Jape file to find the pattern in the sentence

I need to annotate part of a sentence if the words I wrote in my jape rule appear in the same sentence. For example, the sentence: "The child cannot resist any changes in his routine." I put words like resistance in the "trouble.lst" file and the changes in the "alteration.lst" file. Now in this proposal I need to annotate the "resist any changes" part as "A3b". I tried using the below code, but it doesn't address words in the same sentence. My jape rule takes words from different sentences. Suppose resist is included in one clause and changed in some other later clause, so this code annotates that as well. Can anyone help me solve this?

Phase:secondpass
Input: Lookup
Options: control = brill

Rule: A3b
({Lookup.majorType == "trouble"}
{Lookup.majorType == "alteration"}
):label
-->
:label.A3b = {rule= "A3b"}

      

+3


source to share


2 answers


In such cases, you cannot use Context Operators , for example {X within Y}

, because they only work for one annotation, not a sequence of annotations.

But you can use a "trick":

  • Include annotations Sentence

    in Input

    .
    This does the main thing. Even if you don't use Sentence

    rules anywhere, it prevents such matches when a new sentence starts somewhere between annotations.
    But this does not interfere with matches where the sentence starts at the same point as the annotation itself.

  • Prevent any sentence from starting at the same point as the second annotation using the !

    : operator {Lookup, !Sentence}

    .



Phase: secondpass 
Input: Lookup Sentence 
Options: control = brill

Rule: A3b 
(
    {Lookup.majorType == "trouble"}
    {Lookup.majorType == "alteration", !Sentence}
):label 
--> :label.A3b = {rule= "A3b"}

      

+1


source


In addition to annotations Sentence

covering the sentences themselves, the sentence splitter also creates annotations Split

at the boundaries of the sentence. If you include Split

in a string Input

, but do not specify {Split}

in a rule, it will prevent a match that crosses the sentence boundary.

Phase: secondpass
Input: Lookup Split
Options: control = brill

Rule: A3b
({Lookup.majorType == "trouble"}
 {Lookup.majorType == "alteration"}
):label
--> :label.A3b = {rule= "A3b"}

      



The way it works is that the string Input

defines which annotations the JAPE compliant element can see - if the issue and change annotations Lookup

are in different sentences, then the match will see a sequence {Lookup}{Split}{Lookup}

that doesn't match the rule it wants {Lookup}{Lookup}

.

+2


source







All Articles