当前位置: 首页>>代码示例>>Java>>正文


Java CJKAnalyzer类代码示例

本文整理汇总了Java中org.apache.lucene.analysis.cjk.CJKAnalyzer的典型用法代码示例。如果您正苦于以下问题:Java CJKAnalyzer类的具体用法?Java CJKAnalyzer怎么用?Java CJKAnalyzer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CJKAnalyzer类属于org.apache.lucene.analysis.cjk包,在下文中一共展示了CJKAnalyzer类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: CjkAnalyzerProvider

import org.apache.lucene.analysis.cjk.CJKAnalyzer; //导入依赖的package包/类
public CjkAnalyzerProvider(IndexSettings indexSettings, Environment env, String name, Settings settings) {
    super(indexSettings, name, settings);
    CharArraySet stopWords = Analysis.parseStopWords(
        env, indexSettings.getIndexVersionCreated(), settings, CJKAnalyzer.getDefaultStopSet());

    analyzer = new CJKAnalyzer(stopWords);
    analyzer.setVersion(version);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:CjkAnalyzerProvider.java

示例2: CjkAnalyzerProvider

import org.apache.lucene.analysis.cjk.CJKAnalyzer; //导入依赖的package包/类
@Inject
public CjkAnalyzerProvider(Index index, IndexSettingsService indexSettingsService, Environment env, @Assisted String name, @Assisted Settings settings) {
    super(index, indexSettingsService.getSettings(), name, settings);
    CharArraySet stopWords = Analysis.parseStopWords(env, settings, CJKAnalyzer.getDefaultStopSet());

    analyzer = new CJKAnalyzer(stopWords);
    analyzer.setVersion(version);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:CjkAnalyzerProvider.java

示例3: createCJKAnalyzer

import org.apache.lucene.analysis.cjk.CJKAnalyzer; //导入依赖的package包/类
private Map<Pattern, Analyzer> createCJKAnalyzer() {
  Analyzer analyzer = new CJKAnalyzer();
  Map<Pattern, Analyzer> fieldAnalyzerMaps = new LinkedHashMap<Pattern, Analyzer>();
  Pattern fieldPattern = Pattern.compile("cjk");
  fieldAnalyzerMaps.put(fieldPattern, analyzer);
  return fieldAnalyzerMaps;
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:8,代码来源:TestRemoveOneClauseHeuristic.java

示例4: createIndex

import org.apache.lucene.analysis.cjk.CJKAnalyzer; //导入依赖的package包/类
/**
 * Create index
 */
@SuppressWarnings("deprecation")
public boolean createIndex(int num) {
	boolean signal = false;
	Analyzer analyzer = new CJKAnalyzer(Version.LUCENE_35);
	String path = "E:/topicIndex/querytopic" + num;
	//
	System.out.println("--------createIndex--------");
	//
	File file = new File(path);
	if(file.exists()){
		file.delete();
	}
	file.mkdir();
	
	try{
		Directory dir = FSDirectory.open(file);
		
		IndexWriter TextIndex = new IndexWriter(dir, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
		Document doc;
		
		for(int i = 0; i < this.arrQueryTopic.size(); ++i) {
			doc = new Document();
			doc.add(new Field("ID", this.arrQueryTopic.get(i).toString(), Field.Store.YES, Field.Index.NOT_ANALYZED));		// ע������ID��String���͵�
			doc.add(new Field("QueryWord", this.arrQueryWord.get(i), Field.Store.YES, Field.Index.ANALYZED));
			doc.add(new Field("Times", this.arrQueryWordTimes.get(i), Field.Store.YES, Field.Index.ANALYZED));
			TextIndex.addDocument(doc);
		}
		TextIndex.optimize();
		TextIndex.close();
		signal = true;
	}catch(Exception e) {
		signal = false;
		e.printStackTrace();
	}
	
	return signal;
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:41,代码来源:IndexSearch.java

示例5: search

import org.apache.lucene.analysis.cjk.CJKAnalyzer; //导入依赖的package包/类
/**
 * Search
 */
@SuppressWarnings({ "deprecation", "static-access" })
public boolean search(int num, String str) {
	boolean signal = false;
	Analyzer analyzer = new CJKAnalyzer(Version.LUCENE_35);

	String path = "E:/topicIndex/querytopic" + num;
	File file = new File(path);

	try{
		FSDirectory dir = FSDirectory.open(file);
		
		IndexSearcher indexSearcher = new IndexSearcher(dir);
		
		QueryParser parse = new QueryParser(Version.LUCENE_35, "QueryWord", analyzer);
		Query query = parse.parse(str);
		
		TopDocs topDocs = indexSearcher.search(query, this.QUERYWORDNUM);
		ScoreDoc[] docs = topDocs.scoreDocs;
		
		//
		for(int i = 0; i < docs.length; ++i) {
			System.out.println(indexSearcher.doc(docs[i].doc).get("ID") + "   " 
							 + indexSearcher.doc(docs[i].doc).get("QueryWord") + "   "
							 + indexSearcher.doc(docs[i].doc).get("Times"));
		}
		//
		
		indexSearcher.close();
		signal = true;
	}catch(Exception e) {
		e.printStackTrace();
		signal = false;
	}
	
	return signal;
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:40,代码来源:IndexSearch.java

示例6: TxtFileIndexer

import org.apache.lucene.analysis.cjk.CJKAnalyzer; //导入依赖的package包/类
public TxtFileIndexer(String dataDir_s, String indexDir_s) throws Exception {

		dataDir = new File(dataDir_s);

		indexDir = new File(indexDir_s);
		index_dir = FSDirectory.open(indexDir);// (indexDir,null);
		// public static FSDirectory open(File path)throws IOException
		// Creates an FSDirectory instance 创建一个FSDirectory实例

		indexDirCN = new File(indexDir_s + File.separator + "cn");
		index_dir_cn = FSDirectory.open(indexDirCN);

		// -----------初始化第二步:【分析器】和【索引写入器】---------------------
		luceneAnalyzer = new StandardAnalyzer(Version.LUCENE_47);
		// 在文档被索引前,先要对文档内容进行分词处理,由 Analyzer 来做的
		// Analyzer 类是一个抽象类,它有多个实现。针对不同的语言和应用需选择适合的 Analyzer
		// Analyzer 把分词后的内容交给 IndexWriter 来建立索引

		// StandardAnalyzer 标准分析
		// public StandardAnalyzer(Version matchVersion)
		// Builds an analyzer with the default stop words (STOP_WORDS_SET).
		// Parameters:matchVersion - Lucene version to match See above
		indexWriter = new IndexWriter(index_dir, new IndexWriterConfig(
				Version.LUCENE_47, luceneAnalyzer));

		chineseAnalyzer = new CJKAnalyzer(Version.LUCENE_47);// 中文分析器
		indexWriter_cn = new IndexWriter(index_dir_cn, new IndexWriterConfig(
				Version.LUCENE_47, chineseAnalyzer));
	}
 
开发者ID:wuwenjie1992,项目名称:hello_luence,代码行数:30,代码来源:TxtFileIndexer.java

示例7: get

import org.apache.lucene.analysis.cjk.CJKAnalyzer; //导入依赖的package包/类
@Override
public CJKAnalyzer get() {
    return this.analyzer;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:CjkAnalyzerProvider.java

示例8: IndexerInAdvance

import org.apache.lucene.analysis.cjk.CJKAnalyzer; //导入依赖的package包/类
public static void IndexerInAdvance(String indexDir_s) throws Exception {

		// --------indexWriter初始化---------------
		chineseAnalyzer = new CJKAnalyzer(Version.LUCENE_47);
		// 中文分析器,可以使用其他,庖丁解牛分词器 code.google.com/p/paoding/

		indexDir = new File(indexDir_s);
		nioD = new NIOFSDirectory(indexDir);

		iwc = new IndexWriterConfig(Version.LUCENE_47, chineseAnalyzer);

		iwc.setOpenMode(OpenMode.CREATE_OR_APPEND);
		// Creates a new index if one does not exist
		// otherwise it opens the index and documents will be appended.

		iwc.setRAMBufferSizeMB(2048);// 内存上限
		IndexWriterConfig.setDefaultWriteLockTimeout(10);

		// http://space.itpub.net/28624388/viewspace-766134

	}
 
开发者ID:wuwenjie1992,项目名称:hello_luence,代码行数:22,代码来源:TxtFileIndexer.java


注:本文中的org.apache.lucene.analysis.cjk.CJKAnalyzer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。