Package org.languagetool

Examples of org.languagetool.JLanguageTool.check()


    assertEquals(0, matches.size());
   
    matches = langTool.check("Das ist aufwendig. Aber hallo. Es ist wirklich aufwändiger als...");
    assertEquals(1, matches.size());
   
    matches = langTool.check("Das ist aufwändig. Aber hallo. Es ist wirklich aufwendiger als...");
    assertEquals(1, matches.size());
   
    matches = langTool.check("Das ist das aufwändigste. Aber hallo. Es ist wirklich aufwendiger als...");
    assertEquals(1, matches.size());
   
View Full Code Here


    assertEquals(1, matches.size());
   
    matches = langTool.check("Das ist aufwändig. Aber hallo. Es ist wirklich aufwendiger als...");
    assertEquals(1, matches.size());
   
    matches = langTool.check("Das ist das aufwändigste. Aber hallo. Es ist wirklich aufwendiger als...");
    assertEquals(1, matches.size());
   
    matches = langTool.check("Das ist das aufwändigste. Aber hallo. Es ist wirklich aufwendig.");
    assertEquals(1, matches.size());
View Full Code Here

    assertEquals(1, matches.size());
   
    matches = langTool.check("Das ist das aufwändigste. Aber hallo. Es ist wirklich aufwendiger als...");
    assertEquals(1, matches.size());
   
    matches = langTool.check("Das ist das aufwändigste. Aber hallo. Es ist wirklich aufwendig.");
    assertEquals(1, matches.size());

    // cross-paragraph checks
    matches = langTool.check("Das ist das aufwändigste.\n\nAber hallo. Es ist wirklich aufwendig.");
    assertEquals(1, matches.size());
View Full Code Here

   
    matches = langTool.check("Das ist das aufwändigste. Aber hallo. Es ist wirklich aufwendig.");
    assertEquals(1, matches.size());

    // cross-paragraph checks
    matches = langTool.check("Das ist das aufwändigste.\n\nAber hallo. Es ist wirklich aufwendig.");
    assertEquals(1, matches.size());
  }

}
View Full Code Here

    langTool.disableRule("DE_CASE");
    langTool.disableRule("ABKUERZUNG_LEERZEICHEN");
    langTool.disableRule("TYPOGRAFISCHE_ANFUEHRUNGSZEICHEN");
    SwebleWikipediaTextFilter filter = new SwebleWikipediaTextFilter();
    PlainTextMapping mapping = filter.filter(origMarkup);
    List<RuleMatch> matches = langTool.check(mapping.getPlainText());
    assertThat("Expected 3 matches, got: " + matches, matches.size(), is(3));
    String markup = origMarkup;
    int oldPos = 0;
    for (RuleMatch match : matches) {
      SuggestionReplacer replacer = new SuggestionReplacer(mapping, markup, "<s>", "</s>");
View Full Code Here

    String origMarkup = IOUtils.toString(stream);
    JLanguageTool langTool = new JLanguageTool(new GermanyGerman());
    langTool.activateDefaultPatternRules();
    SwebleWikipediaTextFilter filter = new SwebleWikipediaTextFilter();
    PlainTextMapping mapping = filter.filter(origMarkup);
    List<RuleMatch> matches = langTool.check(mapping.getPlainText());
    assertTrue("Expected >= 30 matches, got: " + matches, matches.size() >= 30);
    String markup = origMarkup;
    for (RuleMatch match : matches) {
      SuggestionReplacer replacer = new SuggestionReplacer(mapping, markup, "<s>", "</s>");
      List<RuleMatchApplication> ruleMatchApplications = replacer.applySuggestionsToOriginalText(match);
View Full Code Here

  private List<RuleMatch> getRuleMatches(String text, Map<String, String> parameters, Language lang,
                                         Language motherTongue, QueryParams params) throws Exception {
    final String sourceText = parameters.get("srctext");
    if (sourceText == null) {
      final JLanguageTool lt = getLanguageToolInstance(lang, motherTongue, params);
      return lt.check(text);
    } else {
      if (parameters.get("motherTongue") == null) {
        throw new IllegalArgumentException("Missing 'motherTongue' parameter for bilingual checks");
      }
      print("Checking bilingual text, with source length " + sourceText.length() +
View Full Code Here

    for (Language lang : languages) {
      JLanguageTool lt = new JLanguageTool(lang);
      lt.activateDefaultPatternRules();
      String input = examples.get(lang.getShortNameWithCountryAndVariant());
      if (input != null) {
        List<RuleMatch> matches = lt.check(input);
        expectedResults.put(lang.getShortNameWithCountryAndVariant(), toString(matches));
      }
    }
  }
View Full Code Here

      if (input != null) {
        try {
          JLanguageTool lt = new JLanguageTool(lang);
          lt.activateDefaultPatternRules();
          //System.out.println("Running with " + lang.getShortNameWithCountryAndVariant());
          List<RuleMatch> matches = lt.check(input);
          //System.out.println("=>" + matches);
          String expected = expectedResults.get(lang.getShortNameWithCountryAndVariant());
          String real = MultiThreadingTest1.toString(matches);
          if (!expectedResults.get(lang.getShortNameWithCountryAndVariant()).equals(real)) {
            fail(lang + ": got '" + real + "', expected '" + expected + "'");
View Full Code Here

      int endIndex = Math.min(beginIndex + MAX_TEXT_LENGTH, text.length()-1);
      String subText = text.substring(beginIndex, endIndex);
      long startTime = System.currentTimeMillis();
      JLanguageTool langTool = new MultiThreadedJLanguageTool(language);
      langTool.activateDefaultPatternRules();
      List<RuleMatch> matches = langTool.check(subText);
      long runTime = System.currentTimeMillis() - startTime;
      if (i >= SKIP) {
        totalTime += runTime;
        System.out.println("Time: " + runTime + "ms (" + matches.size() + " matches)");
      } else {
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.