Skip to content
forked from ysc/word

Java分布式中文分词组件 - word分词

License

Notifications You must be signed in to change notification settings

Melody12ab/word

Repository files navigation

Chinese Word Segmentation Component

分词使用方法:

List<Word> words = WordSeg.seg("杨尚川是APDPlat应用级产品开发平台的作者");
System.out.println(words);

输出:
[杨尚川, 是, APDPlat, 应用, 级, 产品开发, 平台, 的, 作者]

Lucene插件:

Analyzer analyzer = new ChineseWordAnalyzer();

TokenStream tokenStream = analyzer.tokenStream("text", "杨尚川是APDPlat应用级产品开发平台的作者");
while(tokenStream.incrementToken()){
	CharTermAttribute charTermAttribute = tokenStream.getAttribute(CharTermAttribute.class);
	OffsetAttribute offsetAttribute = tokenStream.getAttribute(OffsetAttribute.class);
	System.out.println(charTermAttribute.toString()+" "+offsetAttribute.startOffset());
}

Directory directory = new RAMDirectory();
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_47, analyzer);
IndexWriter indexWriter = new IndexWriter(directory, config);

QueryParser queryParser = new QueryParser(Version.LUCENE_47, "text", analyzer);
Query query = queryParser.parse("text:杨尚川");
TopDocs docs = indexSearcher.search(query, Integer.MAX_VALUE);

分词算法文章:

1、中文分词算法 之 基于词典的正向最大匹配算法

2、中文分词算法 之 基于词典的逆向最大匹配算法

3、中文分词算法 之 词典机制性能优化与测试

4、中文分词算法 之 基于词典的正向最小匹配算法

5、中文分词算法 之 基于词典的逆向最小匹配算法

About

Java分布式中文分词组件 - word分词

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 96.6%
  • Shell 2.0%
  • Batchfile 1.4%