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

x33g5p2x  于2022-01-17 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(109)

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

Automata.makeChar介绍

[英]Returns a new (deterministic) automaton that accepts a single codepoint of the given value.
[中]返回一个新的(确定性)自动机,该自动机接受给定值的单个代码点。

代码示例

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

final int nextChar = wildcardText.codePointAt(i + length);
 length += Character.charCount(nextChar);
 automata.add(Automata.makeChar(nextChar));
 break;
automata.add(Automata.makeChar(c));

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

break;
case REGEXP_CHAR:
 a = Automata.makeChar(c);
 break;
case REGEXP_CHAR_RANGE:

代码示例来源:origin: org.elasticsearch/elasticsearch

/** Make matches on objects also match dots in field names.
 *  For instance, if the original simple regex is `foo`, this will translate
 *  it into `foo` OR `foo.*`. */
private static Automaton makeMatchDotsInFieldNames(Automaton automaton) {
  return Operations.union(
      automaton,
      Operations.concatenate(Arrays.asList(automaton, Automata.makeChar('.'), Automata.makeAnyString())));
}

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

break;
case REGEXP_CHAR:
 a = Automata.makeChar(c);
 break;
case REGEXP_CHAR_RANGE:

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

final int nextChar = wildcardText.codePointAt(i + length);
 length += Character.charCount(nextChar);
 automata.add(Automata.makeChar(nextChar));
 break;
automata.add(Automata.makeChar(c));

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

break;
case REGEXP_CHAR:
 a = Automata.makeChar(c);
 break;
case REGEXP_CHAR_RANGE:

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

/** Make matches on objects also match dots in field names.
 *  For instance, if the original simple regex is `foo`, this will translate
 *  it into `foo` OR `foo.*`. */
private static Automaton makeMatchDotsInFieldNames(Automaton automaton) {
  return Operations.union(
      automaton,
      Operations.concatenate(Arrays.asList(automaton, Automata.makeChar('.'), Automata.makeAnyString())));
}

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

break;
case REGEXP_CHAR:
 a = Automata.makeChar(c);
 break;
case REGEXP_CHAR_RANGE:

代码示例来源:origin: org.codelibs/elasticsearch-querybuilders

/** Make matches on objects also match dots in field names.
 *  For instance, if the original simple regex is `foo`, this will translate
 *  it into `foo` OR `foo.*`. */
private static Automaton makeMatchDotsInFieldNames(Automaton automaton) {
  return Operations.union(
      automaton,
      Operations.concatenate(Arrays.asList(automaton, Automata.makeChar('.'), Automata.makeAnyString())));
}

代码示例来源:origin: apache/servicemix-bundles

/** Make matches on objects also match dots in field names.
 *  For instance, if the original simple regex is `foo`, this will translate
 *  it into `foo` OR `foo.*`. */
