Package org.languagetool

Examples of org.languagetool.JLanguageTool.check()


    }
    JLanguageTool langTool = new JLanguageTool(Language.getLanguageForShortName(args[0]));
    String text = StringTools.readStream(new FileInputStream(args[1]), "utf-8");
    langTool.activateDefaultPatternRules();
    System.out.println("Warmup...");
    langTool.check(text);
    langTool.check(text);

    long baselineTime = getBaselineTime(langTool, text);
    System.out.println("Baseline: " + baselineTime + "ms (time with no pattern rules active)");
View Full Code Here


    JLanguageTool langTool = new JLanguageTool(Language.getLanguageForShortName(args[0]));
    String text = StringTools.readStream(new FileInputStream(args[1]), "utf-8");
    langTool.activateDefaultPatternRules();
    System.out.println("Warmup...");
    langTool.check(text);
    langTool.check(text);

    long baselineTime = getBaselineTime(langTool, text);
    System.out.println("Baseline: " + baselineTime + "ms (time with no pattern rules active)");

    int ruleNumber = langTool.getAllActiveRules().size();
View Full Code Here

          break;
        }
      }
      int activeRules = langTool.getAllActiveRules().size();
      long startTime = System.currentTimeMillis();
      langTool.check(text);
      long runTime = System.currentTimeMillis() - startTime;
      long cleanRunTime = runTime - baselineTime;
      if (prevActiveRules != -1 && prevCleanRunTime != -1) {
        float ruleFactor = (float)activeRules / prevActiveRules;
        float cleanRuntimeFactor = (float)cleanRunTime / prevCleanRunTime;
View Full Code Here

  private void initExpectedResults() throws IOException {
    JLanguageTool lt = new JLanguageTool(LANG);
    lt.activateDefaultPatternRules();
    for (String sentence : sentences) {
      List<RuleMatch> matches = lt.check(sentence);
      expectedResults.put(sentence, matches.toString());
    }
  }

  class Handler implements Runnable {
View Full Code Here

    @Override
    public void run() {
      try {
        JLanguageTool lt = new JLanguageTool(lang);
        lt.activateDefaultPatternRules();
        List<RuleMatch> matches = lt.check(sentence);
        //System.out.println("=>" + matches);
        String expected = expectedResults.get(sentence);
        String real = matches.toString();
        if (!expectedResults.get(sentence).equals(real)) {
          fail("Got '" + real + "', expected '" + expected + "' for input: " + sentence);
View Full Code Here

public class SpellingCheckRuleTest extends TestCase {

  public void testIgnoreSuggestionsWithHunspell() throws IOException {
    final JLanguageTool langTool = new JLanguageTool(new GermanyGerman());

    final List<RuleMatch> matches = langTool.check("Das ist ein einPseudoWortFürLanguageToolTests");
    assertEquals(0, matches.size());   // no error, as this word is in ignore.txt

    final List<RuleMatch> matches2 = langTool.check("Das ist ein Tibbfehla");
    assertEquals(1, matches2.size());
    Assert.assertEquals(GermanSpellerRule.RULE_ID, matches2.get(0).getRule().getId());
View Full Code Here

    final JLanguageTool langTool = new JLanguageTool(new GermanyGerman());

    final List<RuleMatch> matches = langTool.check("Das ist ein einPseudoWortFürLanguageToolTests");
    assertEquals(0, matches.size());   // no error, as this word is in ignore.txt

    final List<RuleMatch> matches2 = langTool.check("Das ist ein Tibbfehla");
    assertEquals(1, matches2.size());
    Assert.assertEquals(GermanSpellerRule.RULE_ID, matches2.get(0).getRule().getId());
  }

  public void testIgnoreSuggestionsWithDynamicHunspellRule() throws IOException {
View Full Code Here

  public void testIgnoreSuggestionsWithDynamicHunspellRule() throws IOException {
    final JLanguageTool langTool = new JLanguageTool(new GermanyGerman());
    final SpellingCheckRule rule = new HunspellNoSuggestionRule(TestTools.getEnglishMessages(), new GermanyGerman());
    langTool.addRule(rule);
    langTool.disableRule(GermanSpellerRule.RULE_ID);
    final List<RuleMatch> matches = langTool.check("Das ist ein Tibbfehla.");
    assertEquals(1, matches.size());
    assertEquals(HunspellNoSuggestionRule.RULE_ID, matches.get(0).getRule().getId());

    final PatternRule ruleWithSuggestion = new PatternRule("TEST_ID", new GermanyGerman(),
            Collections.<Element>emptyList(), "description",
View Full Code Here

    final PatternRule ruleWithSuggestion = new PatternRule("TEST_ID", new GermanyGerman(),
            Collections.<Element>emptyList(), "description",
            "Meinten Sie <suggestion>Tibbfehla</suggestion>?", null);
    langTool.addRule(ruleWithSuggestion);
    final List<RuleMatch> matches2 = langTool.check("Das ist ein Tibbfehla.");
    assertEquals(0, matches2.size());   // no error anymore, as this is a suggestion

    langTool.disableRule("TEST_ID");
    final List<RuleMatch> matches3 = langTool.check("Das ist ein Tibbfehla.");
    assertEquals(1, matches3.size());   // an error again
View Full Code Here

    langTool.addRule(ruleWithSuggestion);
    final List<RuleMatch> matches2 = langTool.check("Das ist ein Tibbfehla.");
    assertEquals(0, matches2.size());   // no error anymore, as this is a suggestion

    langTool.disableRule("TEST_ID");
    final List<RuleMatch> matches3 = langTool.check("Das ist ein Tibbfehla.");
    assertEquals(1, matches3.size());   // an error again
  }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.