Package org.languagetool

Examples of org.languagetool.JLanguageTool.activateDefaultPatternRules()


    if (!file.exists() || !file.isFile()) {
      throw new IOException("File doesn't exist or isn't a file: " + xmlFileName);
    }
    final Language lang = Language.getLanguageForShortName(langCode);
    final JLanguageTool languageTool = new JLanguageTool(lang);
    languageTool.activateDefaultPatternRules();
    if (ruleIds != null) {
      enableSpecifiedRules(ruleIds, languageTool);
    } else {
      applyRuleDeactivation(languageTool, disabledRules);
    }
View Full Code Here


    return new MediaWikiContent(handler.getRevisionContent(), handler.getTimestamp());
  }

  private JLanguageTool getLanguageTool(Language lang) throws IOException {
    final JLanguageTool langTool = new JLanguageTool(lang);
    langTool.activateDefaultPatternRules();
    for (String disabledRuleId : disabledRuleIds) {
      langTool.disableRule(disabledRuleId);
    }
    disableSpellingRules(langTool);
    return langTool;
View Full Code Here

      final Rule spellcheckRule = getSpellcheckRule(languageTool);
      if (spellcheckRule == null) {
        System.out.println("No spellchecker rule found for " + lang);
        continue;
      }
      languageTool.activateDefaultPatternRules();
      final List<Rule> rules = languageTool.getAllRules();
      int tokenCount = 0;
      int noErrorCount = 0;
      for (Rule rule : rules) {
        final List<String> tokens = getSuggestionTokens(rule, lang);
View Full Code Here

  @Override
  public void run() {   
    try {
      final JLanguageTool langTool = new JLanguageTool(docLanguage, cfgDialog.getMotherTongue());
      langTool.activateDefaultPatternRules();
      langTool.activateDefaultFalseFriendRules();
      cfgDialog.show(langTool.getAllRules());
      config.setDisabledRuleIds(cfgDialog.getDisabledRuleIds());
      config.setEnabledRuleIds(cfgDialog.getEnabledRuleIds());
      config.setDisabledCategoryNames(cfgDialog.getDisabledCategoryNames());
View Full Code Here

   * @return a JLanguageTool instance for a specific language and mother tongue.
   * @throws Exception when JLanguageTool creation failed
   */
  private JLanguageTool getLanguageToolInstance(Language lang, Language motherTongue) throws Exception {
    final JLanguageTool newLanguageTool = new JLanguageTool(lang, motherTongue);
    newLanguageTool.activateDefaultPatternRules();
    newLanguageTool.activateDefaultFalseFriendRules();
    config = new Configuration(lang);
    if (!useQuerySettings && internalServer && config.getUseGUIConfig()) { // use the GUI config values
      configureGUI(newLanguageTool);
    }
View Full Code Here

    System.setErr(this.stderr);
  }

  public void testCheck() throws IOException, ParserConfigurationException, SAXException {
    final JLanguageTool tool = new JLanguageTool(Language.DEMO);
    tool.activateDefaultPatternRules();
    tool.activateDefaultFalseFriendRules();
    int matches = Tools.checkText("Foo.", tool);
    String output = new String(this.out.toByteArray());
    assertEquals(0, output.indexOf("Time:"));
View Full Code Here

    assertBad("Bei dem Papierabzüge von Digitalbildern bestellte werden.", "bezüglich Kasus, Genus oder Numerus.");
  }
 
  public void testRegression() throws IOException {
      JLanguageTool gramCheckerEngine = new JLanguageTool(new German());
      gramCheckerEngine.activateDefaultPatternRules();
      // used to be not detected > 1.0.1:
      String str = "Und so.\r\nDie Bier.";
      List<RuleMatch> matches = gramCheckerEngine.check(str);
      assertEquals(1, matches.size());
  }
View Full Code Here

  public void testBitextCheck() throws IOException, ParserConfigurationException, SAXException {
    final English english = new English();
    final JLanguageTool srcTool = new JLanguageTool(english);
    final Polish polish = new Polish();
    final JLanguageTool trgTool = new JLanguageTool(polish);
    trgTool.activateDefaultPatternRules();
   
    final List<BitextRule> rules = Tools.getBitextRules(english, polish);
   
    int matches = Tools.checkBitext(
        "This is a perfectly good sentence.",
View Full Code Here

    System.setErr(this.stderr);
  }

  public void testCheck() throws IOException, ParserConfigurationException, SAXException {
    final JLanguageTool tool = new JLanguageTool(new Polish());
    tool.activateDefaultPatternRules();
    tool.activateDefaultFalseFriendRules();
    int matches = Tools.checkText("To jest całkowicie prawidłowe zdanie.", tool);
    String output = new String(this.out.toByteArray());
    assertEquals(0, output.indexOf("Time:"));
View Full Code Here

    assertEquals(1, matches);
  }

  public void testCorrect() throws IOException, ParserConfigurationException, SAXException {
    JLanguageTool tool = new JLanguageTool(new Polish());
    tool.activateDefaultPatternRules();
    tool.activateDefaultFalseFriendRules();

    String correct = Tools.correctText("To jest całkowicie prawidłowe zdanie.", tool);
    assertEquals("To jest całkowicie prawidłowe zdanie.", correct);
    correct = Tools.correctText("To jest jest problem.", tool);
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.