Examples of JLanguageTool


Examples of org.languagetool.JLanguageTool

    private static Pattern regexSet = Pattern.compile("^\\[([^\\-])*?\\]$");

    // default constructor; defaults to English
    public RuleCoverage() throws IOException {
      language = Language.ENGLISH;
      tool = new JLanguageTool(language);
        tool.activateDefaultPatternRules();
        tool.disableRule("UPPERCASE_SENTENCE_START");
        tool.disableRule("EN_UNPAIRED_BRACKETS");
        tool.disableRule("EN_A_VS_AN");
        setupDictionaryFiles();
View Full Code Here

Examples of org.languagetool.JLanguageTool

    // disable some of the default rules in the constructors
    //TODO: disable the right rules for each language
    // though this matters less when we return an array of all covering rules
    public RuleCoverage(Language language) throws IOException {
      this.language = language;
      tool = new JLanguageTool(language);
        tool.activateDefaultPatternRules();
        setupDictionaryFiles();
    }
View Full Code Here

Examples of org.languagetool.JLanguageTool

    }
   
    // for testing purposes, defaults to English
    public RuleCoverage(String dictFileName) throws IOException {
      language = Language.ENGLISH;
      tool = new JLanguageTool(language);
        tool.activateDefaultPatternRules();
        tool.disableRule("UPPERCASE_SENTENCE_START");
        tool.disableRule("EN_UNPAIRED_BRACKETS");
        tool.disableRule("EN_A_VS_AN");
        this.filename = dictFileName;
View Full Code Here

Examples of org.languagetool.JLanguageTool

  // displays the existing LT rule that covers the converted rule
  private void openExistingRuleWindow(String[] ruleIds) {
    if (checker == null) {
      return;
    }
    JLanguageTool tool = checker.getLanguageTool();
    String fetchedRuleString = "<pre>";
    List<Rule> rules = tool.getAllRules();
    for (String ruleId : ruleIds) {
      for (Rule rule : rules) {
        if (rule.getId().equals(ruleId)) {
          // can only display pattern rules
          try {
View Full Code Here

Examples of org.languagetool.JLanguageTool

 

  @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());
      config.setMotherTongue(cfgDialog.getMotherTongue());
      config.saveConfiguration(docLanguage);
View Full Code Here

Examples of org.languagetool.JLanguageTool

    this.singleLineBreakMarksParagraph = singleLineBreakMarksParagraph;
    profileRules = false;
    bitextMode = false;
    srcLt = null;
    bRules = null;
    lt = new JLanguageTool(language, motherTongue);
    lt.activateDefaultPatternRules();
    lt.activateDefaultFalseFriendRules();
    Tools.selectRules(lt, disabledRules, enabledRules);
  }
View Full Code Here

Examples of org.languagetool.JLanguageTool

  private void setBitextMode(final Language sourceLang,
      final String[] disabledRules, final String[] enabledRules) throws IOException, ParserConfigurationException, SAXException {
    bitextMode = true;
    final Language target = lt.getLanguage();
    lt = new JLanguageTool(target, null);
    srcLt = new JLanguageTool(sourceLang);
    lt.activateDefaultPatternRules();
    Tools.selectRules(lt, disabledRules, enabledRules);
    Tools.selectRules(srcLt, disabledRules, enabledRules);
    bRules = Tools.getBitextRules(sourceLang, lt.getLanguage());
View Full Code Here

Examples of org.languagetool.JLanguageTool

  }

  private void changeLanguage(Language language, Language motherTongue,
                              String[] disabledRules, String[] enabledRules) {
    try {
      lt = new JLanguageTool(language, motherTongue);
      lt.activateDefaultPatternRules();
      lt.activateDefaultFalseFriendRules();
      Tools.selectRules(lt, disabledRules, enabledRules);
      if (verbose) {
        lt.setOutput(System.err);
View Full Code Here

Examples of org.languagetool.JLanguageTool

    useQuerySettings = enabledRules.length > 0 || disabledRules.length > 0;
   
    final List<RuleMatch> matches;
    final String sourceText = parameters.get("srctext");
    if (sourceText == null) {
      final JLanguageTool lt = getLanguageToolInstance(lang, motherTongue);
      matches = lt.check(text);
    } else {
      if (motherTongueParam == null) {
        throw new IllegalArgumentException("Missing 'motherTongue' for bilingual checks");
      }
      print("Checking bilingual text, with source length " + sourceText.length() +
          " and target length " + text.length() + " (characters), source language " +
          motherTongue + " and target language " + langParam);
      final JLanguageTool sourceLt = getLanguageToolInstance(motherTongue, null);
      final JLanguageTool targetLt = getLanguageToolInstance(lang, null);
      final List<BitextRule> bRules = Tools.getBitextRules(motherTongue, lang);
      matches = Tools.checkBitext(sourceText, text, sourceLt, targetLt, bRules);
    }
    setCommonHeaders(httpExchange);
    final String response = StringTools.ruleMatchesToXML(matches, text,
View Full Code Here

Examples of org.languagetool.JLanguageTool

   * @param motherTongue the user's mother tongue or <code>null</code>
   * @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);
    }
    if (useQuerySettings) {
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.