use of com.chenlb.mmseg4j.Dictionary in project java-basic by tzuyichao.
the class TestMMSeg4J method main.
public static void main(String[] args) throws IOException {
Dictionary dictionary = Dictionary.getInstance();
MMSeg mmSeg = new MMSeg(new StringReader("上一堂課之後跑18km與2500rpm的挑戰"), new ComplexSeg(dictionary));
Word word = null;
boolean first = true;
while ((word = mmSeg.next()) != null) {
System.out.println(word.getString());
}
}
use of com.chenlb.mmseg4j.Dictionary in project jstarcraft-nlp by HongZhaoHua.
the class MmsegSegmentFactory method build.
@Override
public MMSeg build(Map<String, String> configurations) {
Dictionary dictionary;
String dictionaryPath = get(configurations, "dictionaryPath");
if (StringUtility.isBlank(dictionaryPath)) {
dictionary = Dictionary.getInstance();
} else {
File file = new File(dictionaryPath);
dictionary = Dictionary.getInstance(file);
}
String configuration = get(configurations, "mode", "MaxWord");
Seg seg = null;
switch(configuration) {
case "Complex":
seg = new ComplexSeg(dictionary);
break;
case "Simple":
seg = new SimpleSeg(dictionary);
break;
case "MaxWord":
seg = new MaxWordSeg(dictionary);
break;
default:
throw new IllegalArgumentException();
}
MMSeg mmSeg = new MMSeg(new StringReader(""), seg);
return mmSeg;
}
use of com.chenlb.mmseg4j.Dictionary in project jstarcraft-nlp by HongZhaoHua.
the class Utils method getDict.
public static Dictionary getDict(String dicPath, ResourceLoader loader) {
Dictionary dic = null;
if (dicPath != null) {
File f = new File(dicPath);
dic = Dictionary.getInstance(f);
} else {
dic = Dictionary.getInstance();
}
return dic;
}
use of com.chenlb.mmseg4j.Dictionary in project jstarcraft-nlp by HongZhaoHua.
the class MmsegSegmenterTestCase method getSegmenter.
@Override
protected Tokenizer getSegmenter() {
Dictionary dictionary = Dictionary.getInstance();
ComplexSeg complex = new ComplexSeg(dictionary);
// MMSeg mmSeg = new MMSeg(new StringReader(""), complex);
MmsegTokenizer tokenizer = new MmsegTokenizer(complex);
return tokenizer;
}
use of com.chenlb.mmseg4j.Dictionary in project jstarcraft-nlp by HongZhaoHua.
the class MmsegTokenizerTestCase method getTokenizer.
@Override
protected NlpTokenizer<? extends NlpToken> getTokenizer() {
Dictionary dictionary = Dictionary.getInstance();
ComplexSeg complex = new ComplexSeg(dictionary);
MMSeg mmSeg = new MMSeg(new StringReader(""), complex);
return new MmsegTokenizer(mmSeg);
}
Aggregations