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


Java CompiledAutomaton类代码示例

本文整理汇总了Java中org.apache.lucene.util.automaton.CompiledAutomaton的典型用法代码示例。如果您正苦于以下问题:Java CompiledAutomaton类的具体用法?Java CompiledAutomaton怎么用?Java CompiledAutomaton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CompiledAutomaton类属于org.apache.lucene.util.automaton包,在下文中一共展示了CompiledAutomaton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initAutomata

import org.apache.lucene.util.automaton.CompiledAutomaton; //导入依赖的package包/类
/** initialize levenshtein DFAs up to maxDistance, if possible */
private List<CompiledAutomaton> initAutomata(int maxDistance) {
  final List<CompiledAutomaton> runAutomata = dfaAtt.automata();
  //System.out.println("cached automata size: " + runAutomata.size());
  if (runAutomata.size() <= maxDistance &&
      maxDistance <= LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE) {
    LevenshteinAutomata builder = 
      new LevenshteinAutomata(UnicodeUtil.newString(termText, realPrefixLength, termText.length - realPrefixLength), transpositions);

    String prefix = UnicodeUtil.newString(termText, 0, realPrefixLength);
    for (int i = runAutomata.size(); i <= maxDistance; i++) {
      Automaton a = builder.toAutomaton(i, prefix);
      //System.out.println("compute automaton n=" + i);
      runAutomata.add(new CompiledAutomaton(a, true, false));
    }
  }
  return runAutomata;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:FuzzyTermsEnum.java

示例2: intersect

import org.apache.lucene.util.automaton.CompiledAutomaton; //导入依赖的package包/类
@Override
public TermsEnum intersect(CompiledAutomaton compiled, BytesRef startTerm) throws IOException {
  final List<MultiTermsEnum.TermsEnumIndex> termsEnums = new ArrayList<>();
  for(int i=0;i<subs.length;i++) {
    final TermsEnum termsEnum = subs[i].intersect(compiled, startTerm);
    if (termsEnum != null) {
      termsEnums.add(new MultiTermsEnum.TermsEnumIndex(termsEnum, i));
    }
  }

  if (termsEnums.size() > 0) {
    return new MultiTermsEnum(subSlices).reset(termsEnums.toArray(MultiTermsEnum.TermsEnumIndex.EMPTY_ARRAY));
  } else {
    return TermsEnum.EMPTY;
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:MultiTerms.java

示例3: intersect

import org.apache.lucene.util.automaton.CompiledAutomaton; //导入依赖的package包/类
/** Returns a TermsEnum that iterates over all terms that
 *  are accepted by the provided {@link
 *  CompiledAutomaton}.  If the <code>startTerm</code> is
 *  provided then the returned enum will only accept terms
 *  > <code>startTerm</code>, but you still must call
 *  next() first to get to the first term.  Note that the
 *  provided <code>startTerm</code> must be accepted by
 *  the automaton.
 *
 * <p><b>NOTE</b>: the returned TermsEnum cannot
 * seek</p>. */
public TermsEnum intersect(CompiledAutomaton compiled, final BytesRef startTerm) throws IOException {
  // TODO: eventually we could support seekCeil/Exact on
  // the returned enum, instead of only being able to seek
  // at the start
  if (compiled.type != CompiledAutomaton.AUTOMATON_TYPE.NORMAL) {
    throw new IllegalArgumentException("please use CompiledAutomaton.getTermsEnum instead");
  }
  if (startTerm == null) {
    return new AutomatonTermsEnum(iterator(null), compiled);
  } else {
    return new AutomatonTermsEnum(iterator(null), compiled) {
      @Override
      protected BytesRef nextSeekTerm(BytesRef term) throws IOException {
        if (term == null) {
          term = startTerm;
        }
        return super.nextSeekTerm(term);
      }
    };
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:Terms.java

示例4: initAutomata

import org.apache.lucene.util.automaton.CompiledAutomaton; //导入依赖的package包/类
/** initialize levenshtein DFAs up to maxDistance, if possible */
private List<CompiledAutomaton> initAutomata(int maxDistance) {
  final List<CompiledAutomaton> runAutomata = dfaAtt.automata();
  //System.out.println("cached automata size: " + runAutomata.size());
  if (runAutomata.size() <= maxDistance && 
      maxDistance <= LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE) {
    LevenshteinAutomata builder = 
      new LevenshteinAutomata(UnicodeUtil.newString(termText, realPrefixLength, termText.length - realPrefixLength), transpositions);

    for (int i = runAutomata.size(); i <= maxDistance; i++) {
      Automaton a = builder.toAutomaton(i);
      //System.out.println("compute automaton n=" + i);
      // constant prefix
      if (realPrefixLength > 0) {
        Automaton prefix = BasicAutomata.makeString(
          UnicodeUtil.newString(termText, 0, realPrefixLength));
        a = BasicOperations.concatenate(prefix, a);
      }
      runAutomata.add(new CompiledAutomaton(a, true, false));
    }
  }
  return runAutomata;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:24,代码来源:FuzzyTermsEnum.java

示例5: intersect

import org.apache.lucene.util.automaton.CompiledAutomaton; //导入依赖的package包/类
@Override
public TermsEnum intersect(CompiledAutomaton compiled, BytesRef startTerm) throws IOException {
  final List<MultiTermsEnum.TermsEnumIndex> termsEnums = new ArrayList<MultiTermsEnum.TermsEnumIndex>();
  for(int i=0;i<subs.length;i++) {
    final TermsEnum termsEnum = subs[i].intersect(compiled, startTerm);
    if (termsEnum != null) {
      termsEnums.add(new MultiTermsEnum.TermsEnumIndex(termsEnum, i));
    }
  }

  if (termsEnums.size() > 0) {
    return new MultiTermsEnum(subSlices).reset(termsEnums.toArray(MultiTermsEnum.TermsEnumIndex.EMPTY_ARRAY));
  } else {
    return TermsEnum.EMPTY;
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:17,代码来源:MultiTerms.java

示例6: intersect

import org.apache.lucene.util.automaton.CompiledAutomaton; //导入依赖的package包/类
@Override
public TermsEnum intersect(CompiledAutomaton compiled, BytesRef startTerm) throws IOException {
  if (compiled.type != CompiledAutomaton.AUTOMATON_TYPE.NORMAL) {
    throw new IllegalArgumentException("please use CompiledAutomaton.getTermsEnum instead");
  }
  return new IntersectTermsEnum(this, compiled, startTerm);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:FieldReader.java

示例7: getAutomatonEnum

import org.apache.lucene.util.automaton.CompiledAutomaton; //导入依赖的package包/类
/**
 * return an automata-based enum for matching up to editDistance from
 * lastTerm, if possible
 */
protected TermsEnum getAutomatonEnum(int editDistance, BytesRef lastTerm)
    throws IOException {
  final List<CompiledAutomaton> runAutomata = initAutomata(editDistance);
  if (editDistance < runAutomata.size()) {
    //System.out.println("FuzzyTE.getAEnum: ed=" + editDistance + " lastTerm=" + (lastTerm==null ? "null" : lastTerm.utf8ToString()));
    final CompiledAutomaton compiled = runAutomata.get(editDistance);
    return new AutomatonFuzzyTermsEnum(terms.intersect(compiled, lastTerm == null ? null : compiled.floor(lastTerm, new BytesRefBuilder())),
                                       runAutomata.subList(0, editDistance + 1).toArray(new CompiledAutomaton[editDistance + 1]));
  } else {
    return null;
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:FuzzyTermsEnum.java

示例8: AutomatonFuzzyTermsEnum

import org.apache.lucene.util.automaton.CompiledAutomaton; //导入依赖的package包/类
public AutomatonFuzzyTermsEnum(TermsEnum tenum, CompiledAutomaton compiled[]) {
  super(tenum, false);
  this.matchers = new ByteRunAutomaton[compiled.length];
  for (int i = 0; i < compiled.length; i++)
    this.matchers[i] = compiled[i].runAutomaton;
  termRef = new BytesRef(term.text());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:FuzzyTermsEnum.java

示例9: copyTo

import org.apache.lucene.util.automaton.CompiledAutomaton; //导入依赖的package包/类
@Override
public void copyTo(AttributeImpl target) {
  final List<CompiledAutomaton> targetAutomata =
    ((LevenshteinAutomataAttribute) target).automata();
  targetAutomata.clear();
  targetAutomata.addAll(automata);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:FuzzyTermsEnum.java

示例10: AutomatonTermsEnum

import org.apache.lucene.util.automaton.CompiledAutomaton; //导入依赖的package包/类
/**
 * Construct an enumerator based upon an automaton, enumerating the specified
 * field, working on a supplied TermsEnum
 * <p>
 * @lucene.experimental 
 * <p>
 * @param compiled CompiledAutomaton
 */
public AutomatonTermsEnum(TermsEnum tenum, CompiledAutomaton compiled) {
  super(tenum);
  this.finite = compiled.finite;
  this.runAutomaton = compiled.runAutomaton;
  assert this.runAutomaton != null;
  this.commonSuffixRef = compiled.commonSuffixRef;
  this.automaton = compiled.automaton;

  // used for path tracking, where each bit is a numbered state.
  visited = new long[runAutomaton.getSize()];

  termComp = getComparator();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:AutomatonTermsEnum.java

示例11: wildcardEnumeration

import org.apache.lucene.util.automaton.CompiledAutomaton; //导入依赖的package包/类
private TermsEnum wildcardEnumeration(final IndexReader reader)
        throws IOException {
    Terms terms = MultiFields.getTerms(reader, term.field());
    if(terms == null){
        return null;
    }
    return new AutomatonTermsEnum(
            terms.iterator(),
            new CompiledAutomaton(
                    WildcardQuery.toAutomaton(term),
                    false, false));
}
 
开发者ID:meltwater,项目名称:meltwater-elasticsearch-queries,代码行数:13,代码来源:WildcardTermsProducer.java

示例12: IntersectTermsEnum

import org.apache.lucene.util.automaton.CompiledAutomaton; //导入依赖的package包/类
IntersectTermsEnum(CompiledAutomaton compiled, BytesRef startTerm) throws IOException {
  super();
  //if (TEST) System.out.println("Enum init, startTerm=" + startTerm);
  this.fst = dict;
  this.fstReader = fst.getBytesReader();
  this.fstOutputs = dict.outputs;
  this.fsa = compiled.runAutomaton;
  this.level = -1;
  this.stack = new Frame[16];
  for (int i = 0 ; i < stack.length; i++) {
    this.stack[i] = new Frame();
  }

  Frame frame;
  frame = loadVirtualFrame(newFrame());
  this.level++;
  frame = loadFirstFrame(newFrame());
  pushFrame(frame);

  this.meta = null;
  this.metaUpto = 1;
  this.decoded = false;
  this.pending = false;

  if (startTerm == null) {
    pending = isAccept(topFrame());
  } else {
    doSeekCeil(startTerm);
    pending = (term == null || !startTerm.equals(term.get())) && isValid(topFrame()) && isAccept(topFrame());
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:32,代码来源:FSTTermsReader.java

示例13: IntersectTermsEnum

import org.apache.lucene.util.automaton.CompiledAutomaton; //导入依赖的package包/类
IntersectTermsEnum(CompiledAutomaton compiled, BytesRef startTerm) throws IOException {
  //if (TEST) System.out.println("Enum init, startTerm=" + startTerm);
  this.fst = index;
  this.fstReader = fst.getBytesReader();
  this.fstOutputs = index.outputs;
  this.fsa = compiled.runAutomaton;
  this.level = -1;
  this.stack = new Frame[16];
  for (int i = 0 ; i < stack.length; i++) {
    this.stack[i] = new Frame();
  }

  Frame frame;
  frame = loadVirtualFrame(newFrame());
  this.level++;
  frame = loadFirstFrame(newFrame());
  pushFrame(frame);

  this.decoded = false;
  this.pending = false;

  if (startTerm == null) {
    pending = isAccept(topFrame());
  } else {
    doSeekCeil(startTerm);
    pending = (term == null || !startTerm.equals(term.get())) && isValid(topFrame()) && isAccept(topFrame());
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:29,代码来源:FSTOrdTermsReader.java

示例14: intersect

import org.apache.lucene.util.automaton.CompiledAutomaton; //导入依赖的package包/类
@Override
public TermsEnum intersect(CompiledAutomaton compiled, BytesRef startTerm) throws IOException {
  if (compiled.type != CompiledAutomaton.AUTOMATON_TYPE.NORMAL) {
    throw new IllegalArgumentException("please use CompiledAutomaton.getTermsEnum instead");
  }
  return new OrdsIntersectTermsEnum(this, compiled, startTerm);
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:OrdsFieldReader.java

示例15: intersect

import org.apache.lucene.util.automaton.CompiledAutomaton; //导入依赖的package包/类
@Override
public TermsEnum intersect(CompiledAutomaton automaton, BytesRef bytes) throws IOException {
  TermsEnum termsEnum = in.intersect(automaton, bytes);
  assert termsEnum != null;
  assert bytes == null || bytes.isValid();
  return new AssertingTermsEnum(termsEnum);
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:AssertingAtomicReader.java


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