How can i use AND operation on jape grammar?. I just want to check whether a sentence contain 'organisation','jobtitle','person' all together in any order. How it possible? There is '|'(OR) operation allowed but i didnt see any documentation about AND operation.
Asked
Active
Viewed 334 times
1 Answers
3
There isn't an "and" operator like that as such but you could do it with a set of contains
checks:
Rule: OrgTitlePer
({Sentence contains {Organization},
Sentence contains {JobTitle},
Sentence contains {Person}}):sent
-->
:sent.Interesting = {}
When you have several constraints within the same set of braces that involve the same annotation type on the left (Sentence
in this case) then all the constraints must be satisfied simultaneously by the same annotation.

Ian Roberts
- 120,891
- 16
- 170
- 183
-
Thanks dude. It works for me. One more help i needed. I have a custom list, which i need to check whether any of words in that list contains in that sentence. What should i do ? – Vaisakh Sep 03 '14 at 08:12
-
1@Vaisakh use a gazetteer to annotate the list of words with a suitable Lookup and then you can check for `{Sentence contains {Lookup.majorType="whatever"}}` – Ian Roberts Sep 03 '14 at 08:33
-
Yeaahh.. I got it. Thank you Ian Robert. I went through your suggestion and found how to do the same here (http://stackoverflow.com/questions/21711634/how-can-i-add-custom-annotations-to-default-annie-gazetteer) – Vaisakh Sep 03 '14 at 10:17
-
1Can i use a macro in 'Sentence contain' statement ?. I mean like Macro: MULTIPLE ( {Token.string=="new"}{Lookup.majorType=="jobtitle"} ) Rule: CustomRules({Sentence contains MULTIPLE }) – Vaisakh Sep 03 '14 at 10:22
-
1@Vaisakh no, the right hand side of the contains must be a single constraint. If you want to check for a complex pattern you need to use a multi phase grammar, annotate occurrences of the complex pattern in one phase with a temporary annotation type and then check in the second phase for `{Sentence contains {TemporaryAnnotation}}` – Ian Roberts Sep 03 '14 at 10:29