Search in sources :

Example 1 with CachingWordListLoader

use of org.languagetool.rules.spelling.CachingWordListLoader in project languagetool by languagetool-org.

the class WordListValidatorTest method testWordListValidity.

@Test
public void testWordListValidity() throws IOException {
    Set<String> checked = new HashSet<>();
    for (Language lang : Languages.get()) {
        if (lang.getShortCode().equals("ru")) {
            // skipping, Cyrillic chars not part of the validation yet
            continue;
        }
        JLanguageTool lt = new JLanguageTool(lang);
        List<Rule> rules = lt.getAllActiveRules();
        for (Rule rule : rules) {
            if (rule instanceof SpellingCheckRule) {
                SpellingCheckRule sRule = (SpellingCheckRule) rule;
                String file = sRule.getSpellingFileName();
                if (JLanguageTool.getDataBroker().resourceExists(file) && !checked.contains(file)) {
                    System.out.println("Checking " + file);
                    CachingWordListLoader loader = new CachingWordListLoader();
                    List<String> words = loader.loadWords(file);
                    validateWords(words, file);
                    checked.add(file);
                }
            }
        }
    }
}
Also used : Language(org.languagetool.Language) SpellingCheckRule(org.languagetool.rules.spelling.SpellingCheckRule) JLanguageTool(org.languagetool.JLanguageTool) SpellingCheckRule(org.languagetool.rules.spelling.SpellingCheckRule) CachingWordListLoader(org.languagetool.rules.spelling.CachingWordListLoader) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

HashSet (java.util.HashSet)1 Test (org.junit.Test)1 JLanguageTool (org.languagetool.JLanguageTool)1 Language (org.languagetool.Language)1 CachingWordListLoader (org.languagetool.rules.spelling.CachingWordListLoader)1 SpellingCheckRule (org.languagetool.rules.spelling.SpellingCheckRule)1