Lucene中文分词Paoding
来源:互联网 发布:java公开课推荐 编辑:程序博客网 时间:2024/05/01 20:57
Paoding中文分词库是一个使用Java开发的基于Lucene4.x的分词器,可结合到Lucene应用中的,为互联网、企业内部网使用的中文搜索引擎分词组件。Paoding填补了国内中文分词方面开源组件的空白,致力于此并希翼成为互联网网站首选的中文分词开源组件。 Paoding中文分词追求分词的高效率和用户良好体验。
Paoding's Knives 中文分词具有极 高效率 和 高扩展性 。引入隐喻,采用完全的面向对象设计,构思先进。
高效率:在PIII 1G内存个人机器上,1秒 可准确分词 100万 汉字。采用基于 不限制个数的词典文件对文章进行有效切分,使能够将对词汇分类定义。能够对未知的词汇进行合理解析。
项目地址:http://git.oschina.net/zhzhenqin/paoding-analysis
测试实例:
下载最新项目(当前版本2.0.4):
1.将项目中的dic复制到测试工程的根目录下,词典目录默认classpath:dic下,在paoding-dic-home.properties中配置
2.paoding-analysis-2.0.4.jar放在工程的lib下
1.在项目中使用paoding分词
2.Paoding Analyzer 庖丁解牛分词
3.Paoding分词器for Lucene4.x-Solr4.x
Paoding's Knives 中文分词具有极 高效率 和 高扩展性 。引入隐喻,采用完全的面向对象设计,构思先进。
高效率:在PIII 1G内存个人机器上,1秒 可准确分词 100万 汉字。采用基于 不限制个数的词典文件对文章进行有效切分,使能够将对词汇分类定义。能够对未知的词汇进行合理解析。
项目地址:http://git.oschina.net/zhzhenqin/paoding-analysis
测试实例:
下载最新项目(当前版本2.0.4):
1.将项目中的dic复制到测试工程的根目录下,词典目录默认classpath:dic下,在paoding-dic-home.properties中配置
2.paoding-analysis-2.0.4.jar放在工程的lib下
项目pom配置:
<properties><lucene.version>4.6.0</lucene.version></properties><dependencies><dependency><groupId>commons-logging</groupId><artifactId>commons-logging</artifactId><version>1.1.1</version></dependency><dependency><groupId> org.apache.lucene</groupId><artifactId>lucene-core</artifactId><version> ${lucene.version}</version></dependency><dependency><groupId> org.apache.lucene</groupId><artifactId>lucene-analyzers-common</artifactId><version> ${lucene.version}</version></dependency><dependency><groupId> org.apache.lucene</groupId><artifactId>lucene-queryparser</artifactId><version> ${lucene.version}</version></dependency><dependency><groupId> org.apache.lucene</groupId><artifactId>lucene-highlighter</artifactId><version> ${lucene.version}</version></dependency><dependency><groupId>net.paoding</groupId><artifactId>paoding-analysis</artifactId><version>2.0.4</version><scope>system</scope><systemPath>${project.basedir}/lib/paoding-analysis-2.0.4.jar</systemPath></dependency></dependencies>测试实例:
package cn.slimsmart.lucene.paoding.demo;import java.io.StringReader;import net.paoding.analysis.analyzer.PaodingAnalyzer;import org.apache.lucene.analysis.Analyzer;import org.apache.lucene.analysis.TokenStream;import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;import org.apache.lucene.document.Document;import org.apache.lucene.document.Field.Store;import org.apache.lucene.document.TextField;import org.apache.lucene.index.DirectoryReader;import org.apache.lucene.index.IndexWriter;import org.apache.lucene.index.IndexWriterConfig;import org.apache.lucene.queryparser.classic.QueryParser;import org.apache.lucene.search.IndexSearcher;import org.apache.lucene.store.Directory;import org.apache.lucene.store.RAMDirectory;import org.apache.lucene.util.Version;public class Test {public static void main(String[] args) throws Exception {String text="生成analyzer实例 将项目中的dic复制到工程的classpath下,默认配置";testSplitChinese(text);System.out.println("==============");testDemo(text);}/** * 分词测试 */public static void testSplitChinese(String text) throws Exception{// 生成analyzer实例 将项目中的dic复制到工程的根下,若修改paoding.dic.home,更换位置Analyzer analyzer = new PaodingAnalyzer();// 取得Token流TokenStream tokenizer = analyzer.tokenStream("text", new StringReader(text));tokenizer.reset();// 添加工具类 注意:以下这些与之前lucene2.x版本不同的地方CharTermAttribute offAtt = (CharTermAttribute) tokenizer.addAttribute(CharTermAttribute.class);// 循环打印出分词的结果,及分词出现的位置while (tokenizer.incrementToken()) {System.out.print(offAtt.toString() + "\t");}tokenizer.close();}private static Document createDocument(String title, String content) {Document doc = new Document();doc.add(new TextField("title", title, Store.YES));doc.add(new TextField("content", content, Store.YES));return doc;}/** * lucene简单实例 */public static void testDemo(String text) throws Exception{Analyzer analyzer = new PaodingAnalyzer();Directory idx = new RAMDirectory();IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_46,analyzer);IndexWriter writer = new IndexWriter(idx, iwc);writer.addDocument(createDocument("维基百科:关于中文维基百科", "维基百科:关于中文维基百科"));writer.commit();IndexSearcher searcher = new IndexSearcher(DirectoryReader.open(idx)); System.out.println("命中个数:"+searcher.search(new QueryParser(Version.LUCENE_46, "title", analyzer).parse("title:'维基'"), 10).totalHits); writer.close();}}参考文章:
1.在项目中使用paoding分词
2.Paoding Analyzer 庖丁解牛分词
3.Paoding分词器for Lucene4.x-Solr4.x
0 0
- Lucene中文分词Paoding
- Lucene加中文分词paoding调研结果
- Lucene中使用Paoding中文分词
- paoding 中文分词学习
- Paoding中文分词参考手册
- lucene 结合paoding分词器
- 基于Lucene的搜索系统 同时使用Paoding进行中文分词 一
- 基于Lucene的搜索系统 同时使用Paoding进行中文分词 二
- Nutch 分词 中文分词 paoding 疱丁
- paip.中文 分词 ---paoding 3.1 的使用
- Lucene中如何使用庖丁Paoding Analyzer分词器
- 搜索引擎分词:Nutch整合Paoding中文分词步骤详解
- 搜索引擎分词:Nutch整合Paoding中文分词步骤详解
- Lucene中文分词
- Lucene中文分词“庖丁解牛”
- Lucene中文分词
- Lucene 2.3 中文分词
- Lucene中文分词
- 关于面试
- 修改实例大小失败
- ScrollView里面动态设置listView的Item个数
- AndroidStudio Override Method重载方法
- Android官方文档-App Widgets
- Lucene中文分词Paoding
- QuickFIX/N入门:使用消息循环分组
- 空服务器搭建java工程
- 使用PHP搭建自己的MVC框架
- Lucene中文分词mmseg4j
- Mybatis关联查询一对多使用插件分页返回数据不对
- SAT阅读练习题:Reading Comprehension Test 8
- 1020. Tree Traversals (25)
- python使用xlrd xlwt操作Excel