Problem loading rule's txt only one time

Hello,

I recently created the AbstractSpecificCaseRule. But as @dnaber said the txt file should not be loaded every time the rule constructor is called.

And here is the problem, I guess the solution to this would be to make loadPhrases() method static. But it uses the path that is defined in the subclasses (the SpecificCaseRule of each language), so I cannot call the abstract getPhrasesPath() method from the static loadPhrases() .

How could I overcome this adversity?

Thank you very much in advance!

Just curious: what does this rule do?

Hello @Ruud_Baars !

SpecificCaseRule detects phrases that must be written with a specific capitalization. Here you can find the txt file that contains the english specific case expressions, so you can see some examples.

You could try using org.languagetool.rules.spelling.CachingWordListLoader (see the other code locations where it’s used for examples).

Thanks. I understand now. It could be useful for Dutch as well.

Thank you @dnaber, I looked at it but it was more difficult than I expected unfortunately. I will work more on it on Tuesday, when I will have more time, and I hope I’ll get it done.

Possibly yes! Personally I don’t speak Dutch but it’s a rule easily extensible.

Thanks for the help @dnaber! Initially, I thought that using CachingWordListLoader I could somehow load the phrases only one time, but this wasn’t the case in the end.