JAPE Rule Sentence contains multiple cases

How can I check if a sentence contains combinations? For example, consider a proposal. John has been named the new CEO of Google. I need to write a rule to check if the sentence contains <'new' + 'Jobtitle'>. How can I achieve this. I've tried following. I need to check if there is a new word before the word.

Rule: CustomRules
(
    {
        Sentence contains {Lookup.majorType == "organization"},
        Sentence contains {Lookup.majorType == "jobtitle"},
        Sentence contains {Lookup.majorType == "person_first"}
    }
) 

      

+3


source to share


1 answer


One way to deal with this is to bring it back. Focus on the consistency you need and then get coverage. Sentence:

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

      

You should check this edge when Sentence starts after "new", for example:

new

CEO

      



You can use something like this:

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

      

And then get a suggestion (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);

      

+2


source







All Articles