org.apache.lucene.util.fst.Util.get()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(196)

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

Util.get介绍

[英]Looks up the output for this input, or null if the input is not accepted
[中]查找此输入的输出,如果输入不被接受,则为null

代码示例

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

  1. throw new RuntimeException("seek state is broken");
  2. BytesRef output = Util.get(fr.index, prefix);
  3. if (output == null) {
  4. out.println(" broken seek state: prefix is not final in index");

代码示例来源:origin: lintool/warcbase

  1. public int getID(String url) {
  2. Long id = null;
  3. try {
  4. id = Util.get(fst, new BytesRef(url));
  5. } catch (IOException e) {
  6. // Log error, but assume that URL doesn't exist.
  7. LOG.error("Error fetching " + url);
  8. e.printStackTrace();
  9. return -1;
  10. }
  11. return id == null ? -1 : id.intValue();
  12. }

代码示例来源:origin: lintool/warcbase

  1. public int[] getIdRange(String first, String last){
  2. if (first == null || last == null) {
  3. return null;
  4. }
  5. Long startId = null, endId = null;
  6. try {
  7. startId = Util.get(fst, new BytesRef(first));
  8. endId = Util.get(fst, new BytesRef(last));
  9. if (startId == null || endId == null) {
  10. return null;
  11. }
  12. } catch (IOException e) {
  13. LOG.error("Error: " + e);
  14. e.printStackTrace();
  15. return null;
  16. }
  17. return new int[] { (int) startId.longValue(), (int) endId.longValue() };
  18. }

代码示例来源:origin: NationalSecurityAgency/datawave

  1. final IntsRef ints = irBuilder.get();
  2. synchronized (this.fst) {
  3. if (Util.get(this.fst, ints) != null) {
  4. matches = true;

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

  1. @Override
  2. public ClassificationResult<Boolean> assignClass(String text)
  3. throws IOException {
  4. Long output = 0L;
  5. try (TokenStream tokenStream = analyzer.tokenStream(textFieldName, text)) {
  6. CharTermAttribute charTermAttribute = tokenStream
  7. .addAttribute(CharTermAttribute.class);
  8. tokenStream.reset();
  9. while (tokenStream.incrementToken()) {
  10. String s = charTermAttribute.toString();
  11. Long d = Util.get(fst, new BytesRef(s));
  12. if (d != null) {
  13. output += d;
  14. }
  15. }
  16. tokenStream.end();
  17. }
  18. double score = 1 - Math.exp(-1 * Math.abs(bias - output.doubleValue()) / bias);
  19. return new ClassificationResult<>(output >= bias, score);
  20. }

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

  1. throw new RuntimeException("seek state is broken");
  2. BytesRef output = Util.get(fr.index, prefix);
  3. if (output == null) {
  4. out.println(" broken seek state: prefix is not final in index");

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

  1. throw new RuntimeException("seek state is broken");
  2. BytesRef output = Util.get(fr.index, prefix);
  3. if (output == null) {
  4. out.println(" broken seek state: prefix is not final in index");

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

  1. throw new RuntimeException("seek state is broken");
  2. BytesRef output = Util.get(fr.index, prefix);
  3. if (output == null) {
  4. out.println(" broken seek state: prefix is not final in index");

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

  1. throw new RuntimeException("seek state is broken");
  2. BytesRef output = Util.get(fr.index, prefix);
  3. if (output == null) {
  4. out.println(" broken seek state: prefix is not final in index");

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

  1. throw new RuntimeException("seek state is broken");
  2. Output output = Util.get(fr.index, prefix);
  3. if (output == null) {
  4. out.println(" broken seek state: prefix is not final in index");

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

  1. throw new RuntimeException("seek state is broken");
  2. Pair<BytesRef,Long> output = Util.get(fr.index, prefix);
  3. if (output == null) {
  4. out.println(" broken seek state: prefix is not final in index");

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

  1. throw new RuntimeException("seek state is broken");
  2. Pair<BytesRef,Long> output = Util.get(fr.index, prefix);
  3. if (output == null) {
  4. out.println(" broken seek state: prefix is not final in index");

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

  1. private void updateWeights(IndexReader indexReader,
  2. int docId, Boolean assignedClass, SortedMap<String, Double> weights,
  3. double modifier, boolean updateFST) throws IOException {
  4. TermsEnum cte = textTerms.iterator();
  5. // get the doc term vectors
  6. Terms terms = indexReader.getTermVector(docId, textFieldName);
  7. if (terms == null) {
  8. throw new IOException("term vectors must be stored for field "
  9. + textFieldName);
  10. }
  11. TermsEnum termsEnum = terms.iterator();
  12. BytesRef term;
  13. while ((term = termsEnum.next()) != null) {
  14. cte.seekExact(term);
  15. if (assignedClass != null) {
  16. long termFreqLocal = termsEnum.totalTermFreq();
  17. // update weights
  18. Long previousValue = Util.get(fst, term);
  19. String termString = term.utf8ToString();
  20. weights.put(termString, previousValue == null ? 0 : Math.max(0, previousValue + modifier * termFreqLocal));
  21. }
  22. }
  23. if (updateFST) {
  24. updateFST(weights);
  25. }
  26. }

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

  1. if (token.byteAt(i) == separator) {
  2. BytesRef context = new BytesRef(token.bytes(), 0, i);
  3. Long output = Util.get(fst, Util.toIntsRef(context, new IntsRefBuilder()));
  4. assert output != null;
  5. contextCount = decodeWeight(output);

相关文章