本文整理汇总了Java中com.chenlb.mmseg4j.MMSeg类的典型用法代码示例。如果您正苦于以下问题:Java MMSeg类的具体用法?Java MMSeg怎么用?Java MMSeg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MMSeg类属于com.chenlb.mmseg4j包,在下文中一共展示了MMSeg类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: segWords
import com.chenlb.mmseg4j.MMSeg; //导入依赖的package包/类
public String segWords(Reader input, String wordSpilt) throws IOException {
StringBuilder sb = new StringBuilder();
Seg seg = getSeg(); //取得不同的分词具体算法
MMSeg mmSeg = new MMSeg(input, seg);
Word word = null;
boolean first = true;
while((word=mmSeg.next())!=null) {
if(!first) {
sb.append(wordSpilt);
}
String w = word.getString();
sb.append(w);
first = false;
}
return sb.toString();
}
示例2: MMSegTokenizer
import com.chenlb.mmseg4j.MMSeg; //导入依赖的package包/类
public MMSegTokenizer(Seg seg, Reader input) {
super(input);
mmSeg = new MMSeg(input, seg);
termAtt = addAttribute(CharTermAttribute.class);
offsetAtt = addAttribute(OffsetAttribute.class);
typeAtt = addAttribute(TypeAttribute.class);
}
示例3: toMMsegWords
import com.chenlb.mmseg4j.MMSeg; //导入依赖的package包/类
public static List<String> toMMsegWords(String txt, Seg seg) {
List<String> words = new ArrayList<String>();
MMSeg mmSeg = new MMSeg(new StringReader(txt), seg);
Word word = null;
try {
while ((word = mmSeg.next()) != null) {
String w = word.getString();
words.add(w);
}
} catch (IOException e) {
e.printStackTrace();
}
return words;
}