This file contains an explanation of the MOM graph and a recommendation of what should be visualized in the GUI.

****EXPLANATION:

The DOT file output by MOM is a specification of a morphotactic graph.

Each node is either a lexical item or a position class (prefix or suffix).
The edges are "input relationships" A is input to B means a surface string A-B is possible. Note that we start "inside-out" from the stem: the stem (which must be a lexical item) does not have inputs (incoming edges) but can serve as input to position classes (can have outgoing edges). So, if B is a stem and A- is a prefix and there is an edge from B to A-, then the surface string A-B will be licensed by the grammar compiled from this specification.

The text specification of the grammar is sometimes called the "choices file" (called so because it refers to the Grammar Matrix system that allows the user to specify a grammar by making choices via the web interface). The text specification must be in a valid format in order for it to be processed by the Grammar Matrix Customization System.

For the text specification to be valid, a lexical item must look like this:

verb1_name=verb1
verb1_stem1_pred=_wrap_v_rel
verb1_stem1_orth=wrap
verb1_stem2_pred=_work_v_rel
verb1_stem2_orth=work
verb1_stem3_pred=_wed_v_rel
verb1_stem3_orth=wed
verb1_valence=trans

Lines may come in any order, and stems and valence are all optional.
If a stem is present, it must have a pred and an orth. 
There may also be features on the lexical items, they are optional, but
if a feature is present, it must have a name, a value, and a head:

verb4_name=verb4
verb4_feat1_name=case
verb4_feat1_value=erg
verb4_feat1_head=subj
verb4_feat2_name=case
verb4_feat2_value=abs
verb4_feat2_head=obj
verb4_valence=trans
verb4_stem1_orth=kond
verb4_stem1_pred=_want.to_v_rel
verb4_stem2_orth=lis
verb4_stem2_pred=_be_v_rel

The specification for a position class must look like this:

verb-pc1_order=prefix
verb-pc1_inputs=verb1
verb-pc1_lrt1_lri1_orth=un-
verb-pc1_lrt1_lri1_inflecting=yes
verb-pc1_lrt1_name=verb-pc1_lrt1
verb-pc1_name=verb-pc1


Name, order, inputs, and "inflecting" specifications are obligatory. LRT (lexical rule types) and LRI (Lexical Rule Instances), which belong to LRTs (each LRT can have one or more LRIs), are optional, but if they are present, they must in turn be fully specified.

LRTs can have features on them, which again must be fully specified, if present:

verb-pc3_order=suffix
verb-pc3_inputs=verb-pc2
verb-pc3_lrt1_lri1_orth=-s
verb-pc3_lrt1_lri1_inflecting=yes
verb-pc3_lrt1_feat1_value=3
verb-pc3_lrt1_feat1_head=subj
verb-pc3_lrt1_feat1_name=person
verb-pc3_lrt1_feat2_value=sg
verb-pc3_lrt1_feat2_head=subj
verb-pc3_lrt1_feat2_name=number
verb-pc3_lrt1_name=verb-pc3_lrt1
verb-pc3_name=verb-pc3

***** JSON to text

In the DOT file, you see a name and a label for each node. The name is the unique ID. The "label" is a JSON serialization of the full speficication (see Explanation above). The JSON serialization can be loaded into a dictionary. It corresponds directly to the text serialization shown above.

