I want to create a rule that flags the token Catch-22 (but only when capped up) when the word “novel” doesn’t appear anywhere in the same sentence. I thought this would work but it doesn’t.
<rule>
<token skip="-1"><exception>novel</exception></token>
<pattern case_sensitive="yes">
<token regexp="yes">Catch-22</token>
</pattern>
</rule>
Just following up my query above, I think I have managed to solve the problem with this rule. I don’t know if anybody has a more elegant solution
<pattern case_sensitive="yes">
<token postag="SENT_START" skip="-1"><exception scope="next" regexp="yes">novel</exception></token>
<marker>
<token skip="-1" regexp="yes">Catch-? ?22<exception scope="next" regexp="yes">novel</exception></token>
</marker>
<token postag="SENT_END"><exception scope="current" regexp="yes">novel</exception></token>
</pattern>
@Maximum, this alternative solution uses an antipattern.
<rule id="CATCH22" name="Catch-22">
<antipattern>
<token skip="-1" postag="SENT_START"/>
<token skip="-1" regexp="yes">novel|book</token>
<token postag="SENT_END"/>
</antipattern>
<pattern>
<token case_sensitive="yes">Catch-22</token>
</pattern>
<message>Found it.</message>
<example correction="">This is a bit of a <marker>Catch-22</marker> situation.</example>
<example correction="">Did you read the story <marker>Catch-22</marker> last week?</example>
<example>This is a bit of a <marker>catch-22</marker> situation.</example>
<example>Who wrote the novel called "Catch-22"?</example>
<example>Catch-22 is a famous book.</example>
</rule>
This is really great… thanks.