org.apache.lucene.util.automaton.Operations.optional()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(181)

本文整理了Java中org.apache.lucene.util.automaton.Operations.optional()方法的一些代码示例,展示了Operations.optional()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Operations.optional()方法的具体详情如下:
包路径:org.apache.lucene.util.automaton.Operations
类名称:Operations
方法名:optional

Operations.optional介绍

[英]Returns an automaton that accepts the union of the empty string and the language of the given automaton. This may create a dead state.

Complexity: linear in number of states.
[中]

代码示例

代码示例来源:origin: org.apache.lucene/lucene-core

  1. break;
  2. case REGEXP_OPTIONAL:
  3. a = Operations.optional(exp1.toAutomatonInternal(automata,
  4. automaton_provider, maxDeterminizedStates));
  5. a = MinimizationOperations.minimize(a, maxDeterminizedStates);

代码示例来源:origin: harbby/presto-connectors

  1. @Override
  2. public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
  3. final CompletionWeight innerWeight = ((CompletionWeight) innerQuery.createWeight(searcher, needsScores));
  4. // if separators are preserved the fst contains a SEP_LABEL
  5. // behind each gap. To have a matching automaton, we need to
  6. // include the SEP_LABEL in the query as well
  7. Automaton optionalSepLabel = Operations.optional(Automata.makeChar(CompletionAnalyzer.SEP_LABEL));
  8. Automaton prefixAutomaton = Operations.concatenate(optionalSepLabel, innerWeight.getAutomaton());
  9. Automaton contextsAutomaton = Operations.concatenate(toContextAutomaton(contexts, matchAllContexts), prefixAutomaton);
  10. contextsAutomaton = Operations.determinize(contextsAutomaton, Operations.DEFAULT_MAX_DETERMINIZED_STATES);
  11. final Map<IntsRef, Float> contextMap = new HashMap<>(contexts.size());
  12. final TreeSet<Integer> contextLengths = new TreeSet<>();
  13. for (Map.Entry<IntsRef, ContextMetaData> entry : contexts.entrySet()) {
  14. ContextMetaData contextMetaData = entry.getValue();
  15. contextMap.put(entry.getKey(), contextMetaData.boost);
  16. contextLengths.add(entry.getKey().length);
  17. }
  18. int[] contextLengthArray = new int[contextLengths.size()];
  19. final Iterator<Integer> iterator = contextLengths.descendingIterator();
  20. for (int i = 0; iterator.hasNext(); i++) {
  21. contextLengthArray[i] = iterator.next();
  22. }
  23. return new ContextCompletionWeight(this, contextsAutomaton, innerWeight, contextMap, contextLengthArray);
  24. }

代码示例来源:origin: org.infinispan/infinispan-embedded-query

  1. break;
  2. case REGEXP_OPTIONAL:
  3. a = Operations.optional(exp1.toAutomatonInternal(automata,
  4. automaton_provider, maxDeterminizedStates));
  5. a = MinimizationOperations.minimize(a, maxDeterminizedStates);

代码示例来源:origin: harbby/presto-connectors

  1. break;
  2. case REGEXP_OPTIONAL:
  3. a = Operations.optional(exp1.toAutomatonInternal(automata,
  4. automaton_provider, maxDeterminizedStates));
  5. a = MinimizationOperations.minimize(a, maxDeterminizedStates);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

  1. break;
  2. case REGEXP_OPTIONAL:
  3. a = Operations.optional(exp1.toAutomatonInternal(automata,
  4. automaton_provider, maxDeterminizedStates));
  5. a = MinimizationOperations.minimize(a, maxDeterminizedStates);

相关文章