Exemplo n.º 1
0
 public void testFullMatchList() throws Exception {
   assertMatchEquals(
       completion.lookup(stringToCharSequence("one"), Integer.MAX_VALUE),
       "oneness/1.0",
       "onerous/1.0",
       "onesimus/1.0",
       "one/0.0");
 }
Exemplo n.º 2
0
 public void testExactMatchReordering() throws Exception {
   // Check reordering of exact matches.
   assertMatchEquals(
       completion.lookup(stringToCharSequence("four"), 4),
       "four/0.0",
       "fourblah/1.0",
       "fourteen/1.0",
       "fourier/0.0");
 }
Exemplo n.º 3
0
  public void testThreeByte() throws Exception {
    String key =
        new String(new byte[] {(byte) 0xF0, (byte) 0xA4, (byte) 0xAD, (byte) 0xA2}, "UTF-8");
    FSTCompletionBuilder builder = new FSTCompletionBuilder();
    builder.add(new BytesRef(key), 0);

    FSTCompletion lookup = builder.build();
    List<Completion> result = lookup.lookup(stringToCharSequence(key), 1);
    assertEquals(1, result.size());
  }
Exemplo n.º 4
0
  public void testRequestedCount() throws Exception {
    // 'one' is promoted after collecting two higher ranking results.
    assertMatchEquals(completion.lookup(stringToCharSequence("one"), 2), "one/0.0", "oneness/1.0");

    // 'four' is collected in a bucket and then again as an exact match.
    assertMatchEquals(
        completion.lookup(stringToCharSequence("four"), 2), "four/0.0", "fourblah/1.0");

    // Check reordering of exact matches.
    assertMatchEquals(
        completion.lookup(stringToCharSequence("four"), 4),
        "four/0.0",
        "fourblah/1.0",
        "fourteen/1.0",
        "fourier/0.0");

    // 'one' is at the top after collecting all alphabetical results.
    assertMatchEquals(
        completionAlphabetical.lookup(stringToCharSequence("one"), 2), "one/0.0", "oneness/1.0");

    // 'one' is not promoted after collecting two higher ranking results.
    FSTCompletion noPromotion = new FSTCompletion(completion.getFST(), true, false);
    assertMatchEquals(
        noPromotion.lookup(stringToCharSequence("one"), 2), "oneness/1.0", "onerous/1.0");

    // 'one' is at the top after collecting all alphabetical results.
    assertMatchEquals(
        completionAlphabetical.lookup(stringToCharSequence("one"), 2), "one/0.0", "oneness/1.0");
  }
Exemplo n.º 5
0
 public void testExactMatchLowPriority() throws Exception {
   assertMatchEquals(completion.lookup(stringToCharSequence("one"), 2), "one/0.0", "oneness/1.0");
 }
Exemplo n.º 6
0
 public void testExactMatchHighPriority() throws Exception {
   assertMatchEquals(completion.lookup(stringToCharSequence("two"), 1), "two/1.0");
 }
Exemplo n.º 7
0
 public void testEmptyInput() throws Exception {
   completion = new FSTCompletionBuilder().build();
   assertMatchEquals(completion.lookup(stringToCharSequence(""), 10));
 }
Exemplo n.º 8
0
 public void testAlphabeticWithWeights() throws Exception {
   assertEquals(0, completionAlphabetical.lookup(stringToCharSequence("xyz"), 1).size());
 }
Exemplo n.º 9
0
 public void testMiss() throws Exception {
   assertMatchEquals(completion.lookup(stringToCharSequence("xyz"), 1));
 }