本文整理了Java中org.apache.lucene.util.automaton.Operations.optional()
方法的一些代码示例,展示了Operations.optional()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Operations.optional()
方法的具体详情如下:
包路径:org.apache.lucene.util.automaton.Operations
类名称: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
break;
case REGEXP_OPTIONAL:
a = Operations.optional(exp1.toAutomatonInternal(automata,
automaton_provider, maxDeterminizedStates));
a = MinimizationOperations.minimize(a, maxDeterminizedStates);
代码示例来源:origin: harbby/presto-connectors
@Override
public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
final CompletionWeight innerWeight = ((CompletionWeight) innerQuery.createWeight(searcher, needsScores));
// if separators are preserved the fst contains a SEP_LABEL
// behind each gap. To have a matching automaton, we need to
// include the SEP_LABEL in the query as well
Automaton optionalSepLabel = Operations.optional(Automata.makeChar(CompletionAnalyzer.SEP_LABEL));
Automaton prefixAutomaton = Operations.concatenate(optionalSepLabel, innerWeight.getAutomaton());
Automaton contextsAutomaton = Operations.concatenate(toContextAutomaton(contexts, matchAllContexts), prefixAutomaton);
contextsAutomaton = Operations.determinize(contextsAutomaton, Operations.DEFAULT_MAX_DETERMINIZED_STATES);
final Map<IntsRef, Float> contextMap = new HashMap<>(contexts.size());
final TreeSet<Integer> contextLengths = new TreeSet<>();
for (Map.Entry<IntsRef, ContextMetaData> entry : contexts.entrySet()) {
ContextMetaData contextMetaData = entry.getValue();
contextMap.put(entry.getKey(), contextMetaData.boost);
contextLengths.add(entry.getKey().length);
}
int[] contextLengthArray = new int[contextLengths.size()];
final Iterator<Integer> iterator = contextLengths.descendingIterator();
for (int i = 0; iterator.hasNext(); i++) {
contextLengthArray[i] = iterator.next();
}
return new ContextCompletionWeight(this, contextsAutomaton, innerWeight, contextMap, contextLengthArray);
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
break;
case REGEXP_OPTIONAL:
a = Operations.optional(exp1.toAutomatonInternal(automata,
automaton_provider, maxDeterminizedStates));
a = MinimizationOperations.minimize(a, maxDeterminizedStates);
代码示例来源:origin: harbby/presto-connectors
break;
case REGEXP_OPTIONAL:
a = Operations.optional(exp1.toAutomatonInternal(automata,
automaton_provider, maxDeterminizedStates));
a = MinimizationOperations.minimize(a, maxDeterminizedStates);
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene
break;
case REGEXP_OPTIONAL:
a = Operations.optional(exp1.toAutomatonInternal(automata,
automaton_provider, maxDeterminizedStates));
a = MinimizationOperations.minimize(a, maxDeterminizedStates);
内容来源于网络,如有侵权,请联系作者删除!