Search in sources :

Example 6 with AnnotatedTextBuilder

use of org.languagetool.markup.AnnotatedTextBuilder in project languagetool by languagetool-org.

the class JLanguageToolTest method testAnnotateTextCheck.

@Test
public void testAnnotateTextCheck() throws IOException {
    JLanguageTool languageTool = new JLanguageTool(english);
    AnnotatedText annotatedText = new AnnotatedTextBuilder().addMarkup("<b>").addText("here").addMarkup("</b>").addText(" is an error").build();
    List<RuleMatch> matches = languageTool.check(annotatedText);
    assertThat(matches.size(), is(1));
    assertThat(matches.get(0).getFromPos(), is(3));
    assertThat(matches.get(0).getToPos(), is(7));
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) AnnotatedTextBuilder(org.languagetool.markup.AnnotatedTextBuilder) AnnotatedText(org.languagetool.markup.AnnotatedText) Test(org.junit.Test)

Example 7 with AnnotatedTextBuilder

use of org.languagetool.markup.AnnotatedTextBuilder in project languagetool by languagetool-org.

the class SimpleCorpus method makeAnnotatedText.

private AnnotatedText makeAnnotatedText(String text) {
    AnnotatedTextBuilder builder = new AnnotatedTextBuilder();
    builder.addText(text.replace("_", " ").replaceAll("\\s+", " "));
    return builder.build();
}
Also used : AnnotatedTextBuilder(org.languagetool.markup.AnnotatedTextBuilder)

Aggregations

AnnotatedTextBuilder (org.languagetool.markup.AnnotatedTextBuilder)7 Test (org.junit.Test)4 AnnotatedText (org.languagetool.markup.AnnotatedText)4 RuleMatch (org.languagetool.rules.RuleMatch)4 HashSet (java.util.HashSet)1 StringTokenizer (java.util.StringTokenizer)1