vocabularies are now also used as source for a did-you-mean computation

pull/1/head
Michael Christen 13 years ago
parent eaec14ecc4
commit fa8da7f89d

@ -89,6 +89,10 @@ public class Autotagging {
} }
} }
public Set<String> allTags() {
return this.allTags.keySet();
}
public void addDictionaries(Map<String, Dictionary> dictionaries) { public void addDictionaries(Map<String, Dictionary> dictionaries) {
for (Map.Entry<String, Dictionary> entry: dictionaries.entrySet()) { for (Map.Entry<String, Dictionary> entry: dictionaries.entrySet()) {
Vocabulary voc = new Vocabulary(entry.getKey(), entry.getValue()); Vocabulary voc = new Vocabulary(entry.getKey(), entry.getValue());

@ -32,6 +32,7 @@ import java.io.InputStreamReader;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
@ -111,8 +112,11 @@ public class LibraryProvider
integrateOpenGeoDB(); integrateOpenGeoDB();
integrateGeonames(); integrateGeonames();
initAutotagging(tagPrefix); initAutotagging(tagPrefix);
Set<String> allTags = new HashSet<String>() ;
allTags.addAll(autotagging.allTags()); // we must copy this into a clone to prevent circularity
autotagging.addLocalization(geoLoc); autotagging.addLocalization(geoLoc);
autotagging.addDictionaries(dymLib.getDictionaries()); autotagging.addDictionaries(dymLib.getDictionaries());
WordCache.learn(allTags);
} }
public static void integrateOpenGeoDB() { public static void integrateOpenGeoDB() {

@ -220,6 +220,12 @@ public class WordCache {
} }
} }
public static void learn(Set<String> wordset) {
for (String s: wordset) {
learn(new StringBuilder(s));
}
}
/** /**
* scan the input directory and load all dictionaries (again) * scan the input directory and load all dictionaries (again)
*/ */

Loading…
Cancel
Save