The server has two
API
Create
dictionary return JSON response.
• Path: '/createDictionary'
• Method: POST
• URL Params: None
• Data Params: {
'dataset': 'PATH_TO_DATASET'
'dataset_n': 'PATH_TO_NO_DIACRITICS_DATASET'
'dictionary': 'PATH_TO_DICTIONARY'
}
• Header required: None
• Success Response:
- Code: 200
- Content:
{'Error': false, 'Message': 'Created dictionary weight success in folder './data'.'}
• Error Response
- Code: 404 NOT FOUND
All requirement fields not full fill or not exist data.
{'Error': true, 'Message": 'Path not exist.'}
Get
dictionary return dictionary file with
gzip format.
• Path: '/getDictionary'
• Method: GET
• URL Params: None
• Data Params: None
• Header required: None
• Success Response:
- Code: 200
- Content:
dictionary file with gzip format.
• Error Response
- Code: 403 Forbidden
Not exist dictionary
Go to folder
client
Using in
Node.js
var vnSegmenter = require('./vnSegmenter');
Using in
browser
<script src="./dist/vnSegmenter.min.js"></script>
Segment a
text
var text = "Trong buổi họp mặt nhân kỉ niệm 28 năm ngày thành lập báo Tuổi Trẻ";
vnSegmenter.segment(text, result => {
console.log(result);
});
// Trong buổi họp_mặt nhân kỉ_niệm 28 năm ngày thành_lập báo Tuổi_Trẻ
Segment a
file
vnSegmenter.segmentFolder('INPUT_FILE_PATH');
Segment a
folder
vnSegmenter.segmentFolder('INPUT_FILE_PATH', 'OUTPUT_FILE_PATH');
To see
options and help run
$ node ./bin/vnsegment -h
Usage: vnSegmenter [options]
Options:
-h, --help display this help and exit
-v, --version display version and exit
-i, --input input path (required)
-o, --output output path (optional)
To segment
file run
$ node ./bin/vnsegment -i INPUT_FILE_PATH
To segment
folder run
$ node ./bin/vnsegment -i INPUT_FOLDER_PATH -o OUTPUT_FOLDER_PATH
Go to
client/examples to see other examples.