[SOLVED] Check spelling and grammar for the content of an XML file

Hi,

I’d like to use LanguageTool to check the spelling and grammar for the text contained in an XML file, adjusting error positions so they refer to the original text including markup.

Example 1:

<text>A sentences</text>

Example 2:

<text><bold>A</bold> sentences</text>

For “Example 1” I’ve managed to do this by calling the method check(String) of the class org.languagetool.JLanguageTool

But for “Example 2” this didn’t work (no errors were detected). I suppose the reason is that “A” is nested inside the “” element.

Which is the best way to analyze a text (containing markup) with LanguageTool adjusting error positions so they refer to the original text including markup?

Thanks in advance.

You can use AnnotatedTextBuilder (LanguageTool 6.0 API) to get an AnnotatedText object which can then be checked. Markup will be ignored.

Thanks! That’s exactly what I was looking for.