lucene IKAnalyzer 中文分词及索引,简单实例
lucene + IKAnalyzer 中文分词及索引,简单实例.txt你看得见我打在屏幕上的字,却看不到我掉在键盘上的泪!自己选择45°仰视别人,就休怪他人135°俯视着看你。doc.guandang.net
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.DateTools;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.mira.lucene.analysis.IK_CAnalyzer;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.FileReader;
import java.util.Date;
public class Searcher {
private static String INDEX_DIR = Searcher.class.getResource("/").getPath()+"/data/index";//"c:\\lucene\\index";
private static String DOC_DIR = Searcher.class.getResource("/").getPath();//"c:\\lucene\\doc";
public static void main(String[] args) throws Exception {
String queryString;
queryString = "测试";
File indexDir = new File(INDEX_DIR);
File docDir = new File(DOC_DIR);
Date start = new Date();
//必须先建索引
try {
IndexWriter writer = new IndexWriter(INDEX_DIR, new IK_CAnalyzer(), true);
System.out.println("Indexing to directory '" + INDEX_DIR + "'...");
indexDocs(writer, docDir);
System.out.println("Optimizing...");
writer.optimize();
writer.close();
Date end = new Date();
System.out.println(end.getTime() - start.getTime() + " total milliseconds");
} catch (IOException e) {
System.out.println(" caught a " + e.getClass() +
"\n with message: " + e.getMessage());
}
if (!indexDir.exists() || !indexDir.isDirectory()) {
throw new Exception(indexDir
+ " does not exist or is not a directory.");
}
search(indexDir, queryString);
}
private static void indexDocs(IndexWriter writer, File file)
throws IOException {
if (file.canRead()) {
if (file.isDirectory()) {
String[] files = file.list();
if (files != null) {
for (int i = 0; i < files.length; i++) {
indexDocs(writer, new File(file, files[i]));
}
}
} else {
System.out.println("adding " + file);
try {
lucene IKAnalyzer 中文分词及索引,简单实例lucene IKAnalyzer 中文分词及索引,简单实例隐藏>> lucene + IKAnalyzer 中文分词及索引,简单实例.txt 你看得见我打在屏幕...
lucene IKAnalyzer 中文分词及索引,简单实例 攻心策略攻心策略隐藏>> http://www.trydone.com/posts/list/344.page import import import import import import ...
它的安装部署十分简单,将 IKAnalyzer3.0GA.jar 部署...{ //建立内存索引对象 directory = new RAMDirectory...说明: 分词器的主类,是 IK 分词器的 Lucene ...
lucene IKAnalyzer 中文分词及索引,简单实例_PPT制作技巧_实用文档。lucene IKAnalyzer 中文分词及索引,简单实例lucene + IKAnalyzer 中文分词及索引,简单实例.txt 你...
分词组件,独立于 Lucene 项目,同时提供了对 Lucene ... 它的安装部署十分简单,将 IKAnalyzer2012.jar 部署...(directory , iwConfig); //写入索引 Document doc...
import org.wltea.analyzer.lucene.IKAnalyzer; ...不索引 //Field.Index.ANALYZED 表示分词且索引 //... 搞笑图片乐翻人 cs3简单制作动态搞笑图片...
索引存放的目录 File indexFile = new File(indexPath); // 创建 分词 对象 Analyzer analyzer = new IKAnalyzer(true);//new StandardAnalyzer(Version.LUCENE_...
它的安装部署十分简单, IKAnalyzer3.X.jar 部署于...(directory); //在索引器中使用IKSimilarity相似度...说明:IK 分词器的主类,是 IK 分词器的 Lucene ...
.lucene.IKAnalyzer; 将 Importorg.apache.lucene.... 实验结果分析本次实验首先对 Nutch 进行了简单的...加入中文分词前后的索引结果可以看出,加入中文分词后...
【苏若年Java系列】Lucene使用Analyzer分词实例 及 IKAnalyzer扩展词库_计算机软件及应用_IT/计算机_专业资料。苏若年 Email: dennisit@163.com Luence 学习--...
热门文档