/SimilarityService

A Rest API to find user authentication based similarity between two sentences, through Natural Language Processing.

Primary LanguageJavaScript

Similarity Service

A Rest API to detect the similarity between two sentences.


Authors



Tech Stack

Server: Flask
Language: Python
Database: MongoDb
Container: Docker, Docker-Compose
ML: Spacy


API Reference


Register a new user

  POST /register
Parameter Type Description
username string Required. username to register
password string Required. password of the user

Sample Request

{
    "username": "user2",
    "password": "user_password"
}

Sample Response

{
    "msg": "Sign up Successful",
    "results": {
        "similarity": null
    },
    "status": 200,
    "userInformation": {
        "currentTokens": 6,
        "username": "user2"
    }
}

Detect similarity between two texts

  POST /detect
Parameter Type Description
username string Required. username to validate user
password string Required. password of the user
text1 string Required. Sentence1
textt2 string Required. Sentence2

Sample Request

{
    "username": "user2",
    "password": "user_password",
    "text1" : "you have ",
    "text2" : "You My Have "
}

Sample Response

{
    "msg": "Success",
    "results": {
        "similarity": 53.80624762110769
    },
    "status": 200,
    "userInformation": {
        "currentTokens": 5,
        "username": "user2"
    }
}

Refill the user specific tokens

  POST /refill
Parameter Type Description
username string Required. username to validate user
admin_pw string Required. admin password
refill integer Required. the number of tokens to add

Sample Request

{
    "username": "user2",
    "admin_pw": "admin_password",
    "refill" : 10
}

Sample Response

{
    "msg": "Success",
    "results": {
        "similarity": null
    },
    "status": 200,
    "userInformation": {
        "currentTokens": 15,
        "username": "user2"
    }
}


Build Details:



To build the project on your system


  • Open your terminal in the required directory

  • Clone the repository

  git clone git@github.com:stenzr/SimilarityService.git

  • CD to the project directory
  cd SimilarityService

  • Build the docker images
  sudo docker-compose build

  • Start the Services
  sudo docker-compose up

  • The server starts on localhost:5000

  • Use Postman to send request to the endpoints