Examples of AnalyzedSentence


Examples of org.languagetool.AnalyzedSentence

    if (tokenIter == null || !tokenIter.hasNext()) {
      // there are no remaining tokens from the current sentence... are there more sentences?
      if (input.incrementToken()) {
        // a new sentence is available: process it.
        final AnalyzedSentence sentence = languageTool.getAnalyzedSentence(termAtt.toString());

        final List<AnalyzedTokenReadings> tokenBuffer = Arrays.asList(sentence.getTokens());
        tokenIter = tokenBuffer.iterator();
        /*
         * it should not be possible to have a sentence with 0 words, check just in case. returning
         * EOS isn't the best either, but it's the behavior of the original code.
         */
 
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

    for (ScoreDoc match : topDocs.scoreDocs) {
      final Document doc = indexSearcher.doc(match.doc);
      final String sentence = doc.get(FIELD_NAME);
      final List<RuleMatch> ruleMatches = languageTool.check(sentence);
      if (ruleMatches.size() > 0) {
        final AnalyzedSentence analyzedSentence = languageTool.getAnalyzedSentence(sentence);
        final MatchingSentence matchingSentence = new MatchingSentence(sentence, analyzedSentence, ruleMatches);
        matchingSentences.add(matchingSentence);
      }
    }
    return matchingSentences;
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

      int noErrorCount = 0;
      for (Rule rule : rules) {
        final List<String> tokens = 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) {
            suggestionTokens.add(token);
          } else {
            //System.out.println("No error matches for " + lang + ": " + token);
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

            firstMatchToken, matchingTokens, tokenPositions);
        changed = true;
      }
    }
    if (changed) {
      return new AnalyzedSentence(whTokens, text.getWhPositions());
    }
    return text;
  }
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

                      }
                  }
              }
          }
      }
      return new AnalyzedSentence(output);
  }
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

   * @param contents Text to tag.
   * @param lt LanguageTool instance
   * @throws IOException
   */
  public static void tagText(final String contents, final JLanguageTool lt) throws IOException {
    AnalyzedSentence analyzedText;
    final List<String> sentences = lt.sentenceTokenize(contents);
    for (final String sentence : sentences) {
      analyzedText = lt.getAnalyzedSentence(sentence);
      System.out.println(analyzedText.toString());
    }
  }
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

  * @since 1.0.1
  */
  public static List<RuleMatch> checkBitext(final String src, final String trg,
      final JLanguageTool srcLt, final JLanguageTool trgLt,
      final List<BitextRule> bRules) throws IOException {
   final AnalyzedSentence srcText = srcLt.getAnalyzedSentence(src);
   final AnalyzedSentence trgText = trgLt.getAnalyzedSentence(trg);
   final List<RuleMatch> ruleMatches = trgLt.checkAnalyzedSentence(JLanguageTool.ParagraphHandling.NORMAL,
      trgLt.getAllRules(), 0, 0, 1, trg, trgText);    
    for (BitextRule bRule : bRules) {    
      final RuleMatch[] curMatch = bRule.match(srcText, trgText);
      if (curMatch != null) {
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

  protected abstract Language getLanguage();

  @Override
  public AnalyzedSentence disambiguate(final AnalyzedSentence input) throws IOException {
    AnalyzedSentence sentence = input;
    if (disambiguationRules == null) {
      final String disambiguationFile =
        JLanguageTool.getDataBroker().getResourceDir() + "/" + getLanguage().getShortName() + "/" + DISAMBIGUATION_FILE;
      try {
        disambiguationRules = loadPatternRules(disambiguationFile);
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

        output[i] = new AnalyzedTokenReadings(firstToken, anTokens[i].getStartPos());
      } else {
        output[i] = anTokens[i];
      }
    }
    return new AnalyzedSentence(output);
  }
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

  }
 
  private boolean match(final BitextPatternRule rule, final String src, final String trg,
      final JLanguageTool srcLanguageTool,
      final JLanguageTool trgLanguageTool) throws IOException {
    final AnalyzedSentence srcText = srcLanguageTool.getAnalyzedSentence(src);
    final AnalyzedSentence trgText = trgLanguageTool.getAnalyzedSentence(trg);
    final RuleMatch[] matches = rule.match(srcText, trgText);
    return matches.length > 0;
  }
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.