Tag: fork - adamb924/mortal-engine GitHub Wiki

A <fork> contains multiple <path> elements. The parser can follow any of the paths during the course of the parsing.

The example below (from examples/07-Forks.xml) abandons the pretense of real language in favor of clarity.

Informally: There is a verb stem. This is obligatorily followed by either the “_PRESENT_” suffix or the “_FUTURE_” suffix. Following the “_PRESENT_” suffix, there are agreement suffixes “present.1s” and “present.2s”; and there are also agreement suffixes specific to the future tense. (The names are mnemonic to make the results clear.) The example uses a <fork> element with two <path> elements, one for the present and one for the future.

<?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>verb</matching-tag>
        </stem-list>
        <fork label="Tenses">
            <path label="Present Path">
                <morpheme label="Present">
                    <allomorph>
                        <form lang="wk-LA">_PRESENT_</form>
                    </allomorph>
                </morpheme>
                <mutually-exclusive-morphemes label="Present Agreement">
                    <morpheme label="present.1S">
                        <allomorph>
                            <form lang="wk-LA">present.1s</form>
                        </allomorph>
                    </morpheme>
                    <morpheme label="present.2S">
                        <allomorph>
                            <form lang="wk-LA">present.2s</form>
                        </allomorph>
                    </morpheme>
                </mutually-exclusive-morphemes>
            </path>
            <path label="Future Path">
                <morpheme label="Future">
                    <allomorph>
                        <form lang="wk-LA">_FUTURE_</form>
                    </allomorph>
                </morpheme>
                <mutually-exclusive-morphemes label="Future Agreement">
                    <morpheme label="future.1S">
                        <allomorph>
                            <form lang="wk-LA">future.1s</form>
                        </allomorph>
                    </morpheme>
                    <morpheme label="future.2S">
                        <allomorph>
                            <form lang="wk-LA">future.2s</form>
                        </allomorph>
                    </morpheme>
                </mutually-exclusive-morphemes>
            </path>
        </fork>
    </model>
</morphology>

The output of the tests in examples/all-examples.xml shows the result: present agreement suffixes only occur after the present, and future agreement suffixes only occur after the future.

Success: The input bil_PRESENT_present.1s (wk-LA) was accepted by the model, which is correct. [Stem][Present][present.1S]
Success: The input bil_PRESENT_present.2s (wk-LA) was accepted by the model, which is correct. [Stem][Present][present.2S]
Success: The input bil_FUTURE_present.1s (wk-LA) was rejected by the model, which is correct. 
Success: The input bil_FUTURE_present.2s (wk-LA) was rejected by the model, which is correct. 
Success: The input bil_PRESENT_future.1s (wk-LA) was rejected by the model, which is correct. 
Success: The input bil_PRESENT_future.2s (wk-LA) was rejected by the model, which is correct. 
Success: The input bil_FUTURE_future.1s (wk-LA) was accepted by the model, which is correct. [Stem][Future][future.1S]
Success: The input bil_FUTURE_future.2s (wk-LA) was accepted by the model, which is correct. [Stem][Future][future.2S]

In this example, the fork does not have the <optional/> tag, so one of the paths must be included in the parse. If the <optional/> tag were included, then the morphology would accept bare stems as well.

The labels of the <fork> and <path> elements are just there for your convenience; they will never be displayed in the output of a parse. (They are referenced in the debug output, however.)

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