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


Java InputIterator.next方法代码示例

本文整理汇总了Java中org.apache.lucene.search.suggest.InputIterator.next方法的典型用法代码示例。如果您正苦于以下问题:Java InputIterator.next方法的具体用法?Java InputIterator.next怎么用?Java InputIterator.next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.search.suggest.InputIterator的用法示例。


在下文中一共展示了InputIterator.next方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rebuild

import org.apache.lucene.search.suggest.InputIterator; //导入方法依赖的package包/类
/**
 * Rebuild a suggestion index from the document index.
 *
 * This method iterates through the entire document index and makes sure that only unique titles
 * are indexed.
 *
 * @param indexRoot The parent directory inside which both the document index and the suggestion
 *                  index lives.
 * @throws IOException
 */
public static void rebuild(String indexRoot) throws IOException {
  Path indexRootPath = Paths.get(indexRoot);
  Path suggestionPath = getSuggestionIndexPath(indexRootPath);

  // Delete the suggestion index if it exists.
  if (Files.exists(suggestionPath)) {
    Util.deletePath(suggestionPath);
  }

  // Create the suggestion index.
  Analyzer analyzer = Indexer.getAnalyzer();
  Directory suggestionDir = FSDirectory.open(getSuggestionIndexPath(indexRootPath));
  AnalyzingInfixSuggester suggester = new AnalyzingInfixSuggester(suggestionDir, analyzer);

  // Open the document index.
  Directory indexDir = FSDirectory.open(Indexer.getMainIndexPath(indexRootPath));
  IndexReader reader = DirectoryReader.open(indexDir);

  // Get a document iterator.
  DocumentDictionary docDict = new DocumentDictionary(reader, Indexer.TITLE_FIELD_NAME, null);
  InputIterator iterator = docDict.getEntryIterator();
  Set<BytesRef> titleSet = new HashSet<>();
  BytesRef next;
  while ((next = iterator.next()) != null) {
    if (titleSet.contains(next)) {
      continue;
    }

    titleSet.add(next);
    suggester.add(next, null, 0, null);
  }

  reader.close();

  suggester.commit();
  suggester.close();
}
 
开发者ID:lukhnos,项目名称:lucenestudy,代码行数:48,代码来源:Suggester.java

示例2: build

import org.apache.lucene.search.suggest.InputIterator; //导入方法依赖的package包/类
@Override
public void build(InputIterator iterator) throws IOException {
  if (iterator.hasPayloads()) {
    throw new IllegalArgumentException("this suggester doesn't support payloads");
  }
  BytesRef scratch = new BytesRef();
  InputIterator iter = new WFSTInputIterator(iterator);
  IntsRef scratchInts = new IntsRef();
  BytesRef previous = null;
  PositiveIntOutputs outputs = PositiveIntOutputs.getSingleton();
  Builder<Long> builder = new Builder<Long>(FST.INPUT_TYPE.BYTE1, outputs);
  while ((scratch = iter.next()) != null) {
    long cost = iter.weight();
    
    if (previous == null) {
      previous = new BytesRef();
    } else if (scratch.equals(previous)) {
      continue; // for duplicate suggestions, the best weight is actually
                // added
    }
    Util.toIntsRef(scratch, scratchInts);
    builder.add(scratchInts, cost);
    previous.copyBytes(scratch);
  }
  fst = builder.finish();
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:27,代码来源:WFSTCompletionLookup.java

示例3: add

import org.apache.lucene.search.suggest.InputIterator; //导入方法依赖的package包/类
/**
 * Like build(), but without flushing the old entries, and *ignores duplicate entries*
 * 
 * @param dict
 * @throws IOException
 */
public void add(Dictionary dict) throws IOException {
  InputIterator iter = dict.getEntryIterator();
  BytesRef text;
  while ((text = iter.next()) != null) {
    if (lookup(text.utf8ToString(), 1, true, false).size() > 0) {
      continue;
    }
    add(text, iter.contexts(), iter.weight(), iter.payload());
  }
}
 
开发者ID:safarijv,项目名称:ifpress-solr-plugin,代码行数:17,代码来源:SafariInfixSuggester.java

示例4: build

import org.apache.lucene.search.suggest.InputIterator; //导入方法依赖的package包/类
@Override
public void build(InputIterator iterator) throws IOException {
  if (iterator.hasPayloads()) {
    throw new IllegalArgumentException("this suggester doesn't support payloads");
  }
  count = 0;
  BytesRef scratch = new BytesRef();
  InputIterator iter = new WFSTInputIterator(iterator);
  IntsRef scratchInts = new IntsRef();
  BytesRef previous = null;
  PositiveIntOutputs outputs = PositiveIntOutputs.getSingleton();
  Builder<Long> builder = new Builder<Long>(FST.INPUT_TYPE.BYTE1, outputs);
  while ((scratch = iter.next()) != null) {
    long cost = iter.weight();
    
    if (previous == null) {
      previous = new BytesRef();
    } else if (scratch.equals(previous)) {
      continue; // for duplicate suggestions, the best weight is actually
                // added
    }
    Util.toIntsRef(scratch, scratchInts);
    builder.add(scratchInts, cost);
    previous.copyBytes(scratch);
    count++;
  }
  fst = builder.finish();
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:29,代码来源:WFSTCompletionLookup.java


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