Examples of LookupResult


Examples of org.apache.lucene.search.suggest.Lookup.LookupResult

      final List<LookupResult> matches = new ArrayList<LookupResult>();

      // TODO: could be faster... but its slowCompletor for a reason
      for (Map.Entry<String,Long> e : slowCompletor.entrySet()) {
        if (e.getKey().startsWith(prefix)) {
          matches.add(new LookupResult(e.getKey(), e.getValue().longValue()));
        }
      }

      assertTrue(matches.size() > 0);
      Collections.sort(matches, new Comparator<LookupResult>() {
View Full Code Here

Examples of org.apache.lucene.search.suggest.Lookup.LookupResult

          for (int i = ref.offset; i < ref.length; i++) {
            State q = p.step(ref.bytes[i] & 0xff);
            if (q == null) {
              break;
            } else if (q.isAccept()) {
              matches.add(new LookupResult(e.surfaceForm, e.weight));
              added = true;
              break;
            }
            p = q;
          }
          if (!added && p.isAccept()) {
            matches.add(new LookupResult(e.surfaceForm, e.weight));
          }
        }
      }

      assertTrue(numStopChars > 0 || matches.size() > 0);
View Full Code Here

Examples of org.apache.lucene.search.suggest.Lookup.LookupResult

      Collections.sort(actual, new CompareByCostThenAlpha());

      final int limit = Math.min(expected.size(), actual.size());
      for(int ans=0;ans<limit;ans++) {
        final LookupResult c0 = expected.get(ans);
        final LookupResult c1 = actual.get(ans);
        assertEquals("expected " + c0.key +
                     " but got " + c1.key,
                     0,
                     CHARSEQUENCE_COMPARATOR.compare(c0.key, c1.key));
        assertEquals(c0.value, c1.value);
View Full Code Here

Examples of org.apache.lucene.search.suggest.Lookup.LookupResult

                break;
              }
            }
          }
          if (d <= maxEdits) {
            results.add(new LookupResult(tf.term.utf8ToString(), tf.v));
          }
        }
      }

      Collections.sort(results, new CompareByCostThenAlpha());
View Full Code Here

Examples of org.apache.lucene.search.suggest.Lookup.LookupResult

          payloadsDV.get(sd.doc, payload);
        } else {
          payload = null;
        }

        LookupResult result;

        if (doHighlight) {
          Object highlightKey = highlight(text, matchedTokens, prefixToken);
          result = new LookupResult(highlightKey.toString(), highlightKey, score, payload);
        } else {
          result = new LookupResult(text, score, payload);
        }
        results.add(result);
      }
      //System.out.println((System.currentTimeMillis() - t0) + " msec for infix suggest");
      //System.out.println(results);
View Full Code Here

Examples of org.apache.lucene.search.suggest.Lookup.LookupResult

    Random random = random();
    long previous = Long.MIN_VALUE;
    for (Input k : keys) {
      List<LookupResult> list = lookup.lookup(_TestUtil.bytesToCharSequence(k.term, random), false, 1);
      assertEquals(1, list.size());
      LookupResult lookupResult = list.get(0);
      assertNotNull(k.term.utf8ToString(), lookupResult.key);

      if (supportsExactWeights) {
        assertEquals(k.term.utf8ToString(), k.v, lookupResult.value);
      } else {
View Full Code Here

Examples of org.apache.lucene.search.suggest.Lookup.LookupResult

              continue;
            }
            String ngram = (context + " " + term).trim();
            Integer count = model.get(ngram);
            if (count != null) {
              LookupResult lr = new LookupResult(ngram, (long) (Long.MAX_VALUE * (backoff * (double) count / contextCount)));
              tmp.add(lr);
              if (VERBOSE) {
                System.out.println("      add tmp key='" + lr.key + "' score=" + lr.value);
              }
            }
View Full Code Here

Examples of org.apache.lucene.search.suggest.Lookup.LookupResult

      final List<LookupResult> matches = new ArrayList<LookupResult>();

      // TODO: could be faster... but its slowCompletor for a reason
      for (Map.Entry<String,Long> e : slowCompletor.entrySet()) {
        if (e.getKey().startsWith(prefix)) {
          matches.add(new LookupResult(e.getKey(), e.getValue().longValue()));
        }
      }

      assertTrue(matches.size() > 0);
      Collections.sort(matches, new Comparator<LookupResult>() {
View Full Code Here

Examples of org.apache.lucene.search.suggest.Lookup.LookupResult

        payloadsDV.get(sd.doc, payload);
      } else {
        payload = null;
      }

      LookupResult result;

      if (doHighlight) {
        Object highlightKey = highlight(text, matchedTokens, prefixToken);
        result = new LookupResult(highlightKey.toString(), highlightKey, score, payload);
      } else {
        result = new LookupResult(text, score, payload);
      }

      results.add(result);
    }
View Full Code Here

Examples of org.apache.lucene.search.suggest.Lookup.LookupResult

          for (int i = ref.offset; i < ref.length; i++) {
            State q = p.step(ref.bytes[i] & 0xff);
            if (q == null) {
              break;
            } else if (q.isAccept()) {
              matches.add(new LookupResult(e.surfaceForm, e.weight));
              added = true;
              break;
            }
            p = q;
          }
          if (!added && p.isAccept()) {
            matches.add(new LookupResult(e.surfaceForm, e.weight));
          }
        }
      }

      assertTrue(numStopChars > 0 || matches.size() > 0);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.