本文整理汇总了Java中com.chenlb.mmseg4j.Seg类的典型用法代码示例。如果您正苦于以下问题:Java Seg类的具体用法?Java Seg怎么用?Java Seg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Seg类属于com.chenlb.mmseg4j包,在下文中一共展示了Seg类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: segWords
import com.chenlb.mmseg4j.Seg; //导入依赖的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: assertTokenizerFactory
import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
private void assertTokenizerFactory(final String fieldName, final Seg seg) throws IOException {
logger.info("assert TokenizerFactory field type={}", fieldName);
FileInputStream fis = new FileInputStream("src/test/resources/text-sentence.txt");
try {
Dictionary.load(fis, new FileLoading() {
@Override
public void row(String line, int n) {
List<String> mwords = AnalyzerTest.toMMsegWords(line, seg);
assertU(adoc("id", String.valueOf(n), fieldName, line));
assertU(commit());
logger.debug("words = {}", mwords);
for (String word : mwords) {
assertQ(req("q", "id:" + String.valueOf(n) + " AND " + fieldName + ":" + word),
"//*[@numFound='1']",
"//result/doc[1]/int[@name='id'][.='" + String.valueOf(n) + "']");
}
}
});
} finally {
fis.close();
}
}
示例3: MMSegTokenizer
import com.chenlb.mmseg4j.Seg; //导入依赖的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);
}
示例4: MMSegTokenizer
import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
public MMSegTokenizer(Seg seg) {
this.seg = seg;
termAtt = addAttribute(CharTermAttribute.class);
offsetAtt = addAttribute(OffsetAttribute.class);
typeAtt = addAttribute(TypeAttribute.class);
}
示例5: toMMsegWords
import com.chenlb.mmseg4j.Seg; //导入依赖的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;
}
示例6: newSeg
import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
protected Seg newSeg() {
return new SimpleSeg(dic);
}
示例7: newSeg
import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
protected Seg newSeg() {
return new MaxWordSeg(dic);
}
示例8: newSeg
import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
protected Seg newSeg() {
return new ComplexSeg(dic);
}
示例9: getSeg
import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
protected Seg getSeg() {
return new ComplexSeg(dic);
}
示例10: AssertFileLoading
import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
public AssertFileLoading(Seg seg, Analyzer analyzer) {
this.seg = seg;
this.analyzer = analyzer;
}
示例11: getSeg
import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
protected Seg getSeg() {
return new MaxWordSeg(dic);
}
示例12: getSeg
import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
protected Seg getSeg() {
return new SimpleSeg(dic);
}