Running Grew

Grew can be used from Python. See Tutorial page for basic usage from Python. The remaining of this page presents the command line program.

The command to run Grew is: grew <subcommand> [<args>]

Available subcommands are:

Transform mode

In this mode, Grew apply a Graph Rewriting System to a graph or a set of graphs.

The full command for this mode:

grew transform -grs <grs_file> -i <input_file> -o <output_file>

Required arguments for this mode are:

Optional argument is:

GTK interface

The command to run the GTK interface: grew gui <args>. It supposes that you have installed the grew_gui opam packages (see GUI installation page).

Optional arguments:

Grep mode

This mode corresponds to the command line version of the Grew-match tool. The command is:

grew grep -pattern <pattern_file> -i <corpus_file>


The output is given in JSON format.


With the following files:

pattern {
  V [cat=V];
  V -[a_obj]-> A;
  V -[de_obj]-> DE;

The command:

grew grep -pattern subcat.pat -i

produces the following JSON output:

    "sent_id": "Europar.550_00496",
    "matching": { "V": "16", "DE": "19", "A": "14" }
    "sent_id": "emea-fr-test_00478",
    "matching": { "V": "33", "DE": "32", "A": "35" }
    "sent_id": "emea-fr-test_00438",
    "matching": { "V": "20", "DE": "21", "A": "22" }
    "sent_id": "annodis.er_00441",
    "matching": { "V": "16", "DE": "20", "A": "18" }
    "sent_id": "annodis.er_00240",
    "matching": { "V": "12", "DE": "13", "A": "11" }
    "sent_id": "annodis.er_00040",
    "matching": { "V": "42", "DE": "50", "A": "47" }

This means that the pattern described in the file subcat.pat was found 6 times in the corpus, each item gives the sentence identifier and the position of nodes matched by the pattern.

Note that two other options exist (-html and -dep_dir <directory>). The first one produces a new html field in each JSON item with the sentence where words impacted by the pattern are in a special HTML span with class highlight. The second one produces a new file in the folder directory with the representation of the sentence with highlighted part (as in Grew-match tool) and a new field in each JSON item with the filename; the output is in dep format (usable with Dep2pict).