use of com.chenlb.mmseg4j.SimpleSeg in project jstarcraft-nlp by HongZhaoHua.
the class MMSegTokenizerFactory method newSeg.
private Seg newSeg(Map<String, String> configuration) {
Seg seg = null;
logger.info("create new Seg ...");
// default max-word
String mode = configuration.get("mode");
if ("simple".equals(mode)) {
logger.info("use simple mode");
seg = new SimpleSeg(dic);
} else if ("complex".equals(mode)) {
logger.info("use complex mode");
seg = new ComplexSeg(dic);
} else {
logger.info("use max-word mode");
seg = new MaxWordSeg(dic);
}
return seg;
}
use of com.chenlb.mmseg4j.SimpleSeg 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;
}
Aggregations