forked from mizchi/node-mecab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (30 loc) · 620 Bytes
/
Copy pathindex.js
File metadata and controls
34 lines (30 loc) · 620 Bytes
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
var MeCab
try {
MeCab = new require('./build/default/mecab');
}
catch (e) {
if (e.message.match('Cannot find module')) {
MeCab = new require('./build/Release/mecab');
}
else {
throw e;
}
}
exports.MeCab = MeCab;
var nomal = new MeCab.Tagger();
exports.options = function(opt) {
nomal = new MeCab.Tagger(opt);
}
exports.parse = function(text) {
var buf, i, row, _i, _len;
row = nomal.parse(text).split("\n");
buf = [];
for (_i = 0, _len = row.length; _i < _len; _i++) {
i = row[_i];
if (i === "EOS") {
break;
}
buf.push(i.split(/\r\n|\r|,|\t/));
}
return buf;
};