Examples of AnalyzedSentence


Examples of org.languagetool.AnalyzedSentence

  }

  private AnalyzedSentence getSentenceWithImmunization(AnalyzedSentence sentence) throws IOException {
    if (antiPatterns != null && !antiPatterns.isEmpty()) {
      //we need a copy of the sentence, not reference to the old one
      AnalyzedSentence immunizedSentence = sentence.copy(sentence);
      for (final DisambiguationPatternRule patternRule : antiPatterns) {
        immunizedSentence = patternRule.replace(immunizedSentence);
      }
      return immunizedSentence;
    }
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

    isr.close();
  }

  private 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(getSentence(analyzedText));
    }
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

        changed = true;
      }
      i++;
    }
    if (changed) {
      return new AnalyzedSentence(whTokens, sentence.getWhPositions());
    }
    return sentence;
  }
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

    this.language = Objects.requireNonNull(language);
  }

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

Examples of org.languagetool.AnalyzedSentence

  }

  @Test
  public void testContractions() throws Exception {
    JLanguageTool langTool = new JLanguageTool(new English());
    AnalyzedSentence analyzedSentence = langTool.getAnalyzedSentence("I'll be there");
    AnalyzedTokenReadings[] tokens = analyzedSentence.getTokens();
    assertThat(tokens[1].getChunkTags().get(0), is(new ChunkTag("B-NP-singular")));
    assertThat(tokens[2].getChunkTags().size(), is(0))// "'" cannot be mapped as we tokenize differently
    assertThat(tokens[3].getChunkTags().size(), is(0))// "ll" cannot be mapped as we tokenize differently
    assertThat(tokens[5].getChunkTags().get(0), is(new ChunkTag("I-VP")));
  }
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

  private void assertBad(String sentence) throws IOException {
    assertMatches(sentence, 1);
  }

  private void assertMatches(String sentence, int expectedMatches) throws IOException {
    AnalyzedSentence aSentence = langTool.getAnalyzedSentence(sentence);
    assertThat(rule.match(aSentence).length, is(expectedMatches));
  }
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.