Jape 文件以查找句子中的模式 [英] Jape file to find the pattern within a sentence

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

问题描述

如果我在jape规则中写的单词出现在同一个句子中,我需要对句子的一部分进行注释.例如,这句话是孩子无法抗拒对他的日常生活的任何改变".我在trouble.lst"文件和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 inside 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天全站免登陆