use of org.trie4j.Trie in project trie4j by takawitter.
the class Issue_031 method test_TailDoubleArray.
@Test
public void test_TailDoubleArray() throws Throwable {
Trie trie = new PatriciaTrie();
insertLines(trie, FILE_NAME);
Trie da = new TailDoubleArray(trie);
Assert.assertFalse(trie.contains("you"));
Assert.assertFalse(da.contains("you"));
}
use of org.trie4j.Trie 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"));
}
use of org.trie4j.Trie in project trie4j by takawitter.
the class LongsTailLOUDSTrieWithConcatTailArrayTest method test.
@Test
public void test() throws Exception {
String[] words = { "こんにちは", "さようなら", "おはよう", "おおきなかぶ", "おおやまざき" };
Trie lt = trieWithWords(words);
for (String w : words) {
Assert.assertTrue(w, 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());
}
use of org.trie4j.Trie in project trie4j by takawitter.
the class TailLOUDSTrieWithSuffixTrieTailArrayTest method test_save_load2.
@Test
public void test_save_load2() throws Exception {
String[] words = { "こんにちは", "さようなら", "おはよう", "おおきなかぶ", "おおやまざき" };
Trie trie = new PatriciaTrie();
for (String w : words) trie.insert(w);
TailLOUDSTrie lt = new TailLOUDSTrie(trie);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(lt);
oos.flush();
lt = (TailLOUDSTrie) new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())).readObject();
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());
}
use of org.trie4j.Trie in project trie4j by takawitter.
the class TailPatriciaTrieWithSuffixTrieTailBuilderTest method investigate.
public void investigate() throws Exception {
Trie t = new TailPatriciaTrie(new SuffixTrieTailBuilder());
int start = 0;
int end = 5;
int i = 0;
for (String word : new WikipediaTitles()) {
if (i >= end)
break;
if (i >= start) {
t.insert(word);
System.out.println(word);
}
i++;
}
i = 0;
for (String word : new WikipediaTitles()) {
if (i >= end)
break;
if (i >= start)
Assert.assertTrue(i + "th word: " + word, t.contains(word));
i++;
}
}
Aggregations