JAPE规则句子包含多个案例

JAPE规则句子包含多个案例

本文介绍了JAPE规则句子包含多个案例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何检查一个句子是否包含组合?例如考虑句子.约翰被任命为Google的新首席执行官.我需要写一条规则来检查句子是否包含<'new'+'Jobtitle'>.我怎么能做到这一点.我尝试了以下.我需要检查字词前面是否有新"字.

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"}
    }
)

推荐答案

一种解决方法是将其还原.专注于您需要的顺序,然后获得涵盖句:

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

您可以使用以下内容:

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

然后在Java RHS中获取句子(如果确实需要):

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);

这篇关于JAPE规则句子包含多个案例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 05:00