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

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

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

Operations.minus介绍

[英]Returns a (deterministic) automaton that accepts the intersection of the language of a1 and the complement of the language of a2. As a side-effect, the automata may be determinized, if not already deterministic.

Complexity: quadratic in number of states if a2 already deterministic and exponential in number of a2's states otherwise.
[中]返回一个(确定性)自动机,该自动机接受a1语言与a2语言补码的交集。作为一种副作用,自动机可能是确定的,如果还没有确定的话。
复杂性:如果a2已经确定,则状态数为二次,否则状态数为指数。

代码示例

代码示例来源:origin: oracle/opengrok

/** {@inheritDoc} */
@Override
public TermsEnum getTermsEnumForSuggestions(final Terms terms) {
  if (terms == null) {
    return TermsEnum.EMPTY;
  }
  BytesRef prefix = getPrefix();
  if (prefix != null) {
    Automaton prefixAutomaton = PrefixQuery.toAutomaton(prefix);
    Automaton finalAutomaton;
    if (suggestPosition == SuggestPosition.LOWER) {
      Automaton binaryInt = Automata.makeBinaryInterval(
          getLowerTerm(), includesLower(), getUpperTerm(), includesUpper());
      finalAutomaton = Operations.intersection(binaryInt, prefixAutomaton);
    } else {
      Automaton binaryInt = Automata.makeBinaryInterval(null, true, getLowerTerm(), !includesLower());
      finalAutomaton = Operations.minus(prefixAutomaton, binaryInt, Integer.MIN_VALUE);
    }
    CompiledAutomaton compiledAutomaton = new CompiledAutomaton(finalAutomaton);
    try {
      return compiledAutomaton.getTermsEnum(terms);
    } catch (IOException e) {
      logger.log(Level.WARNING, "Could not compile automaton for range suggestions", e);
    }
  }
  return TermsEnum.EMPTY;
}

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

private Automaton toAutomaton() {
  Automaton a = null;
  if (include != null) {
    a = include.toAutomaton();
  } else if (includeValues != null) {
    a = Automata.makeStringUnion(includeValues);
  } else {
    a = Automata.makeAnyString();
  }
  if (exclude != null) {
    a = Operations.minus(a, exclude.toAutomaton(), Operations.DEFAULT_MAX_DETERMINIZED_STATES);
  } else if (excludeValues != null) {
    a = Operations.minus(a, Automata.makeStringUnion(excludeValues), Operations.DEFAULT_MAX_DETERMINIZED_STATES);
  }
  return a;
}

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

private Automaton toAutomaton() {
  Automaton a = null;
  if (include != null) {
    a = include.toAutomaton();
  } else if (includeValues != null) {
    a = Automata.makeStringUnion(includeValues);
  } else {
    a = Automata.makeAnyString();
  }
  if (exclude != null) {
    a = Operations.minus(a, exclude.toAutomaton(), Operations.DEFAULT_MAX_DETERMINIZED_STATES);
  } else if (excludeValues != null) {
    a = Operations.minus(a, Automata.makeStringUnion(excludeValues), Operations.DEFAULT_MAX_DETERMINIZED_STATES);
  }
  return a;
}

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

private Automaton toAutomaton() {
  Automaton a = null;
  if (include != null) {
    a = include.toAutomaton();
  } else if (includeValues != null) {
    a = Automata.makeStringUnion(includeValues);
  } else {
    a = Automata.makeAnyString();
  }
  if (exclude != null) {
    a = Operations.minus(a, exclude.toAutomaton(), Operations.DEFAULT_MAX_DETERMINIZED_STATES);
  } else if (excludeValues != null) {
    a = Operations.minus(a, Automata.makeStringUnion(excludeValues), Operations.DEFAULT_MAX_DETERMINIZED_STATES);
  }
  return a;
}

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

private Automaton toAutomaton() {
  Automaton a = null;
  if (include != null) {
    a = include.toAutomaton();
  } else if (includeValues != null) {
    a = Automata.makeStringUnion(includeValues);
  } else {
    a = Automata.makeAnyString();
  }
  if (exclude != null) {
    a = Operations.minus(a, exclude.toAutomaton(), Operations.DEFAULT_MAX_DETERMINIZED_STATES);
  } else if (excludeValues != null) {
    a = Operations.minus(a, Automata.makeStringUnion(excludeValues), Operations.DEFAULT_MAX_DETERMINIZED_STATES);
  }
  return a;
}

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

private Automaton toAutomaton() {
  Automaton a = null;
  if (include != null) {
    a = include.toAutomaton();
  } else if (includeValues != null) {
    a = Automata.makeStringUnion(includeValues);
  } else {
    a = Automata.makeAnyString();
  }
  if (exclude != null) {
    a = Operations.minus(a, exclude.toAutomaton(), Operations.DEFAULT_MAX_DETERMINIZED_STATES);
  } else if (excludeValues != null) {
    a = Operations.minus(a, Automata.makeStringUnion(excludeValues), Operations.DEFAULT_MAX_DETERMINIZED_STATES);
  }
  return a;
}

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

private Automaton toAutomaton() {
  Automaton a = null;
  if (include != null) {
    a = include.toAutomaton();
  } else if (includeValues != null) {
    a = Automata.makeStringUnion(includeValues);
  } else {
    a = Automata.makeAnyString();
  }
  if (exclude != null) {
    a = Operations.minus(a, exclude.toAutomaton(), Operations.DEFAULT_MAX_DETERMINIZED_STATES);
  } else if (excludeValues != null) {
    a = Operations.minus(a, Automata.makeStringUnion(excludeValues), Operations.DEFAULT_MAX_DETERMINIZED_STATES);
  }
  return a;
}

相关文章