请指导我如何使用Lucene.net的日语分析器(Lucene.net).同时也建议我为Lucene.net提供一些支持日语的好分析器。
发布于 2014-12-06 20:02:35
Lucene.Net分析器似乎没有移植到Lucene.Net上.您可以在他们的github页面上提出请求,也可以通过移植和提交拉请求来帮助他们。
一旦该分析器存在并使用文章这里 --使用它们的基本代码,只需更改分析器:
string strIndexDir = @"D:\Index";
Lucene.Net.Store.Directory indexDir = Lucene.Net.Store.FSDirectory.Open(new System.IO.DirectoryInfo(strIndexDir));
Analyzer std = new JapaneseAnalyzer(Lucene.Net.Util.Version.LUCENE_29); //Version parameter is used for backward compatibility. Stop words can also be passed to avoid indexing certain words
IndexWriter idxw = new IndexWriter(indexDir, std, true, IndexWriter.MaxFieldLength.UNLIMITED);
//Create an Index writer object.
Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
Lucene.Net.Documents.Field fldText = new Lucene.Net.Documents.Field("text", System.IO.File.ReadAllText(@"d:\test.txt"), Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.ANALYZED, Lucene.Net.Documents.Field.TermVector.YES);
doc.Add(fldText);
//write the document to the index
idxw.AddDocument(doc);
//optimize and close the writer
idxw.Optimize();
idxw.Close();
Response.Write("Indexing Done");
https://stackoverflow.com/questions/27190824
复制相似问题