private static Automaton makeMatchDotsInFieldNames(Automaton automaton) {
  return Operations.union(
      automaton,
      Operations.concatenate(Arrays.asList(automaton, Automata.makeChar('.'), Automata.makeAnyString())));
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

/** Make matches on objects also match dots in field names.
 *  For instance, if the original simple regex is `foo`, this will translate
 *  it into `foo` OR `foo.*`. */
private static Automaton makeMatchDotsInFieldNames(Automaton automaton) {
  return Operations.union(
      automaton,
      Operations.concatenate(Arrays.asList(automaton, Automata.makeChar('.'), Automata.makeAnyString())));
}

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

final int nextChar = wildcardText.codePointAt(i + length);
 length += Character.charCount(nextChar);
 automata.add(Automata.makeChar(nextChar));
 break;
automata.add(Automata.makeChar(c));

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

final int nextChar = wildcardText.codePointAt(i + length);
 length += Character.charCount(nextChar);
 automata.add(Automata.makeChar(nextChar));
 break;
automata.add(Automata.makeChar(c));

代码示例来源: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: com.strapdata.elasticsearch/elasticsearch

/**
 * Create a automaton for a given context query this automaton will be used
 * to find the matching paths with the fst
 *
 * @param preserveSep set an additional char (<code>XAnalyzingSuggester.SEP_LABEL</code>) between each context query
 * @param queries list of {@link ContextQuery} defining the lookup context
 *
 * @return Automaton matching the given Query
 */
public static Automaton toAutomaton(boolean preserveSep, Iterable<ContextQuery> queries) {
  Automaton a = Automata.makeEmptyString();
  Automaton gap = Automata.makeChar(ContextMapping.SEPARATOR);
  if (preserveSep) {
    // 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
    gap = Operations.concatenate(gap, Automata.makeChar(XAnalyzingSuggester.SEP_LABEL));
  }
  for (ContextQuery query : queries) {
    a = Operations.concatenate(Arrays.asList(query.toAutomaton(), gap, a));
  }
  // TODO: should we limit this?  Do any of our ContextQuery impls really create exponential regexps?
  // GeoQuery looks safe (union of strings).
  return Operations.determinize(a, Integer.MAX_VALUE);
}

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

/**
 * Create a automaton for a given context query this automaton will be used
 * to find the matching paths with the fst
 *
 * @param preserveSep set an additional char (<code>XAnalyzingSuggester.SEP_LABEL</code>) between each context query
 * @param queries list of {@link ContextQuery} defining the lookup context
 *
 * @return Automaton matching the given Query
 */
public static Automaton toAutomaton(boolean preserveSep, Iterable<ContextQuery> queries) {
  Automaton a = Automata.makeEmptyString();
  Automaton gap = Automata.makeChar(ContextMapping.SEPARATOR);
  if (preserveSep) {
    // 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
    gap = Operations.concatenate(gap, Automata.makeChar(XAnalyzingSuggester.SEP_LABEL));
  }
  for (ContextQuery query : queries) {
    a = Operations.concatenate(Arrays.asList(query.toAutomaton(), gap, a));
  }
  // TODO: should we limit this?  Do any of our ContextQuery impls really create exponential regexps?  GeoQuery looks safe (union
  // of strings).
  return Operations.determinize(a, Integer.MAX_VALUE);
}

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

private static Automaton toContextAutomaton(final Map<IntsRef, ContextMetaData> contexts, final boolean matchAllContexts) {
 final Automaton matchAllAutomaton = Operations.repeat(Automata.makeAnyString());
 final Automaton sep = Automata.makeChar(ContextSuggestField.CONTEXT_SEPARATOR);
 if (matchAllContexts || contexts.size() == 0) {
  return Operations.concatenate(matchAllAutomaton, sep);
 } else {
  Automaton contextsAutomaton = null;
  for (Map.Entry<IntsRef, ContextMetaData> entry : contexts.entrySet()) {
   final ContextMetaData contextMetaData = entry.getValue();
   final IntsRef ref = entry.getKey();
   Automaton contextAutomaton = Automata.makeString(ref.ints, ref.offset, ref.length);
   if (contextMetaData.exact == false) {
    contextAutomaton = Operations.concatenate(contextAutomaton, matchAllAutomaton);
   }
   contextAutomaton = Operations.concatenate(contextAutomaton, sep);
   if (contextsAutomaton == null) {
    contextsAutomaton = contextAutomaton;
   } else {
    contextsAutomaton = Operations.union(contextsAutomaton, contextAutomaton);
   }
  }
  return contextsAutomaton;
 }
}

代码示例来源:origin: org.codelibs/elasticsearch-querybuilders

/**
     * Create a automaton for a given context query this automaton will be used
     * to find the matching paths with the fst
     *
     * @param preserveSep set an additional char (<code>XAnalyzingSuggester.SEP_LABEL</code>) between each context query
     * @param queries list of {ContextQuery} defining the lookup context
     *
     * @return Automaton matching the given Query
     */
    public static Automaton toAutomaton(boolean preserveSep, Iterable<ContextQuery> queries) {
      Automaton a = Automata.makeEmptyString();

      Automaton gap = Automata.makeChar(ContextMapping.SEPARATOR);
      if (preserveSep) {
        // 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
//                gap = Operations.concatenate(gap, Automata.makeChar(XAnalyzingSuggester.SEP_LABEL));
      }

      for (ContextQuery query : queries) {
        a = Operations.concatenate(Arrays.asList(query.toAutomaton(), gap, a));
      }

      // TODO: should we limit this?  Do any of our ContextQuery impls really create exponential regexps?
      // GeoQuery looks safe (union of strings).
      return Operations.determinize(a, Integer.MAX_VALUE);
    }

相关文章