Search in sources :

Example 6 with LOUDSPPBvTree

use of org.trie4j.louds.bvtree.LOUDSPPBvTree in project trie4j by takawitter.

the class LongsTailLOUDSPPTrieWithSuffixTrieDenseTailArrayWikipediaSerializeTest method secondTrie.

@Override
protected Trie secondTrie(Trie firstTrie) {
    Trie t = new TailLOUDSTrie(firstTrie, new LOUDSPPBvTree(new LongsRank0OnlySuccinctBitVector(), new LongsSuccinctBitVector()), new SuffixTrieDenseTailArrayBuilder());
    t.trimToSize();
    return t;
}
Also used : LOUDSPPBvTree(org.trie4j.louds.bvtree.LOUDSPPBvTree) SuffixTrieDenseTailArrayBuilder(org.trie4j.tail.SuffixTrieDenseTailArrayBuilder) Trie(org.trie4j.Trie) LongsRank0OnlySuccinctBitVector(org.trie4j.bv.LongsRank0OnlySuccinctBitVector) LongsSuccinctBitVector(org.trie4j.bv.LongsSuccinctBitVector)

Example 7 with LOUDSPPBvTree

use of org.trie4j.louds.bvtree.LOUDSPPBvTree in project trie4j by takawitter.

the class TailLOUDSPPTrieWithConcatTailArrayTest method test_save_load.

@Test
public void test_save_load() throws Exception {
    String[] words = { "こんにちは", "さようなら", "おはよう", "おおきなかぶ", "おおやまざき" };
    Trie trie = new PatriciaTrie(words);
    TailLOUDSTrie lt = new TailLOUDSTrie(trie, new LOUDSPPBvTree(trie.nodeSize()));
    try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos)) {
        lt.writeExternal(oos);
        oos.flush();
        lt = new TailLOUDSTrie(new PatriciaTrie(), new LOUDSPPBvTree());
        lt.readExternal(new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())));
        for (String w : words) {
            Assert.assertTrue(lt.contains(w));
        }
        Assert.assertFalse(lt.contains("おやすみなさい"));
    }
    StringBuilder b = new StringBuilder();
    Node[] children = lt.getRoot().getChildren();
    for (Node n : children) {
        char[] letters = n.getLetters();
        b.append(letters[0]);
    }
    Assert.assertEquals("おこさ", b.toString());
}
Also used : LOUDSPPBvTree(org.trie4j.louds.bvtree.LOUDSPPBvTree) PatriciaTrie(org.trie4j.patricia.PatriciaTrie) Node(org.trie4j.Node) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) Trie(org.trie4j.Trie) PatriciaTrie(org.trie4j.patricia.PatriciaTrie) ObjectInputStream(java.io.ObjectInputStream) AbstractTermIdTrieTest(org.trie4j.AbstractTermIdTrieTest) Test(org.junit.Test)

Aggregations

LOUDSPPBvTree (org.trie4j.louds.bvtree.LOUDSPPBvTree)7 Trie (org.trie4j.Trie)5 SuffixTrieDenseTailArrayBuilder (org.trie4j.tail.SuffixTrieDenseTailArrayBuilder)4 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Test (org.junit.Test)2 LongsRank0OnlySuccinctBitVector (org.trie4j.bv.LongsRank0OnlySuccinctBitVector)2 TailLOUDSTrie (org.trie4j.louds.TailLOUDSTrie)2 LOUDSBvTree (org.trie4j.louds.bvtree.LOUDSBvTree)2 PatriciaTrie (org.trie4j.patricia.PatriciaTrie)2 IOException (java.io.IOException)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 AbstractTermIdTrieTest (org.trie4j.AbstractTermIdTrieTest)1 Node (org.trie4j.Node)1 BytesConstantTimeSelect0SuccinctBitVector (org.trie4j.bv.BytesConstantTimeSelect0SuccinctBitVector)1 BytesRank0OnlySuccinctBitVector (org.trie4j.bv.BytesRank0OnlySuccinctBitVector)1 LongsConstantTimeSelect0SuccinctBitVector (org.trie4j.bv.LongsConstantTimeSelect0SuccinctBitVector)1 LongsSuccinctBitVector (org.trie4j.bv.LongsSuccinctBitVector)1 BvTree (org.trie4j.louds.bvtree.BvTree)1