NOTE: The idea is that you use a library to load the JSON serialization into a dictionary and then to dump the modified dictionary back into a JSON object. NOT to write your own parser/serializer (hopefully, this won't be necessary!).

// eng_overlap_graph
digraph {
	verb1 [label="{_QT_stem_QT_: [{_QT_pred_QT_: _QT__wrap_v_rel_QT_, _QT_orth_QT_: _QT_wrap_QT_}, {_QT_pred_QT_: _QT__work_v_rel_QT_, _QT_orth_QT_: _QT_work_QT_}, {_QT_pred_QT_: _QT__wed_v_rel_QT_, _QT_orth_QT_: _QT_wed_QT_}], _QT_valence_QT_: _QT_trans_QT_, _QT_name_QT_: _QT_verb1_QT_}"]
	"verb-pc4" [label="{_QT_order_QT_: _QT_suffix_QT_, _QT_inputs_QT_: _QT_verb-pc2_QT_, _QT_lrt_QT_: [{_QT_lri_QT_: [{_QT_orth_QT_: _QT_-ed_QT_, _QT_inflecting_QT_: _QT_yes_QT_}], _QT_feat_QT_: [{_QT_value_QT_: _QT_pst_QT_, _QT_head_QT_: _QT_verb_QT_, _QT_name_QT_: _QT_tense_QT_}], _QT_name_QT_: _QT_verb-pc4_lrt1_QT_}], _QT_name_QT_: _QT_verb-pc4_QT_}"]
	"verb-pc3" [label="{_QT_order_QT_: _QT_suffix_QT_, _QT_inputs_QT_: _QT_verb-pc2_QT_, _QT_lrt_QT_: [{_QT_lri_QT_: [{_QT_orth_QT_: _QT_-s_QT_, _QT_inflecting_QT_: _QT_yes_QT_}], _QT_feat_QT_: [{_QT_value_QT_: _QT_3_QT_, _QT_head_QT_: _QT_subj_QT_, _QT_name_QT_: _QT_person_QT_}, {_QT_value_QT_: _QT_sg_QT_, _QT_head_QT_: _QT_subj_QT_, _QT_name_QT_: _QT_number_QT_}], _QT_name_QT_: _QT_verb-pc3_lrt1_QT_}], _QT_name_QT_: _QT_verb-pc3_QT_}"]
	"verb-pc2" [label="{_QT_order_QT_: _QT_prefix_QT_, _QT_inputs_QT_: _QT_verb-pc1_QT_, _QT_lrt_QT_: [{_QT_lri_QT_: [{_QT_orth_QT_: _QT_re-_QT_, _QT_inflecting_QT_: _QT_yes_QT_}], _QT_name_QT_: _QT_verb-pc2_lrt1_QT_}], _QT_name_QT_: _QT_verb-pc2_QT_}"]
	"verb-pc1" [label="{_QT_order_QT_: _QT_prefix_QT_, _QT_inputs_QT_: _QT_verb1_QT_, _QT_lrt_QT_: [{_QT_lri_QT_: [{_QT_orth_QT_: _QT_un-_QT_, _QT_inflecting_QT_: _QT_yes_QT_}], _QT_name_QT_: _QT_verb-pc1_lrt1_QT_}], _QT_name_QT_: _QT_verb-pc1_QT_}"]
		"verb-pc2" -> "verb-pc3"
		"verb-pc2" -> "verb-pc4"
		"verb-pc1" -> "verb-pc2"
		verb1 -> "verb-pc1"
}


Let's compare the first node:

	verb1 [label="{_QT_stem_QT_: [{_QT_pred_QT_: _QT__wrap_v_rel_QT_, _QT_orth_QT_: _QT_wrap_QT_}, {_QT_pred_QT_: _QT__work_v_rel_QT_, _QT_orth_QT_: _QT_work_QT_}, {_QT_pred_QT_: _QT__wed_v_rel_QT_, _QT_orth_QT_: _QT_wed_QT_}], _QT_valence_QT_: _QT_trans_QT_, _QT_name_QT_: _QT_verb1_QT_}"]

to the text specification:

verb1_name=verb1
verb1_stem1_pred=_wrap_v_rel
verb1_stem1_orth=wrap
verb1_stem2_pred=_work_v_rel
verb1_stem2_orth=work
verb1_stem3_pred=_wed_v_rel
verb1_stem3_orth=wed
verb1_valence=trans

The very first "verb1" corresponds to "verb1_name=verb1". That's the unique ID. Now let's look at the "label". That is a dictionary. It contains three entries: name, stem, and valence. 

The entry under key 'name' is the simplest: it is the same "verb1" unique ID that we already saw as the node's name. Note that, in order for the data to load and appear on the screen, I had to replace all quotation marks with _QT_. 

The entry under the key "valence" is also just a string, in this case "trans" (transitive).

The entry under the key "stem" is more complex: it is a list:

_QT_stem_QT_: [{_QT_pred_QT_: _QT__wrap_v_rel_QT_, _QT_orth_QT_: _QT_wrap_QT_}, {_QT_pred_QT_: _QT__work_v_rel_QT_, _QT_orth_QT_: _QT_work_QT_}, {_QT_pred_QT_: _QT__wed_v_rel_QT_, _QT_orth_QT_: _QT_wed_QT_}]

You can tell by the [ ] which surround the list items. (Note that these are not the same as the [] which surround the node's "label" itself; the outermost [] are the label's and aren't part of the JSON serialization; anything inside the "label" means a JSON list.

Each item in this list is a small dictionary. In this case, there are three items: wrap, work, and wed. So, three predicates corresponding to the same "stem class". (It may seem unnecessary to have a "stem class" instead of a lexical item class, but that is what is needed for the Grammar Matrix Customization System).

The first item on the list:

{_QT_pred_QT_: _QT__wrap_v_rel_QT_, _QT_orth_QT_: _QT_wrap_QT_}

-- is a dictionary with two keys, pred and orth. We have "wrap_v_rel" stored under the key "pred" and "wrap" stored under the key "orth" (in a non-English file, these would be different).
 

Now let's look at a position class JSON serialization:


	"verb-pc3" [label="{_QT_order_QT_: _QT_suffix_QT_, _QT_inputs_QT_: _QT_verb-pc2_QT_, _QT_lrt_QT_: [{_QT_lri_QT_: [{_QT_orth_QT_: _QT_-s_QT_, _QT_inflecting_QT_: _QT_yes_QT_}], _QT_feat_QT_: [{_QT_value_QT_: _QT_3_QT_, _QT_head_QT_: _QT_subj_QT_, _QT_name_QT_: _QT_person_QT_}, {_QT_value_QT_: _QT_sg_QT_, _QT_head_QT_: _QT_subj_QT_, _QT_name_QT_: _QT_number_QT_}], _QT_name_QT_: _QT_verb-pc3_lrt1_QT_}], _QT_name_QT_: _QT_verb-pc3_QT_}"]


This corresponds directly to:

verb-pc3_order=suffix
verb-pc3_inputs=verb-pc2
verb-pc3_lrt1_lri1_orth=-s
verb-pc3_lrt1_lri1_inflecting=yes
verb-pc3_lrt1_feat1_value=3
verb-pc3_lrt1_feat1_head=subj
verb-pc3_lrt1_feat1_name=person
verb-pc3_lrt1_feat2_value=sg
verb-pc3_lrt1_feat2_head=subj
verb-pc3_lrt1_feat2_name=number
verb-pc3_lrt1_name=verb-pc3_lrt1
verb-pc3_name=verb-pc3

We will start directly with the "label" this time:

label="{_QT_order_QT_: _QT_suffix_QT_, _QT_inputs_QT_: _QT_verb-pc2_QT_, _QT_lrt_QT_: [{_QT_lri_QT_: [{_QT_orth_QT_: _QT_-s_QT_, _QT_inflecting_QT_: _QT_yes_QT_}], _QT_feat_QT_: [{_QT_value_QT_: _QT_3_QT_, _QT_head_QT_: _QT_subj_QT_, _QT_name_QT_: _QT_person_QT_}, {_QT_value_QT_: _QT_sg_QT_, _QT_head_QT_: _QT_subj_QT_, _QT_name_QT_: _QT_number_QT_}], _QT_name_QT_: _QT_verb-pc3_lrt1_QT_}], _QT_name_QT_: _QT_verb-pc3_QT_}"

This is again a dictionary, it has the following keys: "name", "order", "inputs", and "lrt". The first three are strings, but note that "inputs" is comma-separated. We can ignore "inputs" because this information is redundant (it is reflected in the edges of the graph). The complex item in this case is "lrt": it is a list of lexical rule types.

_QT_lrt_QT_: [{_QT_lri_QT_: [{_QT_orth_QT_: _QT_-s_QT_, _QT_inflecting_QT_: _QT_yes_QT_}], _QT_feat_QT_: [{_QT_value_QT_: _QT_3_QT_, _QT_head_QT_: _QT_subj_QT_, _QT_name_QT_: _QT_person_QT_}, {_QT_value_QT_: _QT_sg_QT_, _QT_head_QT_: _QT_subj_QT_, _QT_name_QT_: _QT_number_QT_}]

Each LRT is a dictionary; in this case we only have one LRT:

{_QT_lri_QT_: [{_QT_orth_QT_: _QT_-s_QT_, _QT_inflecting_QT_: _QT_yes_QT_}], _QT_feat_QT_: [{_QT_value_QT_: _QT_3_QT_, _QT_head_QT_: _QT_subj_QT_, _QT_name_QT_: _QT_person_QT_}, {_QT_value_QT_: _QT_sg_QT_, _QT_head_QT_: _QT_subj_QT_, _QT_name_QT_: _QT_number_QT_}]

It has the following keys: "lri" and "feat". Both contain lists (of lexical rule instances and features).

A lexical rule instance is a small dictionary. In this case we have one LRI inside the LRT:

{_QT_orth_QT_: _QT_-s_QT_, _QT_inflecting_QT_: _QT_yes_QT_}

The "orth" attribute of the LRI is -s. We can ignore the "inflecting" attribute.

We have two features associated with the LRT:

{_QT_value_QT_: _QT_3_QT_, _QT_head_QT_: _QT_subj_QT_, _QT_name_QT_: _QT_person_QT_}

and 

{_QT_value_QT_: _QT_sg_QT_, _QT_head_QT_: _QT_subj_QT_, _QT_name_QT_: _QT_number_QT_}

Both are small dictionaries specifying the value, the head, and the name of the feature.




******VISUALIZATION:

For lexical items (e.g. verb or noun stems), we probably want to show a subset of orths and preds (and then have all of the orth/pred pairs available via the sidebar), and also transitivity, if available.

For example, for something like:

verb1_name=verb1
verb1_stem1_pred=_wrap_v_rel
verb1_stem1_orth=wrap
verb1_stem2_pred=_work_v_rel
verb1_stem2_orth=work
verb1_stem3_pred=_wed_v_rel
verb1_stem3_orth=wed
verb1_valence=trans

-- we probably just want to show trans, wrap/wrap, work/work, wed/wed in the sidebar, and maybe we only want to show trans,wed/wed in the node itself in the visualization area (so, just one stem/translation pair?) We want to use the lexical item's name attribute as the unique ID.

For position classes, we probably want to show, at a minimum, its order and orths (aggregated over all of the LRIs, over all of the LRTS; we want all of them in the sidebar and perhaps the first 1-3 in the node itself?). We probably also want the features names, values, and heads, aggregated over all the LRTs, but I am not currently sure what the best way is. I just know it is valuable information that the users will likely want to see. To visualize, it would be good to concatenate the features to e.g. 3+sg+subj (this is a set union of all values and heads, ignoring feature names for a second). Again, we can only show one in the node, to start, and make the rest available via the sidebar. Note that, in the sidebar and for editing, we want to keep things separate (e.g. name, head, value for each feature). The pc's name attribute is its unique ID. It is guaranteed to come in unique and must stay unique.

verb-pc3_order=suffix
verb-pc3_inputs=verb-pc2
verb-pc3_lrt1_lri1_orth=-s
verb-pc3_lrt1_lri1_inflecting=yes
verb-pc3_lrt1_feat1_value=3
verb-pc3_lrt1_feat1_head=subj
verb-pc3_lrt1_feat1_name=person
verb-pc3_lrt1_feat2_value=sg
verb-pc3_lrt1_feat2_head=subj
verb-pc3_lrt1_feat2_name=number
verb-pc3_lrt1_name=verb-pc3_lrt1
verb-pc3_name=verb-pc3


