Jape文件可在句子中找到模式 [英] Jape file to find the pattern within a sentence

查看:100
本文介绍了Jape文件可在句子中找到模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在jape规则中写的单词出现在同一句子中,则需要注释句子的一部分.例如,句子是孩子无法抗拒对其常规的任何改变".我已经在"trouble.lst"文件中添加了诸如"resist"之类的词,并在"alteration.lst"文件中进行了更改.现在在这句话中,我需要将抵制任何更改"部分注释为"A3b".我尝试使用以下代码,但未考虑同一句子中的单词.我的jape规则也是从不同的句子中提取单词.假设抗蚀剂出现在一个句子中,而后一个句子又发生变化,那么此代码也对此进行了注释.谁能帮我找出解决方案吗?

I need to annotate a part of a sentence if the words i have written in my jape rule appear in the same sentence. Eg the sentence is "The child cannot resist any changes to his routine". I have put words like resist in "trouble.lst" file and changes in "alteration.lst" file. Now in this sentence i need to annotate the part "resist any changes" as "A3b". I have tried using the below code but it is not considering words in the same sentence. My jape rule is taking words from different sentences as well. Suppose resist comes in one sentence and changes in some other later sentence, so this code is annotating that as well. Can anyone please help me out figure out solution to this?

Phase:secondpass
Input: Lookup
Options: control = brill

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

推荐答案

在这种情况下,您不能使用上下文运算符类似于{X within Y},因为它们仅适用于单个注释,不适用于一系列注释.

In such cases you cannot use Contextual Operators like {X within Y} because they work for a single annotation only, not for a sequence of annotations.

但是您可以使用技巧":

But you can use a "trick":

  1. Input中包含Sentence批注.
    这是主要的事情.即使您没有在规则中的任何位置使用Sentence,它也可以防止在新句子以注释之间开头的地方进行此类匹配.
    但这不会阻止句子与注释本身在同一点开头的匹配.

  1. Include Sentence annotations in the Input.
    This does the main thing. Even if you do not use Sentence anywhere in the rule, it prevents such matches where a new sentence starts somewhere between the annotations.
    But it does not prevent matches where a sentence starts at the same point as the annotation itself.

使用!运算符:{Lookup, !Sentence}禁止任何句子与第二个注释在同一点开始.

Prohibit any sentence to start 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"}

这篇关于Jape文件可在句子中找到模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