Back to LanguageTool Homepage - Privacy - Imprint

[en] Connect AnalyzedTokenReadings

Hello,

I am currently working on fixing a bug in BritishReplaceRule (and other identical rules). The problem is that 2-word American expressions are not detected by LanguageTool. I studied the code and I found that the cause of the problem is detected in the lines below (from the class AbstractSimpleReplaceRule):

image

As each tokenReading in the tokens array refers to a single word of the sentence.

So my question is: is there a way that two AnalyzedTokenReadings can be connected (in order to refer to 2 words)?

I think the fix might be to extend AbstractSimpleReplaceRule2 instead of AbstractSimpleReplaceRule.

This change was done recently for some Portuguese rules. See an example here: https://github.com/languagetool-org/languagetool/commit/f29ebd4425f9f5b73da70ddbe2a59ae04c78bc93

Thank you both very much! You made my life easier :slight_smile:

Could you please give me an example why is the below method necessary?

image

Do I have to add it to English too?

Example. You have a rule (in French, Spanish…) that suggests replacements for common anglicisms (i.e. ‘look’), but you want some proper nouns to be exceptions (i.e. Look Inc, added to multiwords.txt).

Use it if you need it.

Thanks a lot! Also, I would like to ask how the $match here works, It’s a bit irrelevant but I haven’t seen it before and it drew my interest.
image