use of org.trie4j.tail.SBVConcatTailArrayBuilder in project trie4j by takawitter.
the class SaveLOUDSTrie method main.
public static void main(String[] args) throws Exception {
TailPatriciaTrie trie1 = new TailPatriciaTrie();
for (String s : new WikipediaTitles("data/jawiki-20120220-all-titles-in-ns0.gz")) {
trie1.insert(s);
}
System.out.println(trie1.size() + "nodes.");
SBVConcatTailArrayBuilder tailArray = new SBVConcatTailArrayBuilder(trie1.size());
TailLOUDSTrie trie = new TailLOUDSTrie(trie1, tailArray);
System.out.println(trie.size() + "nodes.");
trie.freeze();
OutputStream os = new FileOutputStream("louds.dat");
try {
ObjectOutputStream oos = new ObjectOutputStream(os);
trie.writeExternal(oos);
oos.flush();
} finally {
os.close();
}
os = new FileOutputStream("louds-bv.dat");
try {
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(trie.getBvTree());
oos.flush();
} finally {
os.close();
}
os = new FileOutputStream("louds-labels.dat");
try {
DataOutputStream dos = new DataOutputStream(os);
for (char c : trie.getLabels()) {
dos.writeChar(c);
}
dos.flush();
} finally {
os.close();
}
os = new FileOutputStream("louds-tails.dat");
try {
ObjectOutputStream dos = new ObjectOutputStream(os);
dos.writeObject(tailArray);
dos.flush();
} finally {
os.close();
}
os = new FileOutputStream("louds-tailIndex.dat");
try {
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(tailArray);
oos.flush();
} finally {
os.close();
}
os = new FileOutputStream("louds-term.dat");
try {
ObjectOutputStream dos = new ObjectOutputStream(os);
dos.writeObject(trie.getTerm());
dos.flush();
} finally {
os.close();
}
}
Aggregations