Back to LanguageTool Homepage - Privacy - Imprint

creating a rule for required text?

How do I create a rule to (a) search for specific text and (b) give the user feedback when that text is NOT in their writing?

For example, I require the user to include the words “civilization” and “development” and “process” in their writing. If all words are included, then they are correct, and receive no feedback. If any of the words are missing, they receive feedback that they are “Missing a key word or phrase.”

It seems like this should be simple, but I cannot find any similar existing rules.

You will need to write Java code for that, as XML rules only work on single sentences. You can implement a TextLevelRule (TextLevelRule (languagetool-parent 5.5 API)) which iterates over the text and returns a RuleMatch if not all required words are found. LongSentenceRule might be a good example.

Thanks for the insights. Right now, the intent is just one sentence at a time. Is there a simple way (using XML) to have it return a RuleMatch if it doesn’t find the required words? It seems like there should be something like a null or ifnull rule, correct?

I’m working on a proof-of-concept for a training tool that would help people practice re-writing sentences more clearly. The idea is to give them automated feedback on their writing style, which requires automated grading. Part of that is including the key words from the original sentence.

Thanks again.

I can’t think of a way with just XML, but maybe somebody else has an idea.