public GermanSpellerRule(ResourceBundle messages, German language) { super(messages, language, language.getNonStrictCompoundSplitter(), getSpeller(language)); addExamplePair( Example.wrong( "LanguageTool kann mehr als eine <marker>nromale</marker> Rechtschreibprüfung."), Example.fixed( "LanguageTool kann mehr als eine <marker>normale</marker> Rechtschreibprüfung.")); compoundTokenizer = language.getStrictCompoundTokenizer(); tagger = language.getTagger(); synthesizer = language.getSynthesizer(); try { splitter = new GermanWordSplitter(false); } catch (IOException e) { throw new RuntimeException(e); } }
/** * @return a list of forms of @param verb which match @param expectedVerbPOS (person:number) * @param toUppercase true when the suggestions should be capitalized */ private List<String> getVerbSuggestions( final AnalyzedTokenReadings verb, final String expectedVerbPOS, final boolean toUppercase) { // find the first verb reading AnalyzedToken verbToken = new AnalyzedToken("", "", ""); for (AnalyzedToken token : verb.getReadings()) { if (token.getPOSTag().startsWith("VER:")) { verbToken = token; break; } } try { String[] synthesized = german.getSynthesizer().synthesize(verbToken, "VER.*:" + expectedVerbPOS + ".*", true); // remove duplicates Set<String> suggestionSet = new HashSet<>(); suggestionSet.addAll(Arrays.asList(synthesized)); List<String> suggestions = new ArrayList<>(); suggestions.addAll(suggestionSet); if (toUppercase) { for (int i = 0; i < suggestions.size(); ++i) { suggestions.set(i, StringTools.uppercaseFirstChar(suggestions.get(i))); } } Collections.sort(suggestions); return suggestions; } catch (IOException e) { throw new RuntimeException(e); } }