Search in sources :

Example 1 with DemoDisambiguator

use of org.languagetool.tagging.disambiguation.xx.DemoDisambiguator in project languagetool by languagetool-org.

the class DisambiguationRuleTest method testDisambiguationRulesFromXML.

private void testDisambiguationRulesFromXML(Set<Language> ignoredLanguages) throws IOException, ParserConfigurationException, SAXException {
    for (Language lang : Languages.getWithDemoLanguage()) {
        if (ignoredLanguages != null && ignoredLanguages.contains(lang)) {
            continue;
        }
        if (lang.isVariant()) {
            System.out.println("Skipping variant: " + lang);
            continue;
        }
        System.out.println("Running disambiguation tests for " + lang.getName() + "...");
        DisambiguationRuleLoader ruleLoader = new DisambiguationRuleLoader();
        JLanguageTool languageTool = new JLanguageTool(lang);
        if (!(languageTool.getLanguage().getDisambiguator() instanceof DemoDisambiguator)) {
            long startTime = System.currentTimeMillis();
            String name = JLanguageTool.getDataBroker().getResourceDir() + "/" + lang.getShortCode() + "/disambiguation.xml";
            validateRuleFile(name);
            List<DisambiguationPatternRule> rules = ruleLoader.getRules(ruleLoader.getClass().getResourceAsStream(name));
            for (DisambiguationPatternRule rule : rules) {
                PatternTestTools.warnIfRegexpSyntaxNotKosher(rule.getPatternTokens(), rule.getId(), rule.getSubId(), lang);
            }
            testDisambiguationRulesFromXML(rules, languageTool, lang);
            long endTime = System.currentTimeMillis();
            System.out.println(rules.size() + " rules tested (" + (endTime - startTime) + "ms)");
        }
    }
}
Also used : DemoDisambiguator(org.languagetool.tagging.disambiguation.xx.DemoDisambiguator) Language(org.languagetool.Language) JLanguageTool(org.languagetool.JLanguageTool)

Example 2 with DemoDisambiguator

use of org.languagetool.tagging.disambiguation.xx.DemoDisambiguator in project languagetool by languagetool-org.

the class EnglishDisambiguationRuleTest method setUp.

@Before
public void setUp() {
    tagger = new EnglishTagger();
    tokenizer = new WordTokenizer();
    sentenceTokenizer = new SRXSentenceTokenizer(new English());
    disambiguator = new XmlRuleDisambiguator(new English());
    disamb2 = new DemoDisambiguator();
}
Also used : English(org.languagetool.language.English) DemoDisambiguator(org.languagetool.tagging.disambiguation.xx.DemoDisambiguator) XmlRuleDisambiguator(org.languagetool.tagging.disambiguation.rules.XmlRuleDisambiguator) WordTokenizer(org.languagetool.tokenizers.WordTokenizer) EnglishTagger(org.languagetool.tagging.en.EnglishTagger) SRXSentenceTokenizer(org.languagetool.tokenizers.SRXSentenceTokenizer) Before(org.junit.Before)

Example 3 with DemoDisambiguator

use of org.languagetool.tagging.disambiguation.xx.DemoDisambiguator in project languagetool by languagetool-org.

the class UkrainianDisambiguationRuleTest method setUp.

@Before
public void setUp() {
    tagger = new UkrainianTagger();
    tokenizer = new UkrainianWordTokenizer();
    sentenceTokenizer = new SRXSentenceTokenizer(new Ukrainian());
    disambiguator = new UkrainianHybridDisambiguator();
    demoDisambiguator = new DemoDisambiguator();
    chunker = new MultiWordChunker("/uk/multiwords.txt", true);
}
Also used : DemoDisambiguator(org.languagetool.tagging.disambiguation.xx.DemoDisambiguator) Ukrainian(org.languagetool.language.Ukrainian) MultiWordChunker(org.languagetool.tagging.disambiguation.MultiWordChunker) UkrainianTagger(org.languagetool.tagging.uk.UkrainianTagger) UkrainianHybridDisambiguator(org.languagetool.tagging.disambiguation.uk.UkrainianHybridDisambiguator) UkrainianWordTokenizer(org.languagetool.tokenizers.uk.UkrainianWordTokenizer) SRXSentenceTokenizer(org.languagetool.tokenizers.SRXSentenceTokenizer) Before(org.junit.Before)

