Grew • Command Line Interface

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

Main subcommands are:

Other subcommands:


Transform

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 [<args>]

All arguments are optional:


Grep

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

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

where:

The output is given in JSON format.

Example

With the following files:

pattern { e: M -> N; N [lemma="rouge"] }

The command:

grew grep -pattern rouge.pat -i fr_gsd-ud-dev.conllu

produces the following JSON output:

[
  {
    "sent_id": "w01133014",
    "matching": {
      "nodes": { "N": "7", "M": "6" },
      "edges": {
        "e": { "source": "6", "label": { "1": "amod" }, "target": "7" }
      }
    }
  },
  {
    "sent_id": "n01098044",
    "matching": {
      "nodes": { "N": "10", "M": "9" },
      "edges": {
        "e": { "source": "9", "label": { "1": "amod" }, "target": "10" }
      }
    }
  },
  {
    "sent_id": "n01050006",
    "matching": {
      "nodes": { "N": "22", "M": "21" },
      "edges": {
        "e": { "source": "21", "label": { "1": "amod" }, "target": "22" }
      }
    }
  }
]

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

Note that two other options exist:


Compile

For the Grew-match server (grew_daemon) or for the command grew count, it is required to first compile corpora. For these two usages, sets of corpora are described in a JSON file.

For compilation, the command is:

grew compile -i <corpora.json>

Note that this produces, for each corpus, a new file with the marshal extension stored in the corpus directory. The marshal is computed only if the corpus has changed since the last compilation.


Clean

The commands below removes the marshal files produced by the grew compile command for the set of corpora described in the JSON file corpora.json.

grew clean -i <corpora.json>


Count

This mode computes corpus statistics. Given a set of patterns and a set of corpora, a TSV table is built with the number of occurrences for each pattern in each corpus.

The set of corpora is described in a JSON file and must be compiled before running grew count.

Each pattern is described in a separate file.

Example

With the two following 1-line files:

and the example file en_fr_zh.json 🔗

{ "corpora": [
  { "id": "UD_English-PUD",
    "directory": "_build",
    "files": ["en_pud-ud-test.conllu"]
  },
  { "id": "UD_French-PUD",
    "directory": "_build",
    "files": ["fr_pud-ud-test.conllu"]
  },
  { "id": "UD_Chinese-PUD",
    "directory": "_build",
    "files": ["zh_pud-ud-test.conllu"]
  } ]
}

  1. Compile the corpora: grew compile -i en_fr_zh.json
  2. Build stat table: grew count -patterns "ADJ_NOUN.pat NOUN_ADJ.pat" -i en_fr_zh.json

The output is given as TSV data:

Corpus	# sentences	ADJ_NOUN	NOUN_ADJ
UD_English-PUD	1000	1118	12
UD_French-PUD	1000	423	935
UD_Chinese-PUD	1000	364	0

which corresponds to the table:

Corpus # sentences ADJ_NOUN NOUN_ADJ
UD_English-PUD 1000 1118 12
UD_French-PUD 1000 423 935
UD_Chinese-PUD 1000 364 0

We can then observe that in the annotations of the 3 corpora in use:

Remarks



GUI (Obsolete)

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

Optional arguments: