Skip to content

Instantly share code, notes, and snippets.

@danielnaber
Created June 3, 2021 15:05
Show Gist options
  • Save danielnaber/737ecf678125eab5fd49fa9f8186983e to your computer and use it in GitHub Desktop.
Save danielnaber/737ecf678125eab5fd49fa9f8186983e to your computer and use it in GitHub Desktop.
public static void main(String[] args) throws IOException {
Dictionary dictionary = Dictionary.read(JLanguageTool.getDataBroker().getFromResourceDirAsUrl("/de/german.dict"));
DictionaryLookup dl = new DictionaryLookup(dictionary);
Map<String, List<String>> res = new HashMap<>();
for (WordData wd : dl) {
String word = wd.getWord().toString();
String base = wd.getStem().toString();
String tag = wd.getTag().toString();
if (tag.startsWith("ADJ:")) {
if (tag.matches("ADJ:AKK:PLU:...:GRU:DEF")) {
//if (tag.matches("ADJ:AKK:PLU:...:KOM:DEF")) {
//if (tag.matches("ADJ:AKK:PLU:...:SUP:DEF")) {
if (res.containsKey(base)) {
List<String> l = res.get(base);
l.add(tag);
res.put(base, l);
} else {
List<String> value = new ArrayList<>();
value.add(tag);
res.put(base, value);
}
}
}
}
for (Map.Entry<String, List<String>> entry : res.entrySet()) {
System.out.println(entry.getValue().size() + " " + entry.getKey() + " " + entry.getValue());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment