Support.Bible is a public forum that connects users of Bible translation software, so that they can help one another find solutions and discover new ways of working together. We welcome users of all Bible translation software systems to discover how they can help one another take God's Word to the world.
Search existing questions first — if you don't find what you need, create a free account to ask your own.
第 6.2.3 节“模式匹配是如何工作的?”解释了在模式匹配过程中,给定长度的规则中列出的第一条具有优先权,并且这意味着“在某些情况下,规则的顺序很重要”。 什么时候这可能会相关?如果第二条本应匹配的规则被忽略,有没有办法让它被使用?或者它只是一条无效规则?
Section 6.2.3 “How does pattern matching work?” explains that during pattern-matching the first one listed of a given length gets precedence and that this “means in some cases the order of your rules will be important”. When might this be relevant? If a second rule that would match is ignored, is there ever a way for it to be used? Or is it just a dead rule?
问得很好。让我逐一回答。
什么时候两条模式长度相等的规则中一条优先于另一条的情况会相关? 假设你有一条规则 A,它匹配任何名词。(设置一个类别以匹配名词,例如标签:‘n’、‘n.*’)。再假设你有一条规则 B,它匹配复数名词。(设置一个类别以匹配复数名词,例如标签:‘n.pl’、‘n.pl.*’)。如果你将规则 B 放在规则 A 之后,规则 B 将永远不会被执行。这两条规则在匹配的类别中具有相等的模式长度(1 个模式项),因此规则的顺序就起作用了。带有类别 ‘n’ 和后缀 ‘pl’ 的词总是先被规则 A 捕获。因此,在这种情况下,你希望将规则 B 放在规则 A 之前。这样,复数名词会被规则 B 捕获,而其他类型的名词则落入规则 A 进行处理。
如果第二条本应匹配的规则被忽略,有没有办法让它被使用?我认为上面的回答已经说明了,是的,根据类别的不同,它是可以被使用的。
如果一条规则位于两条模式长度相等的规则中的第二位,它是否就是无效的?正如我们上面描述的情况,如果规则 A 在规则 B 之前,规则 B 基本上是无效的,因为规则 A 捕获了所有你希望由规则 B 捕获的词。然而,如果规则 B 在规则 A 之前,即使规则 A 位于第二位,它也不是无效的,因为规则 B 只捕获有限数量的可能词(在这种情况下是复数名词)。其余的词落入规则 A。
一个普遍原则是,当规则模式长度相同时,将更具体的规则放在更通用的规则之前。
Some good questions. Let me address them one by one.
When might two equal pattern length rules where one has precedence of the other be relevant? Let’s say you have rule A that matches any noun. (A category is set up to match noun, e.g. tags: ‘n’, ‘n.*’). Also let’s say you have rule B that matches plural nouns. (A category is set up to match plural nouns, e.g. tags: ‘n.pl’, ‘n.pl.*’) If you place rule B after rule A, rule B will never get executed. Both rules are of equal pattern length in the categories being matched (1 pattern item), so the order of the rules comes into play. A word with category ‘n’ and suffix ‘pl’ will always be caught first by rule A. So in this situation you would want to put rule B before rule A. This way plural nouns get caught by rule B and other kinds of nouns fall through to rule A for handling.
If a second rule that would match is ignored, is there ever a way for it to be used? I think the above answers that yes it can be used depending on the category.
Is a rule dead if it is in 2nd position of two equal pattern length rules? As we look at the situation described above, if rule A is before rule B, rule B it is essentially dead because rule A catches all words that you would want to be caught by rule B. However, if rule B is before rule A, rule A is not dead even though it is 2nd because rule B catches only a limited amount of possible words (in this case plural nouns). The rest fall through to rule A.
A general principle is to put more specific rules before more general rules when the rule pattern length is the same.
谢谢,这很有帮助!所以,用于按词类匹配单词的模式(标签)可以通过包含词缀模式变得更加具体。
Thanks, that is helpful! So, the patterns (tags) for matching words by word class can be more specific by including affix patterns, too.
是的。你甚至可以匹配一个词类 + 一个精确的词根。这里有一个例子:
Yes. You can even match a word category + an exact lemma. Here’s an example:
在这种情况下,据推测词根是唯一的,所以你可能不需要指定标签;或者你需要吗?
In this case, presumably the lemma is unique, so you wouldn’t need to specify the tag; or would you?
你仍然必须指定第一个标签,即语法类别。这是 Apertium 的工作方式。
You still have to specify the first tag, i.e. the grammatical category. That’s the way Apertium works.