org.apache.lucene.util.fst.Builder.<init>()方法的使用及代码示例

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

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

Builder.<init>介绍

[英]Instantiates an FST/FSA builder with all the possible tuning and construction tweaks. Read parameter documentation carefully.
[中]实例化一个FST/FSA生成器,其中包含所有可能的调优和构造调整。仔细阅读参数文档。

代码示例

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

final Builder<BytesRef> indexBuilder = new Builder<>(FST.INPUT_TYPE.BYTE1,
                           0, 0, true, false, Integer.MAX_VALUE,
                           outputs, true, 15);

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

private FST<CharsRef> parseConversions(LineNumberReader reader, int num) throws IOException, ParseException {
 Map<String,String> mappings = new TreeMap<>();
 
 for (int i = 0; i < num; i++) {
  String line = reader.readLine();
  String parts[] = line.split("\\s+");
  if (parts.length != 3) {
   throw new ParseException("invalid syntax: " + line, reader.getLineNumber());
  }
  if (mappings.put(parts[1], parts[2]) != null) {
   throw new IllegalStateException("duplicate mapping specified for: " + parts[1]);
  }
 }
 
 Outputs<CharsRef> outputs = CharSequenceOutputs.getSingleton();
 Builder<CharsRef> builder = new Builder<>(FST.INPUT_TYPE.BYTE2, outputs);
 IntsRefBuilder scratchInts = new IntsRefBuilder();
 for (Map.Entry<String,String> entry : mappings.entrySet()) {
  Util.toUTF16(entry.getKey(), scratchInts);
  builder.add(scratchInts.get(), new CharsRef(entry.getValue()));
 }
 
 return builder.finish();
}

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

public XBuilder(int maxSurfaceFormsPerAnalyzedForm, boolean hasPayloads, int payloadSep) {
  this.payloadSep = payloadSep;
  this.outputs = new PairOutputs<>(PositiveIntOutputs.getSingleton(), ByteSequenceOutputs.getSingleton());
  this.builder = new Builder<>(FST.INPUT_TYPE.BYTE1, outputs);
  this.maxSurfaceFormsPerAnalyzedForm = maxSurfaceFormsPerAnalyzedForm;
  this.hasPayloads = hasPayloads;
  surfaceFormsAndPayload = new SurfaceFormAndPayload[maxSurfaceFormsPerAnalyzedForm];
}
public void startTerm(BytesRef analyzed) {

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

private FST<IntsRef> affixFST(TreeMap<String,List<Integer>> affixes) throws IOException {
 IntSequenceOutputs outputs = IntSequenceOutputs.getSingleton();
 Builder<IntsRef> builder = new Builder<>(FST.INPUT_TYPE.BYTE4, outputs);
 IntsRefBuilder scratch = new IntsRefBuilder();
 for (Map.Entry<String,List<Integer>> entry : affixes.entrySet()) {
  Util.toUTF32(entry.getKey(), scratch);
  List<Integer> entries = entry.getValue();
  IntsRef output = new IntsRef(entries.size());
  for (Integer c : entries) {
   output.ints[output.length++] = c;
  }
  builder.add(scratch.get(), output);
 }
 return builder.finish();
}

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

/** Builds the NormalizeCharMap; call this once you
  *  are done calling {@link #add}. */
 public NormalizeCharMap build() {
  final FST<CharsRef> map;
  try {
   final Outputs<CharsRef> outputs = CharSequenceOutputs.getSingleton();
   final org.apache.lucene.util.fst.Builder<CharsRef> builder = new org.apache.lucene.util.fst.Builder<>(FST.INPUT_TYPE.BYTE2, outputs);
   final IntsRefBuilder scratch = new IntsRefBuilder();
   for(Map.Entry<String,String> ent : pendingPairs.entrySet()) {
    builder.add(Util.toUTF16(ent.getKey(), scratch),
          new CharsRef(ent.getValue()));
   }
   map = builder.finish();
   pendingPairs.clear();
  } catch (IOException ioe) {
   // Bogus FST IOExceptions!!  (will never happen)
   throw new RuntimeException(ioe);
  }
  return new NormalizeCharMap(map);
 }
}

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

