git clone https://github.com/varvar/nlp.git
cd to folder nlp
npm install
npm update
npm start
Once server started it will be accessible on http://localhost:3000/
Run tokenizer process for provided .txt file. Average processing time for 5 MB file is about 10 sec and depends on download speed.
-
POST
-
{"file":"http://www.gutenberg.org/cache/epub/10/pg10.txt"}
Please note, that file property required and not optional
-
- Code: 200
Content:{ "processStatus": "Done", "fileName": "pg10.txt", "chunksProcessed": 148, "state": { "totalProcessingTime": "7 sec", "fileSize": "4.25 MB", "downloadSpeed": "601.7 kB/sec" } }
- Code: 200
-
- Code: 500 SERVER ERROR
Content:{ errorObj }
OR
- Code: 400 BAD REQUEST
Content:{ "message": "File value can not be empty!" }
- Code: 500 SERVER ERROR
-
"fileName" property from response object required for getting the words list in next API call, since it's an identifier for retrieving relevant json data. The rest of properties is for information only.
Returns json data for provided file name with words list and repetitions.
-
http://localhost:3000/words/{fileName}/{sort}/{order}
For example: http://localhost:3000/words/pgs10.txt/repetitions/desc
-
GET
-
Required:
fileName=[string]
Optional:
`sort=[repetitions/word]` `order=[asc/desc]`
-
- Code: 200
Content:[ { "word": "project", "repetitions": 5 }, { "word": "gutenberg", "repetitions": 4 }, { "word": "ebook", "repetitions": 8 }, .... ]
- Code: 200
-
- Code: 500 SERVER ERROR
Content:{ "message": { "errno": -2, "code": "ENOENT", "syscall": "open", "path": "/nlp/app/controllers/../../files/pgs10.txt.json" } }
- Code: 500 SERVER ERROR
Serving json data for provided file name via readable stream. This type of serving can increase request speed and performance.
-
http://localhost:3000/pipe/{fileName}
For example: http://localhost:3000/pipe/pgs10.txt
-
GET
-
Required:
fileName=[string]
-
- Code: 200
Content:[ { "word": "project", "repetitions": 5 }, { "word": "gutenberg", "repetitions": 4 }, { "word": "ebook", "repetitions": 8 }, .... ]
- Code: 200
-
- Code: 500 SERVER ERROR
Content:{ "message": { "errno": -2, "code": "ENOENT", "syscall": "open", "path": "/nlp/app/controllers/../../files/pgs10.txt.json" } }
- Code: 500 SERVER ERROR
run "npm test" inside project folder.