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:

The command:

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

produces the following JSON output:

[
  {
    "sent_id": "fr-ud-dev_00623",
    "matching": {
      "nodes": { "N": "39", "M": "38" },
      "edges": {
        "e": { "source": "38", "label": { "1": "amod" }, "target": "39" }
      }
    }
  },
  {
    "sent_id": "fr-ud-dev_00217",
    "matching": {
      "nodes": { "N": "17", "M": "16" },
      "edges": {
        "e": { "source": "16", "label": { "1": "amod" }, "target": "17" }
      }
    }
  }
]

This means that the pattern described in the file bleu.pat was found twice in the corpus, each item gives the sentence identifier and the position of nodes and 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 usage, 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-EWT@2.6",
    "directory": "/Users/guillaum/resources/ud-treebanks-v2.6/UD_English-EWT/",
    "files": ["en_ewt-ud-dev.conllu", "en_ewt-ud-test.conllu", "en_ewt-ud-train.conllu"]
  },
  { "id": "UD_French-Sequoia@2.6",
    "directory": "/Users/guillaum/resources/ud-treebanks-v2.6/UD_French-Sequoia/"
  },
  { "id": "UD_Chinese-GSD@2.6",
    "directory": "/Users/guillaum/resources/ud-treebanks-v2.6/UD_Chinese-GSD/"
  } ]
}

  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-EWT	16622	9835	163
UD_French-Sequoia	3099	891	2779
UD_Chinese-GSD	4997	1505	0

which corresponds to the table:

Corpus # sentences ADJ_NOUN NOUN_ADJ
UD_English-EWT 16622 9835 163
UD_French-Sequoia 3099 891 2779
UD_Chinese-GSD 4997 1505 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: