Lucene_demo02_分词
/**
* 英文的分词器 中文的分词器
*/
public class AnalyzerTest {
/**
* 英文分词:(Lucene自带包)
* @throws Exception
*/
@Test
public void testEN() throws Exception {
String text = "Creates a searcher searching the index in the named directory";
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30);
this.testAnalyzer(analyzer, text);
}
/**
* 中文分词:单字分词器(Lucene自带包)
* @throws Exception
*/
@Test
public void testCH1() throws Exception {
String text = "LBJ和韦德能带领热火在2013赛季拿到NBA总冠军吗?";
Analyzer analyzer = new ChineseAnalyzer();
this.testAnalyzer(analyzer, text);
}
/**
* 中文分词:二分法分词器(Lucene自带包)
* @throws Exception
*/
@Test
public void testCH2() throws Exception {
String text = "LBJ和韦德能带领热火在2013赛季拿到NBA总冠军吗";
Analyzer analyzer = new CJKAnalyzer(Version.LUCENE_30);
this.testAnalyzer(analyzer, text);
}
/**
* 中文分词:IK分词器(Lucene自带包)
* @throws Exception
*/
@Test
public void testCH3() throws Exception {
String text = "fasd";
Analyzer analyzer = new IKAnalyzer();
this.testAnalyzer(analyzer, text);
}
/**
* 输出分词后的结果
* @param analyzer
* @param text
* @throws Exception
*/
private void testAnalyzer(Analyzer analyzer, String text) throws Exception {
TokenStream tokenStream = analyzer.tokenStream("content", new StringReader(text));
tokenStream.addAttribute(TermAttribute.class);
while (tokenStream.incrementToken()) {
TermAttribute termAttribute = tokenStream.getAttribute(TermAttribute.class);
System.out.println(termAttribute.term());
}
}
}
分享到:
相关推荐
本压缩包的主要内容是Lucene分词器的demo版本,可以导入到程序中直接使用,包含Lucene分词使用的pom文件,使用前请注意修改存储地址。
Lucene.Net+盘古分词是一个常见的中文信息检索组合。但是随着盘古分词停止更新,与Lucene.Net3.0...为了使得大家少走弯路,本人利用Lucene.Net2.9+盘古分词2.3搭建了一个Demo,里面包含了两个模块的源码,方便大家研究。
Lucene.Net+盘古分词是一个常见的中文信息检索组合。但是随着盘古分词停止更新,与Lucene...为了使得大家少走弯路,本人利用Lucene.Net2.9+盘古分词2.3搭建了一个Demo,里面包含了两个模块的源码,方便大家研究。 以上。
压缩包内含有Lucene分词时所需要的jar包,可以添加到本地maven当中使用,但不含demo,如需使用Lucene的demo,还请下载Lucene-Demo.rar
这是Lucene.NET v3.0.3 DEMO范例程序(含PanGu分词),用C#语言编写的,同时对PanGu分词进行了整合,可以直接下载运行。 项目中还整理了一个后台任务线程监听范例,可以用作增量索引创建,但这个需要你自行加入相关...
使用lucene.net盘古分词实现站内搜索demo
Lucene的使用Demo(含分词) Lucene.Net的版本为2.4.0.2
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT); //创建一个语法分析器 IndexWriter iwriter = null; Directory directory = null; try { directory = FSDirectory.open(destDir); //...
Struts2.3+spring4+hibernate4+Lucene4.7+IKAnalyzer,中文分词,高亮显示,附带MySQL8000条测试数据。仅供学习参考
使用Solr + Paoding中文分词的搜索引擎 使用Demo 测试放在C盘根目录
使用maven,Lucene7.1.0,JDK8,SmartChineseAnalyzer中文分词器。使用方法:1. LuceneApp.java运行main方法。 2.Constants.java修改index_path路径为你自己的路径。3.浏览器中输入:http://localhost:8000/
包括lucene .NET4.0&盘古分词 。net可用dll,盘古分词器等
最新庖丁解牛分词法的使用demo,支持Lucene3.3、3.4等3.0以上版本,庖丁解牛的分词包为自己编译生成的,之前的2.0的版本不能支持Lucene3.0以上版本,所以需要从svn下载最新的庖丁解牛源码,生成jar文件(我同样已...
本Demo实现了lucene分词和查询,Dao中实现了lucene的几个基本方法.
这是Pangu分词,可以很清楚的看到分词效果,协助创建索引中文分词效果,还可以进行字典管理,打开release里面的demo.exe直接可以用,字典都在里面
分词效率: 第一次分词需要1-2秒(读取词典),之后速度基本与Lucene自带分词持平 运行环境: Lucene 1.9+ 内存消耗: 30M+ 1.4.0 —— 2006-08-21 增加词典的动态扩展能力 1.3.3 —— 2006-07...
运行项目根目录下的脚本demo-word.bat可以快速体验分词效果 用法: command [text] [input] [output] 命令command的可选值为:demo、text、file demo text 杨尚川是APDPlat应用级产品开发平台的作者 file d:/text.txt...
盘古中文分词+lucene.net2.3.1的详细示例 lucene.net2.3.1+盘古分词 Demo
Lucene.net demo 搜索 带高亮显示 盘古分词 分析器 lucene框架 基本项目功能点实现 代码复用性强