0 votes

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?

FLExTrans by (233 points)

4 Answers

0 votes

Some good questions. Let me address them one by one.

  1. 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.

  2. 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.

  3. 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.

by (256 points)
0 votes

Thanks, that is helpful! So, the patterns (tags) for matching words by word class can be more specific by including affix patterns, too.

by (233 points)
0 votes

Yes. You can even match a word category + an exact lemma. Here’s an example:
image

by (256 points)

In this case, presumably the lemma is unique, so you wouldn’t need to specify the tag; or would you?

0 votes

You still have to specify the first tag, i.e. the grammatical category. That’s the way Apertium works.

by (256 points)
Welcome to Support Bible, where you can ask questions and receive answers from other members of the community.
Every day they continued to meet together in the temple courts. They broke bread in their homes and ate together with glad and sincere hearts, praising God and enjoying the favor of all the people. And the Lord added to their number daily those who were being saved.
Acts 2:46-47
2,618 questions
5,350 answers
5,037 comments
1,421 users