First rule ⬅️⬆️➡️ Termination

Grew Tutorial • Lesson 3 • Rules set

In the previous lesson, we have seen 3 rules dealing with several POS. We will learn how to make these rules working together.


A solution to use several rules in the same rewriting process is to put them in the same package construction (file: pos_rules.grs).

package POS {
  rule adj {
    pattern { N [upos=A] }
    commands { N.upos = ADJ }

  rule noun {
    pattern { N [upos=N] }
    commands { N.upos = NOUN }

  rule prep {
    pattern { N [upos=P] }
    commands { N.upos = ADP }

The package name POS can be used as strategy name for rewriting. Applying the package POS corresponds to the application of one of the rules of the package.

With the input graph used in the previous lesson:


The command below produces 3 graphs obtained either by the application of the rule adj or by the two possible applications of the rule noun.

grew transform -config sequoia -grs pos_rules.grs -strat "POS" -i frwiki_50.1000_00907.seq.conll

In order to iterate the package, we need the strategy Onf (POS):

grew transform -config sequoia -grs pos_rules.grs -strat "Onf(POS)" -i frwiki_50.1000_00907.seq.conll

As usual with Onf, exactly one graph is produced obtained with the successive applications of the rules:


First rule ⬅️⬆️➡️ Termination