Builder<IntsRef> b = new Builder<>(FST.INPUT_TYPE.BYTE4, o);
readDictionaryFiles(tempDir, tempFileNamePrefix, dictionaries, decoder, b);
words = b.finish();

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

new org.apache.lucene.util.fst.Builder<>(FST.INPUT_TYPE.BYTE4, outputs);

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

public TermsWriter(IndexOutput out, FieldInfo field) {
 this.out = out;
 this.field = field;
 builder = new Builder<>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, Integer.MAX_VALUE, outputs, true, 15);
}

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

/**
 * Returns an {@link StemmerOverrideMap} to be used with the {@link StemmerOverrideFilter}
 * @return an {@link StemmerOverrideMap} to be used with the {@link StemmerOverrideFilter}
 * @throws IOException if an {@link IOException} occurs;
 */
public StemmerOverrideMap build() throws IOException {
 ByteSequenceOutputs outputs = ByteSequenceOutputs.getSingleton();
 org.apache.lucene.util.fst.Builder<BytesRef> builder = new org.apache.lucene.util.fst.Builder<>(
   FST.INPUT_TYPE.BYTE4, outputs);
 final int[] sort = hash.sort();
 IntsRefBuilder intsSpare = new IntsRefBuilder();
 final int size = hash.size();
 BytesRef spare = new BytesRef();
 for (int i = 0; i < size; i++) {
  int id = sort[i];
  BytesRef bytesRef = hash.get(id, spare);
  intsSpare.copyUTF8Bytes(bytesRef);
  builder.add(intsSpare.get(), new BytesRef(outputValues.get(id)));
 }
 return new StemmerOverrideMap(builder.finish(), ignoreCase);
}

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

Builder<Pair<Long,BytesRef>> builder = new Builder<>(FST.INPUT_TYPE.BYTE1, outputs);

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

TermsWriter(FieldInfo fieldInfo) {
 this.numTerms = 0;
 this.fieldInfo = fieldInfo;
 this.longsSize = postingsWriter.setField(fieldInfo);
 this.outputs = new FSTTermOutputs(fieldInfo, longsSize);
 this.builder = new Builder<>(FST.INPUT_TYPE.BYTE1, outputs);
}

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

TermsWriter(FieldInfo fieldInfo) {
 this.numTerms = 0;
 this.fieldInfo = fieldInfo;
 this.longsSize = postingsWriter.setField(fieldInfo);
 this.outputs = PositiveIntOutputs.getSingleton();
 this.builder = new Builder<>(FST.INPUT_TYPE.BYTE1, outputs);
 this.lastBlockStatsFP = 0;
 this.lastBlockMetaLongsFP = 0;
 this.lastBlockMetaBytesFP = 0;
 this.lastBlockLongs = new long[longsSize];
 this.lastLongs = new long[longsSize];
 this.lastMetaBytesFP = 0;
}

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

/**
 * Create a builder for {@link NRTSuggester}
 */
public NRTSuggesterBuilder() {
 this.payloadSep = PAYLOAD_SEP;
 this.endByte = END_BYTE;
 this.outputs = new PairOutputs<>(PositiveIntOutputs.getSingleton(), ByteSequenceOutputs.getSingleton());
 this.entries = new PriorityQueue<>();
 this.builder = new Builder<>(FST.INPUT_TYPE.BYTE1, outputs);
}

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

