Search in sources :

Example 6 with ResourceDataBroker

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;
}
Also used : InputStream(java.io.InputStream) ResourceDataBroker(org.languagetool.databroker.ResourceDataBroker) IOException(java.io.IOException) ConfusionSetLoader(org.languagetool.rules.ConfusionSetLoader)

Aggregations

ResourceDataBroker (org.languagetool.databroker.ResourceDataBroker)6 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ImageIcon (javax.swing.ImageIcon)1 Language (org.languagetool.Language)1 ConfusionSetLoader (org.languagetool.rules.ConfusionSetLoader)1