Examples of AnalyzedSentence


Examples of org.languagetool.AnalyzedSentence

  }

 
  private RuleMatch[] getMatches(final Rule rule, final String sentence,
      final JLanguageTool languageTool) throws IOException {
    final AnalyzedSentence text = languageTool.getAnalyzedSentence(sentence);
    final RuleMatch[] matches = rule.match(text);
    return matches;
  }
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

        "/[null]SENT_START Je/[je]R pers suj 1 s  /[null]null suis/[suivre]V imp pres 2 s|suis/[suivre]V ind pres 1 s|suis/[suivre]V ind pres 2 s|suis/[être]V etre ind pres 1 s  /[null]null petite/[petit]J f s|petite/[petit]N f s ./[null]null",
        tokenizer, sentenceTokenizer, tagger, disamb2);
  }

  public void testAnnotations() throws IOException {
     final AnalyzedSentence sent = lt.getAnalyzedSentence("Les avions");
     assertEquals(sent.getAnnotations(), "Disambiguator log: \n\n" +
        "RP-D_N_AMBIG:1 Les[le/D e p*,les/R pers obj 3 p*] -> Les[le/D e p*]"+
             "\nRB-LE_LA_LES:1 Les[le/D e p*] -> Les[le/D e p*]" +
        "\n\nRP-D_N_AMBIG:1 avions[avoir/V avoir ind impa 1 p,avion/N m p,avoir/SENT_END] -> avions[avion/N m p,avoir/SENT_END]\n");
  }
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

      // tag text
      final List<String> sentences = langTool.sentenceTokenize(textArea.getText());
      final StringBuilder sb = new StringBuilder();
      try {
        for (String sent : sentences) {
          final AnalyzedSentence analyzedText = langTool.getAnalyzedSentence(sent);
          final String analyzedTextString = StringTools.escapeHTML(analyzedText.toString(", ")).
                  replace("[", "<font color='#888888'>[").replace("]", "]</font>");
          sb.append(analyzedTextString).append("\n");
        }
      } catch (Exception e) {
        sb.append(getStackTraceAsHtml(e));
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

public class MultiWordChunkerTest extends TestCase {

  public void testDisambiguate() throws Exception {
    final Disambiguator chunker = new MultiWordChunker("/pl/multiwords.txt");
    final JLanguageTool lt = new JLanguageTool(new English());
    final AnalyzedSentence analyzedSentence = lt.getAnalyzedSentence("A test... More.");
    final AnalyzedSentence disambiguated = chunker.disambiguate(analyzedSentence);
    final AnalyzedTokenReadings[] tokens = disambiguated.getTokens();
    assertTrue(tokens[4].getReadings().toString().contains("<ELLIPSIS>"));
    assertTrue(tokens[6].getReadings().toString().contains("</ELLIPSIS>"));
  }
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

      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) {
            suggestionTokens.add(token);
          } else {
            //System.out.println("No error matches for " + lang + ": " + token);
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

  }
 
  private RuleMatch[] 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);
    return rule.match(srcText, trgText);   
  }
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

Examples of org.languagetool.AnalyzedSentence

  }

 
  private RuleMatch[] getMatches(final Rule rule, final String sentence,
      final JLanguageTool languageTool) throws IOException {
    final AnalyzedSentence analyzedSentence = languageTool.getAnalyzedSentence(sentence);
    final RuleMatch[] matches = rule.match(analyzedSentence);
    return matches;
  }
View Full Code Here

Examples of org.languagetool.AnalyzedSentence

    // error not found here as it's in the XML rules:
    //assertBad("Das gilt ohne wenn und aber.");
  }
 
  public void testCompareLists() throws IOException {
    AnalyzedSentence sentence1 = langTool.getAnalyzedSentence("Hier ein Test");
    assertTrue(rule.compareLists(sentence1.getTokensWithoutWhitespace(), 0, 2, new String[]{"", "Hier", "ein"}));
    assertTrue(rule.compareLists(sentence1.getTokensWithoutWhitespace(), 1, 2, new String[]{"Hier", "ein"}));
    assertTrue(rule.compareLists(sentence1.getTokensWithoutWhitespace(), 0, 3, new String[]{"", "Hier", "ein", "Test"}));
    assertFalse(rule.compareLists(sentence1.getTokensWithoutWhitespace(), 0, 4, new String[]{"", "Hier", "ein", "Test"}));

    AnalyzedSentence sentence2 = langTool.getAnalyzedSentence("das Heilige Römische Reich");
    assertTrue(rule.compareLists(sentence2.getTokensWithoutWhitespace(), 0, 4, new String[]{"", "das", "Heilige", "Römische", "Reich"}));
    assertFalse(rule.compareLists(sentence2.getTokensWithoutWhitespace(), 8, 11, new String[]{"", "das", "Heilige", "Römische", "Reich"}));
  }
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.