Thanks Paolo. You gave me an idea for a solution for the real problem that I
am trying to solve. 

Previously, I wrote:
What is the correct behaviour of a rule that has skip="-1" when you want to
find a pair of tokens that comes after the skip?
 1. John looked at both the 'incorrect' example as well as the 'correct'
example.
 2. John looked at both the 'as if' example as well as the 'correct'
example.

LT does not find 'as well as' in sentence 2. Is this a bug or is it by
design? (If it's a bug, then I will file a bug report. If it is by design,
then I will try to find solution to the real problem.)

Regards,

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


-----Original Message-----
From: Paolo Bianchini [mailto:[email protected]] 
Sent: 10 April 2013 10:45
To: development discussion for LanguageTool
Subject: Re: Skip="-1" with 2 tokens to match after the skip

Try this:


<rule id="skip-test" name="skip test">
     <pattern>
       <token skip="-1">saw</token>
       <marker>
        <token skip="-1">cat<exception regexp="yes"
scope="previous">[^f][^a][^t].*</exception></token>
       </marker>
     </pattern>
     <message>Fat cat!</message>
     <short>Fat cat!</short>
     <example type="correct">The boy saw the cat.</example>
     <example type="correct">The boy saw the fat and smiling cat.</example>
     <example type="correct">The boy saw the fat in the frying
pan.</example>
     <example type="incorrect">The boy saw the fat
<marker>cat</marker>.</example>
     <example type="incorrect">The boy saw the smiling and fat
<marker>cat</marker>.</example>
     <example type="incorrect">The boy saw Peter and his fat
<marker>cat</marker>.</example>
     <example type="incorrect">The boy saw the fat in the frying pan and the
fat <marker>cat</marker>.</example>
   </rule>

Ciao

Paolo



On Apr 10, 2013, at 9:38 AM, Mike Unwalla wrote:

> Hi All,
> 
> What is the correct behaviour of a rule that has skip="-1" when you want
to find a pair of tokens that comes after the skip?
> 
> 1. John looked at both the 'incorrect' example as well as the 'correct'
example.
> 2. John looked at both the 'as if' example as well as the 'correct'
example.
> 
> The English grammar rule id="BOTH_AS_WELL_AS" finds "as well as" in
sentence 1, but not in sentence 2.
> 
> I wrote this test rule:
> 
>    <rule id="skip-test" name="skip test">
>      <pattern>
>        <token skip="-1">saw</token>
>        <marker>
>          <token>fat</token>
>          <token>cat</token>
>        </marker>
>      </pattern>
>      <message>Fat cat!</message>
>      <short>Fat cat!</short>
>      <example type="correct">The boy saw the cat.</example>
>      <example type="correct">The boy saw the fat and smiling
cat.</example>
>      <example type="correct">The boy saw the fat in the frying
pan.</example>
>      <example type="incorrect">The boy saw the <marker>fat
cat</marker>.</example>
>      <example type="incorrect">The boy saw the smiling and <marker>fat
cat</marker>.</example>
>      <example type="incorrect">The boy saw Peter and his <marker>fat
cat</marker>.</example>
>      <example type="incorrect">The boy saw the fat in the frying pan and
the <marker>fat cat</marker>.</example>
>    </rule>
> 
> Testrules gave this error message:
> 
> Running pattern rule tests for English... Exception in thread "main"
junit.framework.AssertionFailedError: English: Did expect one error in: "The
boy saw the fat in the frying pan and the fat cat." (Rule:
skip-test[1]:[saw, fat, cat]:skip test), but found 0. Additional info:Fat
cat!, Matches: []
> 
> Page www.languagetool.org/development/#skip states, "Using negative value,
we can match until the B is found, no matter how many tokens are skipped."
One interpretation of this sentence is that the rule finds the first
instance of B (rather than the pair BC [fat cat]). Is that interpretation
correct, and if yes, how do I create a rule that finds a pair of tokens that
comes after skip="-1"?
> 
> Regards,
> 
> Mike Unwalla
> Contact: www.techscribe.co.uk/techw/contact.htm 
> 



------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Languagetool-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-devel

Reply via email to