python does not correct custom rules


I have created some custom rules and written them in the grammar.xml file. I was trying to see whether these rules were correct by using python.

when using tool.check(text), it shows the list of mistakes found in the input text. Here, I can also see that it spotted my custom rules. However, when using tool.correct(text) only some of the mistakes are corrected (none of them being any of my custom rules). How can I make python correct all the mistakes found in the text?


Not sure which Python script you’re referring to? It’s probably not provided by LT, so I think you’ll need to ask the Python script’s vendor.

The language-tool-python package allows to check a given text and apply the suggested corrections automatically. language-tool-python · PyPI
I wrote my custom rules into the grammar.xml file, if I do tool.check(text), they appear as errors. However, when using tool.correct(text), these mistakes are not corrected, while the rules that already come in grammar.xml are corrected.
For example, here I want to change a passive sentence for an active one change the date format.

import language_tool_python
tool = language_tool_python.LanguageTool(‘es’)
text = ‘El gerente fue despedido el 16-03-2023.’
matches = tool.check(text)

Offset 0, length 24, Rule ID: PASIVA
Message: No utilices la voz pasiva. Utiliza la voz activa.
El gerente fue despedido el 16-03-2023.
Offset 28, length 10, Rule ID: FECHAS
El gerente fue despedido el 16-03-2023.

The errors are correctly recognised, based on my custom rules, but these suggestions are not applied to the text.