当前位置: 首页>>代码示例>>Java>>正文


Java Seg类代码示例

本文整理汇总了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();
}
 
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:18,代码来源:Complex.java

示例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();
	}
}
 
开发者ID:chenlb,项目名称:mmseg4j-solr,代码行数:26,代码来源:MMSegTokenizerFactoryTest.java

示例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);
}
 
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:9,代码来源:MMSegTokenizer.java

示例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);
}
 
开发者ID:chenlb,项目名称:mmseg4j-solr,代码行数:8,代码来源:MMSegTokenizer.java

示例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;
}
 
开发者ID:chenlb,项目名称:mmseg4j-solr,代码行数:15,代码来源:AnalyzerTest.java

示例6: newSeg

import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
protected Seg newSeg() {
	return new SimpleSeg(dic);
}
 
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:4,代码来源:SimpleAnalyzer.java

示例7: newSeg

import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
protected Seg newSeg() {
	return new MaxWordSeg(dic);
}
 
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:4,代码来源:MMSegAnalyzer.java

示例8: newSeg

import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
protected Seg newSeg() {
	return new ComplexSeg(dic);
}
 
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:4,代码来源:ComplexAnalyzer.java

示例9: getSeg

import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
protected Seg getSeg() {
	return new ComplexSeg(dic);
}
 
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:4,代码来源:Complex.java

示例10: AssertFileLoading

import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
public AssertFileLoading(Seg seg, Analyzer analyzer) {
	this.seg = seg;
	this.analyzer = analyzer;
}
 
开发者ID:chenlb,项目名称:mmseg4j-solr,代码行数:5,代码来源:AnalyzerTest.java

示例11: getSeg

import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
protected Seg getSeg() {

		return new MaxWordSeg(dic);
	}
 
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:5,代码来源:MaxWord.java

示例12: getSeg

import com.chenlb.mmseg4j.Seg; //导入依赖的package包/类
protected Seg getSeg() {

		return new SimpleSeg(dic);
	}
 
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:5,代码来源:Simple.java


注:本文中的com.chenlb.mmseg4j.Seg类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。