Examples of LookupResult


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

              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

        }
      } else {
        contexts = null;
      }

      LookupResult result;

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

      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

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

      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.shindig.gadgets.features.FeatureRegistry.LookupResult

  public void setUp() throws Exception {
    GadgetContext ctx = new GadgetContext();
    Provider<GadgetContext> contextProviderMock = Providers.of(ctx);
    FeatureResource resource = mockResource(DEFER_JS_DEB);
    FeatureRegistry.FeatureBundle bundle = mockExportJsBundle(resource);
    LookupResult lookupMock = mockLookupResult(bundle);
    final FeatureRegistry featureRegistryMock = mockRegistry(lookupMock);
    featureRegistry = featureRegistryMock;
    FeatureRegistryProvider registryProvider = new FeatureRegistryProvider() {
      public FeatureRegistry get(String repository) {
        return featureRegistryMock;
View Full Code Here

Examples of org.apache.shindig.gadgets.features.FeatureRegistry.LookupResult

    replay(result);
    return result;
  }

  private LookupResult mockLookupResult(FeatureRegistry.FeatureBundle featureBundle) {
    LookupResult result = createMock(LookupResult.class);
    expect(result.getBundles()).andReturn(ImmutableList.of(featureBundle)).anyTimes();
    replay(result);
    return result;
  }
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.