-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
38 lines (31 loc) · 1.39 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Simple Word Segmenter
* https://github.com/vpnry/myanmar_word_segmenter
* File: example.js
*/
// const MyWordSegmenter = require("./dev_NodeJs_MyWordSegmenter.js");
// const mSegmenter = new MyWordSegmenter("./MYWORDS.json");
const MyWordSegmenter = require("./MyWordSegmenter");
const mSegmenter = new MyWordSegmenter();
const imagineTestWord =
"123ညီအစ်ကိုမသိတသိအချိန်ညီအစ်ကိုမသိတသိအချိန်Singaporeမသေကောင်းမပျောက်ကောင်းမှုန်မှုန်မွှားမွှား";
console.log("\nTest input", imagineTestWord);
console.log("Test output", mSegmenter.word_segment(imagineTestWord));
// Actually the method `word_segment` also work with sentences thanks to is syllable regex.
// `word_segment_sentence` is added for other languages
console.log(
"\nTest sentence output",
mSegmenter.word_segment_sentence(imagineTestWord + " " + imagineTestWord)
);
/*
[
'123',
'ညီအစ်ကိုမသိတသိအချိန်',
'ညီအစ်ကိုမသိတသိအချိန်',
'Singapore',
'မသေကောင်းမပျောက်ကောင်း',
'မှုန်မှုန်မွှားမွှား'
]
*/
// const syllables = mSegmenter.syllable_segment(imagineTestWord);
// console.log("syllables", syllables);