Tag: jump - adamb924/mortal-engine GitHub Wiki

A <jump> tag will jump you from one node to another. This provides a little more flexibility that working with, e.g., <fork> tags. It also provides the critical capability of jumping between different models, which is probably what you want to do if you have an affix that changes the grammatical category of a word.

The “Multiple Models” example showed nouns receiving case marking, and verbs receiving tense marking (here on the Morphology file page, or at examples/09-Multiple-Models.xml).

The model below is similar, with the difference that you can add an infinitive suffix (“inf”) to a verb, and then jump to the case node to receive a case marker.

This code is from examples/10-Jumps.xml.

<?xml version="1.0" encoding="UTF-8"?>
<morphology
    xmlns="https://www.adambaker.org/mortal-engine"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://www.adambaker.org/mortal-engine morphology.xsd">
    <writing-systems src="writing-systems.xml"/>
    <model label="Nouns">
        <stem-list label="Stem">
            <filename>01-stems.xml</filename>
            <matching-tag>noun</matching-tag>
        </stem-list>
        <morpheme label="Case" id="case-suffix">
            <optional/>
            <allomorph>
                <form lang="wk-LA">Case</form>
            </allomorph>
        </morpheme>
    </model>
    <model label="Verbs">
        <stem-list label="Stem">
            <filename>01-stems.xml</filename>
            <matching-tag>verb</matching-tag>
        </stem-list>
        <sequence label="Infinitive Sequence">
            <optional/>
            <morpheme label="Infinitive">
                <allomorph>
                    <form lang="wk-LA">inf</form>
                </allomorph>
            </morpheme>
            <jump to="case-suffix" optional="false" target-node-required="false"/>
        </sequence>
    </model>
</morphology>

Unlike other nodes, the way to make a <jump> node optional is to use the optional attribute: <jump to="case-suffix" optional="true"/>. You must use this attribute, and set it to either true or false. (There's nothing profound behind this; <jump> just looks nicer as a self-closing tag.)

The output of the tests in examples/all-examples.xml shows the result: you can only add case suffixes onto a verb if there is an infinitive suffix.

Case suffixes can go on nouns
Success: The input don (wk-LA) was accepted by the model, which is correct. [Stem]
Success: The input donCase (wk-LA) was accepted by the model, which is correct. [Stem][Case]
Case suffixes don't go on verbs
Success: The input bilCase (wk-LA) was rejected by the model, which is correct. 
Infinitive suffixation, with subsequent case affixation
Success: The input bilinf (wk-LA) was accepted by the model, which is correct. [Stem][Infinitive]
Success: The input bilinfCase (wk-LA) was accepted by the model, which is correct. [Stem][Infinitive][Case]
(Obviously) Infinitive suffixes don't go on nouns
Success: The input doninf (wk-LA) was rejected by the model, which is correct. 

(In a proper language, the infinitive+jump sequence would be probably be one <path> in a <fork> element, with the other paths being various finite inflections.)

How to identify a node

As shown in the example above, the <jump> tag does not identify nodes with labels, but with the id attribute. The id case-suffix is created in <morpheme label="Case" id="case-suffix">. Then it is referenced in <jump to="case-suffix"/>.

(The reason for this is that label attributes are not required to be unique, but id attributes are. Sometimes you might want to use the same label for different nodes, e.g., verb agreement suffixes in different tenses.)

It is not required that the id attribute be identified “before” it is used. It can occur anywhere in the document.

Requiring the target node to match

Another option is to require the target node to match, using the attribute target-node-required="true". This is illustrated in examples/11-Jumps-2.xml. The only difference from the previous example is that instead of <jump to="case-suffix" optional="false"/> we have <jump to="case-suffix" optional="false" target-node-required="true"/>

Setting target-node-required="true" overrides the optionality of <morpheme label="Case" id="case-suffix">, to make it a required node.

Because the only difference is that single line, we can just review the output of examples/all-examples.xml:

Case suffixes go on nouns
Success: The input don (wk-LA) was accepted by the model, which is correct. [Stem]
Success: The input donCase (wk-LA) was accepted by the model, which is correct. [Stem][Case]
Case suffixes don't go on verbs
Success: The input bilCase (wk-LA) was rejected by the model, which is correct. 
Infinitive suffixation, without a case suffix, is no longer possible
Success: The input bilinf (wk-LA) was rejected by the model, which is correct. 
Infinitive suffixation, with subsequent case affixation
Success: The input bilinfCase (wk-LA) was accepted by the model, which is correct. [Stem][Infinitive][Case]
(Obviously) Infinitive suffixes don't go on nouns
Success: The input doninf (wk-LA) was rejected by the model, which is correct. 

Limitations on jumps

There in an important limitation on jumps: every <jump> tag gets one jump per parsing. This is to deal with the possibility of infinitely long parsings. This slows down generations. ;-)

To be concrete, if in the example above there was another <jump> from the noun model to the verb model, then:

  • You could jump from the verb model to the noun model.
  • And you could jump back from the noun model to the verb model.
  • But after that, you could not jump for a second time to the noun model.

This should really not be a problem, unless you're using <jump> tags the way a beginning programmer uses goto statements.

⚠️ **GitHub.com Fallback** ⚠️