-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsentenceSplitUsage.js
More file actions
38 lines (31 loc) · 931 Bytes
/
sentenceSplitUsage.js
File metadata and controls
38 lines (31 loc) · 931 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
35
36
37
38
const {initialize} = require("koalanlp/Util");
const {SentenceSplitter} = require("koalanlp/proc");
const {OKT} = require("koalanlp/API");
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let splitter;
async function processText(text){
if (text == null || text.trim().length === 0) {
rl.close();
return;
}
let sentences = await splitter(text);
sentences.forEach((sent, i) => {
console.log(`[${i}] ${sent}`);
});
readInput();
}
function readInput(){
rl.question("분석할 문장을 입력하세요>> ", processText);
}
/***********************
* Main Execution Part *
***********************/
initialize({packages: {OKT: 'LATEST'}}) //HNN
.then(() => {
splitter = new SentenceSplitter(OKT);
readInput();
}).catch((err) => console.error('Error occurred!', err));