Thanks Marcin. The rule works fine in the grammar file.

Can I use antipatterns in the disambiguation file? With the rule that
follows, testrules gives this error:
Invalid content was found starting with element 'antipattern'. One of
'{pattern}' is expected.

    <rule id="disambiguation-antipattern" name="disambiguation-antipattern">
      <antipattern>
      <marker>
        <token skip="-1">happy</token>
        <token>cat</token>
      </marker>
      </antipattern>
      <pattern>
        <token>cat</token>
      </pattern>
      <disambig action="add"><wd pos="MYPOS"/></disambig>
      <example type="untouched">The <marker>happy cat</marker> sat on the
mat.</example>
      <example type="untouched">The <marker>happy and fat cat</marker> sat
on the mat.</example>
      <example type="ambiguous" inputform="cat[cat/NN,cat/VB,cat/VBP]"
outputform="cat[cat/MYPOS,cat/NN,cat/VB,cat/VBP]">The <marker>cat</marker>
sat on the mat.</example>
    </rule>

> Maybe we should change the default behavior (implying only a marker around
"happy") as it may be quite confusing. I simply solved the problem by always
using markers.

If changing the behaviour is easy, then yes. Alternatively, in the
documentation about antipatterns, explain that markers are necessary. (And
also, if antipatterns can be in only the grammar file, say so.) To know what
cannot be done is almost as important as to know what can be done.

Regards,

Mike Unwalla
Contact: www.techscribe.co.uk/techw/contact.htm 


-----Original Message-----
From: Marcin Milkowski [mailto:list-addr...@wp.pl] 
Sent: 07 April 2014 20:18
To: languagetool-devel@lists.sourceforge.net
Subject: Re: Antipatterns

W dniu 2014-04-07 19:23, Mike Unwalla pisze:
> Hello All,
>
> When I run testrules against this rule in LT 2.5, testrules does not give
an
> error message:
>
>   <rule id="antipattern" name="antipattern">
>        <antipattern>
>          <token skip="-1">happy</token>
>          <token>cat</token>
>        </antipattern>
>        <pattern>
>          <token>cat</token>
>        </pattern>
>        <message>The word 'happy' does not come anywhere before the word
> 'cat'.</message>
>        <short>antipattern</short>
>        <example type="correct">The <marker>happy cat</marker> sat on the
> mat.</example>
> <!--      <example type="correct">The <marker>happy and fat cat</marker>
sat
> on the mat.</example>-->
>        <example type="incorrect">The lazy <marker>cat</marker> sat on the
> mat.</example>
>        <example type="incorrect">The <marker>cat</marker> is
happy.</example>
>      </rule>
>
> But, when I remove the comments from the second 'correct' example,
testrules
> gives an error message:
> ... Did not expect error in: The happy and fat cat sat on the mat. (Rule:
> antipattern[1]:[cat]:antipattern)
>
> http://wiki.languagetool.org/development-overview#toc12 states "You can
use
> all subelements of 'pattern' in 'antipattern' but 'phrase' and 'or'."
>
> 1. Is the antipattern correct [LT has a bug] or is the documentation
> incorrect?
> 2. If <token skip="-1"> is not correct, shouldn't testrules give an error?

Well, <antipattern> is simply a disambiguation immunizing rule, and 
disambiguation rules by default take effect only on the first token if 
no markers are given. Use explicit markers, and you'll get what you want:

        <antipattern>
                 <marker>
                 <token skip="-1">happy</token>
                 <token>cat</token>
                 </marker>
         </antipattern>

Maybe we should change the default behavior (implying only a marker 
around "happy") as it may be quite confusing. I simply solved the 
problem by always using markers.

Regards,
Marcin

----------------------------------------------------------------------------
--
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Languagetool-devel mailing list
Languagetool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/languagetool-devel


------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Languagetool-devel mailing list
Languagetool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/languagetool-devel

Reply via email to