package com.example.test;
import org.snu.ids.kkma.index.Keyword;
import org.snu.ids.kkma.index.KeywordExtractor;
import org.snu.ids.kkma.index.KeywordList;
import org.snu.ids.kkma.ma.MExpression;
import org.snu.ids.kkma.ma.MorphemeAnalyzer;
import org.snu.ids.kkma.ma.Sentence;
import java.util.List;
public class KkmaTest {
public static void main(String[] args){
// maTest();
extractTest();
}
public static void maTest()
{
String string = "꼬꼬마형태소분석기를테스트할것입니다.";
try {
MorphemeAnalyzer ma = new MorphemeAnalyzer();
ma.createLogger(null);
List<MExpression> ret = ma.analyze(string);
ret = ma.postProcess(ret);
ret = ma.leaveJustBest(ret);
List<Sentence> stl = ma.divideToSentences(ret);
for( int i = 0; i < stl.size(); i++ ) {
Sentence st = stl.get(i);
System.out.println("============================================= " + st.getSentence());
for( int j = 0; j < st.size(); j++ ) {
System.out.println(st.get(j));
}
}
ma.closeLogger();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void extractTest(){
String string = "이부분은명사만추출할것이고오늘은오월12일입니다.";
KeywordExtractor ke = new KeywordExtractor();
KeywordList kl = ke.extractKeyword(string, true);
for( int i = 0; i < kl.size(); i++ ){
Keyword kwrd = kl.get(i);
System.out.println(kwrd.getString() + "\t" + kwrd.getCnt());
}
}
}