4
私は、Trieのメモリインプリメンテーションで高速実装を行い、バックエンドから自動提案/スペルチェッカーを作成したいと考えています。 ハローキャストのようなインメモリ実装に基づいた実装が既にありますか? また、これらの種類のJavaのオープンソースツールをお勧めします。Trieを実装するためのメモリJavaアプリケーションのベストオープンソース
私は、Trieのメモリインプリメンテーションで高速実装を行い、バックエンドから自動提案/スペルチェッカーを作成したいと考えています。 ハローキャストのようなインメモリ実装に基づいた実装が既にありますか? また、これらの種類のJavaのオープンソースツールをお勧めします。Trieを実装するためのメモリJavaアプリケーションのベストオープンソース
私はTreeSetのようなプレーンなNavigableSetを使用します。内蔵され、範囲検索をサポートします。
NavigableSet<String> words = new TreeSet<String>();
// add words.
String startsWith = ...
SortedSet<String> matching = words.subSet(startsWith, startsWith + '\uFFFF');
さらに効率的なメモリが必要な場合は、配列を使用できます。
List<String> words = new ArrayList<String>();
words.add("aa");
words.add("ab");
words.add("ac");
words.add("ba");
Collections.sort(words);
String startsWith = "a";
int first = Collections.binarySearch(words, startsWith);
int last = Collections.binarySearch(words, startsWith.concat("\uFFFF"));
if (first < 0) first = ~first;
if (last < 0) last = ~last - 1;
for (int i = first; i <= last; i++) {
System.out.println(words.get(i));
}
このツールが最適です - http://sna-projects.com/cleo/quickstart.php –