3

How can i check whether a sentence contain combinations? For example consider sentence. John appointed as new CEO for google. I need to write a rule to check whether sentence contains < 'new' + 'Jobtitle' >. How can i achieve this. I tried following. I need to check is there 'new' before word .

Rule: CustomRules
(
    {
        Sentence contains {Lookup.majorType == "organization"},
        Sentence contains {Lookup.majorType == "jobtitle"},
        Sentence contains {Lookup.majorType == "person_first"}
    }
) 
Vaisakh
  • 1,088
  • 1
  • 8
  • 14
  • See following question. It alows you to limit a JAPE patern to match within a single sentece only. Then you can select the coreponding sentence using another JAPE. http://stackoverflow.com/questions/29198611/jape-file-to-find-the-pattern-within-a-sentence – dedek May 14 '15 at 13:30

1 Answers1

2

One way to handle this is to revert it. Focus on the sequence you need and then get the covering Sentence:

(
  {Token@string == "new"}
  {Lookup.majorType = "jobtitle"}
):newJT

You should check this edge when the Sentence starts after "new", like this:

new

CEO

You can use something like this:

{Token ... }
{!Sentence, Lookup.majorType ...}

And then get the sentence (if you really need it) in the java RHS:

long end = newJTAnnots.lastNode().getOffset();
long start = newJTAnnots.firstNode().getOffset();
AnnotationSet sentences = inputAS.get("Sentence", start, end);
Yasen
  • 1,663
  • 10
  • 17