I have a rulegroup that finds any inflection of the word ‘disburse’ when it should probably be ‘disperse’ by identifying trigger words in the same sentence. The first rule finds ‘disburse’ in front of certain other words in the sentence and the second after those words. Is there a way to do this with just one rule and not two?
<rule>
<pattern>
<marker><token inflected="yes" regexp="yes" skip='-1'>disburse</token></marker>
<token regexp="yes">crowds?|people|seeds|widely|protesters|demonstrators?|rioters|groups|demonstrations?|</token>
</pattern>
<message><suggestion><match no="1" postag="(V.*)" postag_regexp="yes" postag_replace="$1">disperse</match></suggestion></message>
</rule>
<rule>
<pattern>
<token regexp="yes" skip='-1'>crowds?|people|seeds|widely|protesters|demonstrators?|rioters|groups|demonstrations?|</token>
<marker><token inflected="yes" regexp="yes">disburse</token></marker>
</pattern>
<message><suggestion><match no="1" postag="(V.*)" postag_regexp="yes" postag_replace="$1">disperse</match></suggestion></message>
</rule>
dnaber
(Daniel Naber)
May 14, 2021, 7:07pm
2
I don’t think so, but <or>
(Development Overview | dev.languagetool.org ) could maybe make the rule more compact.
The rule “wrong word in context” does this in a more compact way. You need to add a line to this file:
#word1 word2 match1 match2 context1 context2 [explanation1 explanation2]
#do not forget to add tests to EnglishWrongWordInContextRuleTest.java
# proscribe/prescribe
prescribe[ds]? proscribe[sd]? prescr proscr medication|medicine|antibiotics|doctors? theft|murder to recommend or authorize to forbid, to limit or to banish
heroin heroine oin oine addict.*|morphine|drug|narcotics?|withdrawal literature|novels?|author|story|poems?|play|female|dramatic|statue|heroes? highly addictive narcotic the chief female character; a woman admired for great deeds
bazaar bizarre azaar izarre oriental|marketplace|rummage|goods|buy|bought|sell|sold moment|odd|unusual|incident|behaviou?r|situations?|stor(y|ies)|reasons?|moments? a marketplace (noun) unusual, odd, or whimsically strange (adjective)
bridal bridle ridal ridle weddings?|brides?|boutique|gowns?|church|party|shower|shop|jewellery|dress|fashion horses?|cavalier|harness|headgear|headstall|rider?s? related to a bride a part of a horse's harness
desserts? deserts? esse ese chocolate|menu|wait(ers?|ress)|cookies|cakes? bec[ao]me|dry|arid|vegetation|camels?|precipitation|rain a confectionery course that concludes a main meal a barren area of landscape with little precipitation
statutes? statues? ute ue government|legislat(ure|ive)|laws?|senators?|regulat(ions?|ed?|ing)|Republicans?|Democrats?|limitations life-size|figur(ative|ine)|sculptur(ing|ed?)|modeling|art(ist)|temples?|marble|bronze|Gree(k|ce) a formal written enactment of a legislative authority a sculpture; a carved or shaped imitation of an object
gorilla guerilla o ue apes?|chimpanzees?|bonobos?|[Ss]ilverback|zoos? marketing|war(fares?)?|insurgents?|soldiers?|army|(para)?military|ambush(ed)? animal in ape family soldier specializing surprise attacks
massage message ma me Thai|relaxing|naked|therap(eutic|y|ist)|prostate|erotic|tantric|lymphatic|muscles? error|send(ing)?|receive[dr]?|important|take|writ(e|ten) action of rubbing, kneading or hitting someone's body communication, or what is communicated
sing sign ing ign songs?|music|choirs? contracts? to produce musical or harmonious sounds with one’s voice to write one's signature
neutrons? neurons? utr ur [fF]ermion(ic)?|[pP]rotons?|[Aa]tom(s?|ic)|[Ee]lectrons?|[nN]uclear|[Ss]pins?|hadron(ic)?|[tT]hermal|bound ganglia|axons?|dendrits?|nervous|synapses?|stimul(i|us)|nerves?|neurotransmitters?|cerebral|(bi|uni)polar subatomic particle nerve cell
hangars? hangers? gar ger air(craft|plain)s?|aeroplains?|planes? cloth(es?|ing)|coats?|garments? shed or shelter a frame for hanging clothes
But if you need specific exceptions later, you will be better off with the two XML rules.