<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../../../../../../../../../languagetool-core/src/main/resources/org/languagetool/rules/print.xsl" title="Pretty print" ?>
<?xml-stylesheet type="text/css" href="../../../../../../../../../languagetool-core/src/main/resources/org/languagetool/rules/rules.css" title="Easy editing stylesheet" ?>
<!--
German Disambiguation Rules for LanguageTool
Copyright © 2013 Markus Brenneis, Daniel Naber, Jan Schreiber
-->

<rules lang="de" xsi:noNamespaceSchemaLocation="../../../../../../../../../languagetool-core/src/main/resources/org/languagetool/resource/disambiguation.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <unification feature="number">
        <equivalence type="sg">
            <token postag=".*:SIN:.*" postag_regexp="yes"/>
        </equivalence>
        <equivalence type="pl">
            <token postag=".*:PLU:.*" postag_regexp="yes"/>
        </equivalence>
    </unification>

    <unification feature="case">
        <equivalence type="nom">
            <token postag=".*:NOM:.*" postag_regexp="yes"/>
        </equivalence>
        <equivalence type="akk">
            <token postag=".*:AKK:.*" postag_regexp="yes"/>
        </equivalence>
        <equivalence type="dat">
            <token postag=".*:DAT:.*" postag_regexp="yes"/>
        </equivalence>
        <equivalence type="gen">
            <token postag=".*:GEN:.*" postag_regexp="yes"/>
        </equivalence>
    </unification>

    <unification feature="gender">
        <!-- NOG = no gender, benutzt für Nomen, die nur im Plural vorkommen wie "Ferien" -->
        <equivalence type="mas">
            <token postag=".*:(MAS|NOG).*" postag_regexp="yes"/>
        </equivalence>
        <equivalence type="fem">
            <token postag=".*:(FEM|NOG).*" postag_regexp="yes"/>
        </equivalence>
        <equivalence type="neu">
            <token postag=".*:(NEU|NOG).*" postag_regexp="yes"/>
        </equivalence>
    </unification>

    <!-- ============================================================================================================== -->
    <!-- Noun phrases unification -->
    <!-- ============================================================================================================== -->

    <rule name="NP unify 1" id="UNIFY_DET_SUB">
        <!--
        z.B. in "Das Kind, das Kuchen isst." wird 'das Kind' unifiziert, 'das Kuchen' aber nicht.
        So können wir weiter unten Nominalphrasen erkennen und in grammar.xml dann Regeln haben
        für z.B. "Das Haus sind groß."
        Die Erkennung von Fehlern *innerhalb* von Nominalphrasen (z.B. "der Auto") liegt bei der
        Java-Regel AgreementRule.
        -->
        <pattern>
            <marker>
                <unify>
                    <feature id="number"/><feature id="case"/><feature id="gender"/>
                    <token regexp="yes">der|die|das|den|ein|eine|dieser|dieses|sein|ihr</token>
                    <token postag="SUB:.*" postag_regexp="yes">
                        <exception postag_regexp="yes" postag="ADJ:.*"/><!-- needed for AgreementRule to not false alert on 'den Berliner Arbeitern' -->
                    </token>
                </unify>
            </marker>
        </pattern>
        <disambig action="unify"/>
    </rule>
    <rule name="NP unify 1b" id="UNIFY_DET_SUB2">
        <pattern>
            <marker>
                <unify>
                    <feature id="number"/><feature id="case"/><feature id="gender"/>
                    <!--"beiden Filmen", but: "dass sie Geliebte waren"-->
                    <token postag="(PRO|ART):.*" postag_regexp="yes"><exception>sie</exception></token>
                    <token postag="SUB:.*" postag_regexp="yes"><exception postag="ADJ:.*" postag_regexp="yes"/></token>
                </unify>
            </marker>
        </pattern>
        <disambig action="unify"/>
    </rule>
    <!-- TODO: this would fix false alarm for 'die ältere der beiden Töchter' but causes other problems
    <rule name="NP unify 1c" id="UNIFY_DET_ADJ">
        <pattern>
            <marker>
                <unify>
                    <feature id="number"/><feature id="case"/><feature id="gender"/>
                    "die ältere [der beiden]"
                    <token regexp="yes">der|die|das</token>
                    <token postag="ADJ.*:(DEF|IND).*" postag_regexp="yes"/>
                </unify>
            </marker>
        </pattern>
        <disambig action="unify"/>
    </rule>
    -->
    <rule name="NP unify 2" id="UNIFY_DET_ADJ_ADJ_SUB">
        <pattern>
            <marker>
                <unify>
                    <feature id="number"/><feature id="case"/><feature id="gender"/>
                    <token regexp="yes">der|die|das|den|ein|eine|dieser|dieses|sein|ihr</token>
                    <token postag="ADJ:.*" postag_regexp="yes"/>
                    <token postag="ADJ:.*" postag_regexp="yes"/>
                    <token postag="SUB:.*" postag_regexp="yes"/>
                </unify>
            </marker>
        </pattern>
        <disambig action="unify"/>
    </rule>
    <rule name="NP unify 2b" id="UNIFY_DET_ADJ_UND_ADJ_SUB">
        <pattern>
            <marker>
                <unify>
                    <!-- "Der größte und schönste Tempel" -->
                    <feature id="number"/><feature id="case"/><feature id="gender"/>
                    <token regexp="yes">der|die|das|den|ein|eine|dieser|dieses|sein|ihr</token>
                    <token postag="ADJ:.*" postag_regexp="yes"/>
                    <unify-ignore>
                        <token>und</token>
                    </unify-ignore>
                    <token postag="ADJ:.*" postag_regexp="yes"/>
                    <token postag="SUB:.*" postag_regexp="yes"/>
                </unify>
            </marker>
        </pattern>
        <disambig action="unify"/>
    </rule>
    <rule name="NP unify 3" id="UNIFY_DET_ADJ_SUB">
        <pattern>
            <marker>
                <unify>
                    <feature id="number"/><feature id="case"/><feature id="gender"/>
                    <token regexp="yes">der|die|das|den|ein|eine|dieser|dieses|sein|ihr</token>
                    <token postag="ADJ:.*" postag_regexp="yes"/>
                    <token postag="SUB:.*" postag_regexp="yes"/>
                </unify>
            </marker>
        </pattern>
        <disambig action="unify"/>
    </rule>
    <rule name="NP unify 3b" id="UNIFY_ADJ_SUB">
        <pattern>
            <marker>
                <unify>
                    <feature id="number"/><feature id="case"/><feature id="gender"/>
                    <!-- "Am Strand stehen schöne Häuser"-->
                    <token postag="ADJ:.*" postag_regexp="yes"/>
                    <token postag="SUB:.*" postag_regexp="yes"/>
                </unify>
            </marker>
        </pattern>
        <disambig action="unify"/>
    </rule>

    <rule name="NP unify 4" id="UNIFY_4">
        <pattern>
            <marker>
                <unify>
                    <feature id="number"/><feature id="case"/><feature id="gender"/>
                    <!-- "Die von der Regierung geprüften Hunde" -->
                    <token regexp="yes">der|die|das|den|ein|eine|dieser|dieses|sein|ihr</token>
                    <unify-ignore>
                        <token postag="PRP:.*" postag_regexp="yes"/>
                        <token regexp="yes">der|die|das|den|ein|eine|dieser|dieses|sein|ihr</token>
                        <!--<token postag="ADJ:.*" postag_regexp="yes"/>-->
                        <token postag="SUB:.*" postag_regexp="yes"/>
                    </unify-ignore>
                    <token postag="PA2:.*" postag_regexp="yes"/>
                    <token postag="SUB:.*" postag_regexp="yes"/>
                </unify>
            </marker>
        </pattern>
        <disambig action="unify"/>
    </rule>

    <!-- ============================================================================================================== -->

    <rule name=".,;:…!? UNKNOWN -> PKT" id="UNKNOWN_PKT">
        <pattern>
            <marker>
                <token regexp="yes">[\.,;:…!\?]</token>
            </marker>
        </pattern>
        <disambig action="add"><wd pos="PKT"/></disambig>
    </rule>

    <rule name="en vogue" id="EN_VOGUE">
        <pattern>
            <marker>
                <token>en</token>
                <token>vogue</token>
            </marker>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="G7-Gipfel" id="Gx-GIPFEL">
        <pattern>
            <marker>
                <token regexp="yes">G[78]-Gipfel</token>
            </marker>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="Los Angeles" id="LOS_ANGELES">
        <pattern>
            <marker>
                <token>Los</token>
                <token>Angeles</token>
            </marker>
        </pattern>
        <disambig action="immunize"/>
    </rule>

    <rule name="Los Angeles" id="LAS_VEGAS">
        <pattern case_sensitive="yes">
            <marker>
                <token>Las</token>
                <token>Vegas</token>
            </marker>
        </pattern>
        <disambig action="immunize"/>
    </rule>

    <rule name="Mise en scène" id="MISE_EN_SCENE">
        <pattern>
            <marker>
                <token>Mise</token>
                <token>en</token>
                <token>scène</token>
            </marker>
        </pattern>
        <disambig action="immunize"/>
    </rule>

    <rule name="Rhythm and Blues" id="RHYTHM_AND_BLUES">
        <pattern>
            <marker>
                <token>Rhythm</token>
                <token>and</token>
                <token>Blues</token>
            </marker>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="Rock and Roll" id="ROCK_AND_ROLL">
        <pattern>
            <marker>
                <token>Rock</token>
                <token>and</token>
                <token>Roll</token>
            </marker>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="en gros" id="EN_GROS">
        <pattern>
            <marker>
                <token>en</token>
                <token>gros</token>
            </marker>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="Alexius Meinong" id="ALEXIUS_MEINONG">
        <pattern>
            <marker>
                <token>Alexius</token>
                <token regexp="yes">Meinongs?</token>
            </marker>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="starker Tobak" id="STARKER_TOBAK">
        <pattern>
            <marker>
                <token regexp="yes">alter|starker</token>
                <token>Tobak</token>
            </marker>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="Alfred Nobel" id="ALFRED_NOBEL">
        <pattern>
            <marker>
                <token>Alfred</token>
                <token>Nobel</token>
            </marker>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="São Paulo" id="SAO_PAULO">
        <pattern>
            <marker>
                <token>São</token>
                <token>Paulo</token>
            </marker>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="Open Source" id="OPEN_SOURCE">
        <pattern>
            <marker>
                <token>Open</token>
                <token>Source</token>
            </marker>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>
    <rule name="Open-Source-Software" id="OPEN_SOURCE_SOFTWARE">
        <pattern>
            <marker>
                <token>Open-Source-Software</token>
            </marker>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>
    <rule name="x-Jährige" id="x-JAEHRIGE">
        <pattern>
            <marker>
                <!-- "Zeit seines Lebens hat der 76-Jährige keine Häuser gebaut." (aber: hat der 76-jährige Architekt...) -->
                <token regexp="yes">\d+-Jährigen?</token>
            </marker>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>
    <rule name="Ein und Alles" id="EIN_UND_ALLES">
        <pattern>
            <!-- http://canoo.net/blog/2008/11/14/zum-einen-zum-anderen/ -->
            <marker>
                <token>Ein</token>
                <token>und</token>
                <token>Alles</token>
            </marker>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>
</rules>
