Package org.languagetool.rules.spelling

Examples of org.languagetool.rules.spelling.SuggestionExtractor


  /**
   * Add a rule to be used by the next call to the check methods like {@link #check(String)}.
   */
  public void addRule(final Rule rule) {
    userRules.add(rule);
    final SuggestionExtractor extractor = new SuggestionExtractor();
    final List<String> suggestionTokens = extractor.getSuggestionTokens(rule, language);
    final List<Rule> allActiveRules = getAllActiveRules();
    addIgnoreWords(suggestionTokens, allActiveRules);
  }
View Full Code Here


  private List<String> getAllIgnoreWords(List<Rule> allActiveRules) {
    final List<String> suggestionTokens = new ArrayList<>();
    for (Rule activeRule : allActiveRules) {
      if (activeRule instanceof PatternRule) {
        final SuggestionExtractor extractor = new SuggestionExtractor();
        suggestionTokens.addAll(extractor.getSuggestionTokens(activeRule, language));
      }
    }
    return suggestionTokens;
  }
View Full Code Here

  /**
   * We don't support sub-language resources yet, so collect all variants for one language.
   */
  private Map<Language, Set<String>> getLanguageToIgnoreTokensMapping() throws IOException {
    final Map<Language, Set<String>> langToIgnoreTokens = new HashMap<>();
    SuggestionExtractor extractor = new SuggestionExtractor();
    for (Language lang : Language.REAL_LANGUAGES) {
      final Set<String> suggestionTokens = new HashSet<>();
      final JLanguageTool languageTool = new JLanguageTool(lang);
      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 = extractor.getSuggestionTokens(rule, lang);
        tokenCount += tokens.size();
        for (String token : tokens) {
          final AnalyzedSentence sentence = languageTool.getAnalyzedSentence(token);
          final RuleMatch[] matches = spellcheckRule.match(sentence);
          if (matches.length > 0) {
View Full Code Here

  /**
   * Add a rule to be used by the next call to the check methods like {@link #check(String)}.
   */
  public void addRule(final Rule rule) {
    userRules.add(rule);
    final SuggestionExtractor extractor = new SuggestionExtractor();
    final List<String> suggestionTokens = extractor.getSuggestionTokens(rule, language);
    final List<Rule> allActiveRules = getAllActiveRules();
    addIgnoreWords(suggestionTokens, allActiveRules);
  }
View Full Code Here

  private List<String> getAllIgnoreWords(List<Rule> allActiveRules) {
    final List<String> suggestionTokens = new ArrayList<>();
    for (Rule activeRule : allActiveRules) {
      if (activeRule instanceof PatternRule) {
        final SuggestionExtractor extractor = new SuggestionExtractor();
        suggestionTokens.addAll(extractor.getSuggestionTokens(activeRule, language));
      }
    }
    return suggestionTokens;
  }
View Full Code Here

TOP

Related Classes of org.languagetool.rules.spelling.SuggestionExtractor

Copyright © 2018 www.massapicom. 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.