Search in sources :

Example 1 with DoubleArray

use of org.trie4j.doublearray.DoubleArray in project trie4j by takawitter.

the class Issue_031 method test_DoubleArray.

@Test
public void test_DoubleArray() throws Throwable {
    Trie trie = new PatriciaTrie();
    insertLines(trie, FILE_NAME);
    Trie da = new DoubleArray(trie);
    Assert.assertFalse(trie.contains("you"));
    Assert.assertFalse(da.contains("you"));
}
Also used : PatriciaTrie(org.trie4j.patricia.PatriciaTrie) MapPatriciaTrie(org.trie4j.patricia.MapPatriciaTrie) MapTrie(org.trie4j.MapTrie) PatriciaTrie(org.trie4j.patricia.PatriciaTrie) Trie(org.trie4j.Trie) MapPatriciaTrie(org.trie4j.patricia.MapPatriciaTrie) MapTailDoubleArray(org.trie4j.doublearray.MapTailDoubleArray) TailDoubleArray(org.trie4j.doublearray.TailDoubleArray) MapDoubleArray(org.trie4j.doublearray.MapDoubleArray) DoubleArray(org.trie4j.doublearray.DoubleArray) Test(org.junit.Test)

Example 2 with DoubleArray

use of org.trie4j.doublearray.DoubleArray in project trie4j by takawitter.

the class MapTailLOUDSTrieWithConcatTailArrayTest method investigate2.

public void investigate2() throws Exception {
    String[] words = { "!SHOUT!", "!_-attention-", "!wagero!", "![ai-ou]", "\"74ers\"_LIVE_IN_OSAKA-JO_HALL_2003" };
    Integer[] values = { 1, 3, 2, 6, 100 };
    MapTailLOUDSTrie<Integer> trie = trieWithWordsAndValues(words, values);
    DoubleArray da = (DoubleArray) trie.getTrie();
    int n = words.length;
    BytesRank1OnlySuccinctBitVector bv = (BytesRank1OnlySuccinctBitVector) da.getTerm();
    System.out.println(bv.rank1(67));
    for (int i = 0; i < n; i++) {
        String s = words[i];
        System.out.println(String.format("%s, nid: %d, tid: %d, ev: %d, av: %d", s, da.getNodeId(s), da.getTermId(s), values[i], trie.get(s)));
        Assert.assertEquals(values[i], trie.get(words[i]));
    }
}
Also used : BytesRank1OnlySuccinctBitVector(org.trie4j.bv.BytesRank1OnlySuccinctBitVector) DoubleArray(org.trie4j.doublearray.DoubleArray)

Example 3 with DoubleArray

use of org.trie4j.doublearray.DoubleArray in project trie4j by takawitter.

the class MapTailLOUDSTrieWithSBVConcatTailArrayTest method investigate2.

public void investigate2() throws Exception {
    String[] words = { "!SHOUT!", "!_-attention-", "!wagero!", "![ai-ou]", "\"74ers\"_LIVE_IN_OSAKA-JO_HALL_2003" };
    Integer[] values = { 1, 3, 2, 6, 100 };
    MapTailLOUDSTrie<Integer> trie = (MapTailLOUDSTrie<Integer>) trieWithWordsAndValues(words, values);
    DoubleArray da = (DoubleArray) trie.getTrie();
    int n = words.length;
    BytesRank1OnlySuccinctBitVector bv = (BytesRank1OnlySuccinctBitVector) da.getTerm();
    System.out.println(bv.rank1(67));
    for (int i = 0; i < n; i++) {
        String s = words[i];
        System.out.println(String.format("%s, nid: %d, tid: %d, ev: %d, av: %d", s, da.getNodeId(s), da.getTermId(s), values[i], trie.get(s)));
        Assert.assertEquals(values[i], trie.get(words[i]));
    }
}
Also used : BytesRank1OnlySuccinctBitVector(org.trie4j.bv.BytesRank1OnlySuccinctBitVector) DoubleArray(org.trie4j.doublearray.DoubleArray)

Example 4 with DoubleArray

use of org.trie4j.doublearray.DoubleArray in project trie4j by takawitter.

the class MapTailLOUDSTrieWithSuffixTrieTailArrayTest method investigate2.

public void investigate2() throws Exception {
    String[] words = { "!SHOUT!", "!_-attention-", "!wagero!", "![ai-ou]", "\"74ers\"_LIVE_IN_OSAKA-JO_HALL_2003" };
    Integer[] values = { 1, 3, 2, 6, 100 };
    MapTailLOUDSTrie<Integer> trie = (MapTailLOUDSTrie<Integer>) trieWithWordsAndValues(words, values);
    DoubleArray da = (DoubleArray) trie.getTrie();
    int n = words.length;
    BytesRank1OnlySuccinctBitVector bv = (BytesRank1OnlySuccinctBitVector) da.getTerm();
    System.out.println(bv.rank1(67));
    for (int i = 0; i < n; i++) {
        String s = words[i];
        System.out.println(String.format("%s, nid: %d, tid: %d, ev: %d, av: %d", s, da.getNodeId(s), da.getTermId(s), values[i], trie.get(s)));
        Assert.assertEquals(values[i], trie.get(words[i]));
    }
}
Also used : BytesRank1OnlySuccinctBitVector(org.trie4j.bv.BytesRank1OnlySuccinctBitVector) DoubleArray(org.trie4j.doublearray.DoubleArray)

Aggregations

DoubleArray (org.trie4j.doublearray.DoubleArray)4 BytesRank1OnlySuccinctBitVector (org.trie4j.bv.BytesRank1OnlySuccinctBitVector)3 Test (org.junit.Test)1 MapTrie (org.trie4j.MapTrie)1 Trie (org.trie4j.Trie)1 MapDoubleArray (org.trie4j.doublearray.MapDoubleArray)1 MapTailDoubleArray (org.trie4j.doublearray.MapTailDoubleArray)1 TailDoubleArray (org.trie4j.doublearray.TailDoubleArray)1 MapPatriciaTrie (org.trie4j.patricia.MapPatriciaTrie)1 PatriciaTrie (org.trie4j.patricia.PatriciaTrie)1