public XBuilder(int maxSurfaceFormsPerAnalyzedForm, boolean hasPayloads, int payloadSep) {
  this.payloadSep = payloadSep;
  this.outputs = new PairOutputs<>(PositiveIntOutputs.getSingleton(), ByteSequenceOutputs.getSingleton());
  this.builder = new Builder<>(FST.INPUT_TYPE.BYTE1, outputs);
  this.maxSurfaceFormsPerAnalyzedForm = maxSurfaceFormsPerAnalyzedForm;
  this.hasPayloads = hasPayloads;
  surfaceFormsAndPayload = new SurfaceFormAndPayload[maxSurfaceFormsPerAnalyzedForm];
}
public void startTerm(BytesRef analyzed) {

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

public XBuilder(int maxSurfaceFormsPerAnalyzedForm, boolean hasPayloads, int payloadSep) {
  this.payloadSep = payloadSep;
  this.outputs = new PairOutputs<>(PositiveIntOutputs.getSingleton(), ByteSequenceOutputs.getSingleton());
  this.builder = new Builder<>(FST.INPUT_TYPE.BYTE1, outputs);
  this.maxSurfaceFormsPerAnalyzedForm = maxSurfaceFormsPerAnalyzedForm;
  this.hasPayloads = hasPayloads;
  surfaceFormsAndPayload = new SurfaceFormAndPayload[maxSurfaceFormsPerAnalyzedForm];
}
public void startTerm(BytesRef analyzed) {

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

public XBuilder(int maxSurfaceFormsPerAnalyzedForm, boolean hasPayloads, int payloadSep) {
  this.payloadSep = payloadSep;
  this.outputs = new PairOutputs<>(PositiveIntOutputs.getSingleton(), ByteSequenceOutputs.getSingleton());
  this.builder = new Builder<>(FST.INPUT_TYPE.BYTE1, outputs);
  this.maxSurfaceFormsPerAnalyzedForm = maxSurfaceFormsPerAnalyzedForm;
  this.hasPayloads = hasPayloads;
  surfaceFormsAndPayload = new SurfaceFormAndPayload[maxSurfaceFormsPerAnalyzedForm];
}
public void startTerm(BytesRef analyzed) {

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

private void updateFST(SortedMap<String, Double> weights) throws IOException {
 PositiveIntOutputs outputs = PositiveIntOutputs.getSingleton();
 Builder<Long> fstBuilder = new Builder<>(FST.INPUT_TYPE.BYTE1, outputs);
 BytesRefBuilder scratchBytes = new BytesRefBuilder();
 IntsRefBuilder scratchInts = new IntsRefBuilder();
 for (Map.Entry<String, Double> entry : weights.entrySet()) {
  scratchBytes.copyChars(entry.getKey());
  fstBuilder.add(Util.toIntsRef(scratchBytes.get(), scratchInts), entry
      .getValue().longValue());
 }
 fst = fstBuilder.finish();
}

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

public XBuilder(int maxSurfaceFormsPerAnalyzedForm, boolean hasPayloads, int payloadSep) {
  this.payloadSep = payloadSep;
  this.outputs = new PairOutputs<>(PositiveIntOutputs.getSingleton(), ByteSequenceOutputs.getSingleton());
  this.builder = new Builder<>(FST.INPUT_TYPE.BYTE1, outputs);
  this.maxSurfaceFormsPerAnalyzedForm = maxSurfaceFormsPerAnalyzedForm;
  this.hasPayloads = hasPayloads;
  surfaceFormsAndPayload = new SurfaceFormAndPayload[maxSurfaceFormsPerAnalyzedForm];
}
public void startTerm(BytesRef analyzed) {

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

private FST<IntsRef> affixFST(TreeMap<String,List<Integer>> affixes) throws IOException {
 IntSequenceOutputs outputs = IntSequenceOutputs.getSingleton();
 Builder<IntsRef> builder = new Builder<>(FST.INPUT_TYPE.BYTE4, outputs);
 IntsRefBuilder scratch = new IntsRefBuilder();
 for (Map.Entry<String,List<Integer>> entry : affixes.entrySet()) {
  Util.toUTF32(entry.getKey(), scratch);
  List<Integer> entries = entry.getValue();
  IntsRef output = new IntsRef(entries.size());
  for (Integer c : entries) {
   output.ints[output.length++] = c;
  }
  builder.add(scratch.get(), output);
 }
 return builder.finish();
}

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

public FSTFieldWriter(FieldInfo fieldInfo, long termsFilePointer) throws IOException {
 this.fieldInfo = fieldInfo;
 fstOutputs = PositiveIntOutputs.getSingleton();
 fstBuilder = new Builder<>(FST.INPUT_TYPE.BYTE1, fstOutputs);
 indexStart = out.getFilePointer();
 ////System.out.println("VGW: field=" + fieldInfo.name);
 // Always put empty string in
 fstBuilder.add(new IntsRef(), termsFilePointer);
 startTermsFilePointer = termsFilePointer;
}

相关文章