Back to LanguageTool Homepage - Privacy - Imprint

How to remove last letter and order replacements


#1

HI,

I want to create a rule which removes the last letter.
What I mean.

Let's say the user enters:

Setes

I want the suggested replacement to be Sete.

Also, if right now (with the existing rules) , I enter:

Malos , the suggested replacement is Male.

I want first, to apply my rule and the suggested replacement be Malo and then Male.

Finally, if all the above are set, will it work for two words also?
For example Hello Malos , the replacement will be Hello Malo.

Thank you!


(Mike Unwalla) #2

I guess that you mean you want to replace a word with a different inflection. Refer to http://wiki.languagetool.org/development-overview#toc17

I do not know how you can do the other things you asked about.

This rule removes the last letter of a word:

<rule id="REMOVE_LAST_LETTER" name="'Remove last letter">
 <pattern>
  <token regexp="yes">[a-zA-Z]+[a-zA-Z]</token>
 </pattern>
 <message>You entered '\1'. Use <suggestion><match no="1" regexp_match="^([a-zA-Z]+)[a-zA-Z]" regexp_replace="$1" /></suggestion></message>
 <short>Remove last</short>
 <example>A, 234.</example>
 <example correction="Remove">2) <marker>Removes</marker>.</example>
</rule>

But, the rule causes testrules to give an error message, and I don't know how to prevent that error message:

Running pattern rule tests for English... Exception in thread "main" java.lang.AssertionError: Incorrect input:
  2) Removes.
Corrected sentence:
  2) Remove.
By Rule:
  REMOVE_LAST_LETTER[1]
The correction triggered an error itself:
  REMOVE_LAST_LETTER:3-9:You entered 'Remove'. Use <suggestion>Remov</suggestion>

#3

Thanks for the suggestions.

In the example tag, you have 2) after the "Remove">.
Maybe this causes the error?(Just noticed, I am not at all experienced).

2) Removes.


(Mike Unwalla) #4

The text in the marker is what the rule finds. The text in the correction is the corrected text. But, look at the testrules error message. The corrected text 'Remove' causes another error.