Package org.languagetool.markup
Class AnnotatedTextBuilder
java.lang.Object
org.languagetool.markup.AnnotatedTextBuilder
Use this builder to create input of text with markup for LanguageTool, so that it
can check only the plain text parts and ignore the markup, yet still calculate the
positions of errors so that they refer to the complete text, including markup.
It's up to you to split the input into parts that are plain text and parts that are markup.
For example, text with XML markup like
Here is <b>some text</b>
needs to be prepared like this:
new AnnotatedTextBuilder() .addText("Here is ").addMarkup("<b>").addText("some text").addMarkup("</b>") .build()
- Since:
- 2.3
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddGlobalMetaData
(String key, String value) Add any global meta data about the document to be checked.addGlobalMetaData
(AnnotatedText.MetaDataKey key, String value) Add global meta data like document title or receiver name (when writing an email).Add a markup text snippet like<b attr='something'>
or<div>
.Add a markup text snippet like<b attr='something'>
or<div>
.Add a plain text snippet, to be checked by LanguageTool when usingJLanguageTool.check(AnnotatedText)
.build()
Create the annotated text to be passed intoJLanguageTool.check(AnnotatedText)
.private boolean
hasFakeContent
(int i, List<TextPart> parts)
-
Field Details
-
parts
-
metaData
-
customMetaData
-
-
Constructor Details
-
AnnotatedTextBuilder
public AnnotatedTextBuilder()
-
-
Method Details
-
addGlobalMetaData
Add global meta data like document title or receiver name (when writing an email). Some rules may use this information.- Since:
- 3.9
-
addGlobalMetaData
Add any global meta data about the document to be checked. Some rules may use this information. Unless you're using your own rules for which you know useful keys, you probably want to useaddGlobalMetaData(AnnotatedText.MetaDataKey, String)
.- Since:
- 3.9
-
addText
Add a plain text snippet, to be checked by LanguageTool when usingJLanguageTool.check(AnnotatedText)
. -
addMarkup
Add a markup text snippet like<b attr='something'>
or<div>
. These parts will be ignored by LanguageTool when usingJLanguageTool.check(AnnotatedText)
. -
addMarkup
Add a markup text snippet like<b attr='something'>
or<div>
. These parts will be ignored by LanguageTool when usingJLanguageTool.check(AnnotatedText)
.- Parameters:
interpretAs
- A string that will be used by the checker instead of the markup. This is usually whitespace, e.g.\n\n
for<p>
-
build
Create the annotated text to be passed intoJLanguageTool.check(AnnotatedText)
. -
hasFakeContent
-