When checking longer strings, the error formatting was done as follows:
from language_tool_python import LanguageTool
language_tool = LanguageTool("en-US")
text = "Write or paste your text here to have it checked continuously. Errors will be underlined in different colours: we will mark spelling errors with red underlines. Furthermore grammar error's are highlighted in yellow. "
matches = language_tool.check(text)
for m in matches:
print(m)
Output:
Offset 102, length 7, Rule ID: MORFOLOGIK_RULE_EN_US
Message: Possible spelling mistake. ‘colours’ is British English.
Suggestion: colors
... Errors will be underlined in different colours: we will mark spelling errors with red ...
^^^^^^^
Offset 161, length 11, Rule ID: SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA
Message: Did you forget a comma after a conjunctive/linking adverb?
Suggestion: Furthermore,
...rk spelling errors with red underlines. Furthermore grammar error's are highlighted in yell...
^^^^^^^^^^^
Offset 181, length 7, Rule ID: APOSTROPHE_PLURAL
Message: Consider using the plural form here: “errors”.
Suggestion: errors
...ith red underlines. Furthermore grammar error's are highlighted in yellow.
^^^^^^^
The problem was that the offset regarding the whole text is used for printing the error markers instead of the offset in context.
With changing the error indicators to be offset by self.offsetInContext the output now is the following:
Offset 102, length 7, Rule ID: MORFOLOGIK_RULE_EN_US
Message: Possible spelling mistake. ‘colours’ is British English.
Suggestion: colors
... Errors will be underlined in different colours: we will mark spelling errors with red ...
^^^^^^^
Offset 161, length 11, Rule ID: SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA
Message: Did you forget a comma after a conjunctive/linking adverb?
Suggestion: Furthermore,
...rk spelling errors with red underlines. Furthermore grammar error's are highlighted in yell...
^^^^^^^^^^^
Offset 181, length 7, Rule ID: APOSTROPHE_PLURAL
Message: Consider using the plural form here: “errors”.
Suggestion: errors
...ith red underlines. Furthermore grammar error's are highlighted in yellow.
^^^^^^^
When checking longer strings, the error formatting was done as follows:
Output:
The problem was that the offset regarding the whole text is used for printing the error markers instead of the offset in context.
With changing the error indicators to be offset by
self.offsetInContext
the output now is the following: