0 votes
230 views

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 (237 points) | 230 views

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 (336 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 (237 points)
0 votes

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

by (336 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 (336 points)

Related questions

0 votes
2 answers 29 views
I'm trying to eliminate the Genitive slot on a noun when both Genitive and Associative slots have ... AND a_Associative_slot is NOT EMPTY, then eliminate a_Genitive_slot:
matoxltr 122 asked Jul 16, 2025
0 votes
1 answer 80 views
How do I use the Sample logic that’s in the transfer rules file?
Sara 246 asked Apr 28, 2025
0 votes
1 answer 100 views
How do I use the attribute element in the transfer rules?
rmdiamondl 336 asked May 8, 2022
0 votes
1 answer 114 views
Lexical categories are used to group words together. The grouping can be very broad such as verbs or very specific such ... you want to match phrases containing the word this'.
rmdiamondl 336 asked May 8, 2022
0 votes
1 answer 21 views
How do I refer to affix glosses in transfer rules?
Sara 246 asked Apr 28, 2025
Welcome to Support Bible, where you can ask questions and receive answers from other members of the community.
May the God who gives endurance and encouragement give you the same attitude of mind toward each other that Christ Jesus had.
Romans 15:5
3,037 questions
5,994 answers
5,661 comments
2,022 users