LanguageToolAnnotator

The LanguageToolAnnotator is an annotator that connects to a LanguageTool server that provides a proofreading service that identifies many grammatical and stylistic issues.

Prerequisites

You will need to have your own instance of the LanguageTool Http Server to use this annotator.

LanguageAnnotations must be available for the LanguageToolAnnotator to provide feedback.

For development purposes you could use a (community-contributed) LanguageTool Docker image that serves the LanguageTool HTTP Server. View the Docker section in the LanguageTool GitHub repository for the relevant links.

Configuration

The must be configured with a baseUrl and with at least one mapping element. The annotator comes with build in configuration for spelling and grammar suggestions. Additionally, the annotator can be configured with custom mappings.

Attribute

Description

Required

Default

baseUrl

The URL to the LanguageTool HTTP Server check endpoint.

E.g.: https://my-languagetool-instance:8010/v2/

This attribute also supports environment variables.

Yes

N/A

Grammar & spelling

The annotator comes with build in configuration for spelling and grammar suggestions. You will need to use the elements spellingErrorMapping and grammarErrorMapping to enable these suggestions.

Attribute

Description

Required

Default

categories

A list of LanguageTool categories.

Yes

N/A

The editor configuration for the build in spelling and grammar annotation types are available as an add-on: fontoxml-content-quality-languagetool.

Custom mappings

Custom mappings can be used when you have configured LanguageTool with additional rules that you would like to use with a different type of annotation other than spelling or grammar. You will need to use the mapping element for that.

Attribute

Description

Required

Default

AnnotationTypeId

The type identifier to set on the added annotations.

Yes

N/A

categories

A list of LanguageTool categories.

Yes

N/A

Visit the LanguageTool Development Overview to learn how to configure custom rules so you can use them in custom mappings.

Produces

Annotation types

Namespace

Name

urn:fontoxml:fcq:annotations:language-tool:1.0.0

grammar-error

urn:fontoxml:fcq:annotations:language-tool:1.0.0

spelling-error

Additionally, the custom configured (using the custom mappings) annotation type identifiers will be returned.

Metadata

Other

{
	{ "message", "[A message explaining the error]" },
	{ "shortMessage", "[An optional shorter version of the message]" },
	{ "replacements", ["a", "list", "of", "suggested", "replacements"] }
}

Example configuration

The LanguageToolAnnotator must be configured with at least one mapping. In the following example both the spelling and grammar features are enabled and a custom mapping is added.

XML

<languageToolAnnotator baseUrl="https://my-languagetool-instance:8010/v2/">
	<spellingErrorMapping categories="TYPOS"/>
	<grammarErrorMapping categories="CASING COMPOUNDING CONFUSED_WORDS GRAMMAR MISC REDUNDANCY SEMANTICS"/>
	<mapping annotationTypeId="simplified-technical-english" categories="STE_RULE_1_1" />
</languageToolAnnotator>