mw-parser.simplify

Simplify a parse tree.

simplify

(simplify tree)

Simplify/canonicalise this tree. Opportunistically replace complex fragments with semantically identical simpler fragments

simplify-chained-list

(simplify-chained-list tree branch-tag leaf-tag)

Some parse trees take the form [:X [:Y 1] :NOISE :NOISE [:X [:Y 2] :NOISE :NOISE [:X [:Y 3]]]] where what’s wanted is [:X [:Y 1] [:Y 2] [:Y 2]] – :DISJUNCT-VALUE is a case in point. This takes such a parse tree, where branch-tag is the tag of the enclosing form and leaf-tag is the tag of the form to be collected, and returns the desired form.

simplify-determiner-condition

(simplify-determiner-condition tree)

TODO: write docs

simplify-second-of-two

(simplify-second-of-two tree)

There are a number of possible simplifications such that if the tree has only two elements, the second is semantically sufficient.