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.