use of org.languagetool.databroker.ResourceDataBroker in project languagetool by languagetool-org.
the class RuleOverview method countConfusionPairs.
private int countConfusionPairs(Language lang) {
String path = "/" + lang.getShortCode() + "/confusion_sets.txt";
ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
if (dataBroker.resourceExists(path)) {
try (InputStream confusionSetStream = dataBroker.getFromResourceDirAsStream(path)) {
ConfusionSetLoader confusionSetLoader = new ConfusionSetLoader();
return confusionSetLoader.loadConfusionSet(confusionSetStream).size() / 2;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return 0;
}
Aggregations