Example 4 with DemoDisambiguator

use of org.languagetool.tagging.disambiguation.xx.DemoDisambiguator in project languagetool by languagetool-org.

the class FrenchRuleDisambiguatorTest method setUp.

@Before
public void setUp() throws IOException {
    tagger = new FrenchTagger();
    tokenizer = new WordTokenizer();
    French language = new French();
    sentenceTokenizer = new SRXSentenceTokenizer(language);
    disambiguator = new XmlRuleDisambiguator(language);
    disamb2 = new DemoDisambiguator();
}
Also used : DemoDisambiguator(org.languagetool.tagging.disambiguation.xx.DemoDisambiguator) FrenchTagger(org.languagetool.tagging.fr.FrenchTagger) French(org.languagetool.language.French) XmlRuleDisambiguator(org.languagetool.tagging.disambiguation.rules.XmlRuleDisambiguator) WordTokenizer(org.languagetool.tokenizers.WordTokenizer) SRXSentenceTokenizer(org.languagetool.tokenizers.SRXSentenceTokenizer) Before(org.junit.Before)

Example 5 with DemoDisambiguator

use of org.languagetool.tagging.disambiguation.xx.DemoDisambiguator in project languagetool by languagetool-org.

the class RomanianRuleDisambiguatorTest method setUp.

@Before
public void setUp() {
    tagger = new RomanianTagger();
    tokenizer = new RomanianWordTokenizer();
    Romanian language = new Romanian();
    sentenceTokenizer = new SRXSentenceTokenizer(language);
    disambiguator = new XmlRuleDisambiguator(language);
    disamb2 = new DemoDisambiguator();
}
Also used : RomanianTagger(org.languagetool.tagging.ro.RomanianTagger) DemoDisambiguator(org.languagetool.tagging.disambiguation.xx.DemoDisambiguator) Romanian(org.languagetool.language.Romanian) RomanianWordTokenizer(org.languagetool.tokenizers.ro.RomanianWordTokenizer) XmlRuleDisambiguator(org.languagetool.tagging.disambiguation.rules.XmlRuleDisambiguator) SRXSentenceTokenizer(org.languagetool.tokenizers.SRXSentenceTokenizer) Before(org.junit.Before)

Aggregations

DemoDisambiguator (org.languagetool.tagging.disambiguation.xx.DemoDisambiguator)5 Before (org.junit.Before)4 SRXSentenceTokenizer (org.languagetool.tokenizers.SRXSentenceTokenizer)4 XmlRuleDisambiguator (org.languagetool.tagging.disambiguation.rules.XmlRuleDisambiguator)3 WordTokenizer (org.languagetool.tokenizers.WordTokenizer)2 JLanguageTool (org.languagetool.JLanguageTool)1 Language (org.languagetool.Language)1 English (org.languagetool.language.English)1 French (org.languagetool.language.French)1 Romanian (org.languagetool.language.Romanian)1 Ukrainian (org.languagetool.language.Ukrainian)1 MultiWordChunker (org.languagetool.tagging.disambiguation.MultiWordChunker)1 UkrainianHybridDisambiguator (org.languagetool.tagging.disambiguation.uk.UkrainianHybridDisambiguator)1 EnglishTagger (org.languagetool.tagging.en.EnglishTagger)1 FrenchTagger (org.languagetool.tagging.fr.FrenchTagger)1 RomanianTagger (org.languagetool.tagging.ro.RomanianTagger)1 UkrainianTagger (org.languagetool.tagging.uk.UkrainianTagger)1 RomanianWordTokenizer (org.languagetool.tokenizers.ro.RomanianWordTokenizer)1 UkrainianWordTokenizer (org.languagetool.tokenizers.uk.UkrainianWordTokenizer)1