use of org.languagetool.tagging.disambiguation.rules.DisambiguationRuleLoader in project languagetool by languagetool-org.
the class TestFrenchDisambiguator method disambiguate.
@Override
public AnalyzedSentence disambiguate(AnalyzedSentence input) throws IOException {
AnalyzedSentence sentence = input;
String filePath = "/disambiguator.xml";
try (InputStream inputStream = getClass().getResourceAsStream(filePath)) {
final DisambiguationRuleLoader ruleLoader = new DisambiguationRuleLoader();
List<DisambiguationPatternRule> disambiguationRules = ruleLoader.getRules(inputStream);
for (final DisambiguationPatternRule patternRule : disambiguationRules) {
sentence = patternRule.replace(sentence);
}
} catch (Exception e) {
throw new RuntimeException("Problems with loading disambiguation file: " + filePath, e);
}
return sentence;
}
Aggregations