Lexical density is defined as the number of lexical words (or content words) divided by the total number of words. In the following sentence the green words are lexical words and the density is 66,67%. Kim loves going to the cinema For the sake of simplicity, we define a lexical word as all words not contained in the provided list of non lexical words in the Appendix. Case sensitivity should be ignored.
● Route: GET /complexity
○ Description:
Return the lexical density of the inputted text. The text should be provided via the body.
○ output :
{ “data”:{ overall_ld: 0.42 } }
● Route: GET /complexity?mode=verbose
○ Description:
Return the lexical density of the text broken down into sentences. The text should be provided via the body.
○ output :
{ “data”:{ sentence_ld: [ 0.23, 0.1, 1.0, 0.0], overall_ld: 0.42 } }
The base url is localhost:3000
- open .env.example and edit your env variables then remove .example from the extenstion file
npm inode init-db.jsnpm start- To send a word please do as follow:
- send a word via post request the body must contain text field for ex:
{"text":"This is a test sentance"} - send more than one sentance:
{"text":"This is first test sentance. this is a second sentance"}
- send a word via post request the body must contain text field for ex:
- To add a new non lexical word do as follow:
- signin using the email and password you had just added them in the .env file by sending
a post request to this endpoint
/loginwith a body like this{"email":"xxx@xxx.com", "password":"xxx"} - you will receive a jwt token add this token to the Authorization header of the post request of adding a new word
for example the curl request will look something like this
http://localhost:8080/complexity/add \ -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImFobWVkaGFueV81QGhvdG1haWwuY29tIiwiaWQiOiI1YjViMTczOTI4OGY4MzAwMDYyMmM4OTIiLCJzdGFsZXMiOjE1MzI2OTgwMTI4NDQsImlhdCI6MTUzMjY5NzExMn0.ZibYbPjC1ehZp3BzSTmsb2Lr1xOH_gGzUfKdSZQgbcY' \ -H 'Cache-Control: no-cache' \ -H 'Content-Type: application/json' \ -H 'Postman-Token: 071e5507-fe96-447a-b0ff-9160f5a682db' \ -d '{ "word":"test" }'```
- signin using the email and password you had just added them in the .env file by sending
a post request to this endpoint
The base url is localhost:8080
- open the docker-compose file and add your env in the environment section but leave the DB_HOST as it is
docker-compose builddocker-compose up
npm test