<?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>
            <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>
        </pattern>
        <disambig action="unify"/>
    </rule>
    <rule name="NP unify 1b" id="UNIFY_DET_SUB2">
        <pattern>
            <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>
        </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>
                <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>
        </pattern>
        <disambig action="unify"/>
    </rule>
    -->
    <rule name="NP unify 2" id="UNIFY_DET_ADJ_ADJ_SUB">
        <pattern>
            <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>
        </pattern>
        <disambig action="unify"/>
    </rule>
    <rule name="NP unify 2b" id="UNIFY_DET_ADJ_UND_ADJ_SUB">
        <pattern>
            <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>
        </pattern>
        <disambig action="unify"/>
    </rule>
    <rule name="NP unify 3" id="UNIFY_DET_ADJ_SUB">
        <pattern>
            <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>
        </pattern>
        <disambig action="unify"/>
    </rule>
    <rule name="NP unify 3b" id="UNIFY_ADJ_SUB">
        <pattern>
            <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>
        </pattern>
        <disambig action="unify"/>
    </rule>

    <rule name="NP unify 4" id="UNIFY_4">
        <pattern>
            <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>
        </pattern>
        <disambig action="unify"/>
    </rule>

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

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

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

    <rule name="en masse" id="EN_MASSE">
        <pattern>
            <token>en</token>
            <token>masse</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="Côte d'Azur" id="COTE_DAZUR">
        <pattern>
            <token>Côte</token>
            <token>d</token>
            <token regexp="yes">['’]</token>
            <token>Azur</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="Saucen" id="SAUCEN">
        <pattern>
            <token>Sauce</token>
            <token regexp='yes'>hollandaise|béarnaise|bordelaise|Bolognese|Béchamel</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

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

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

    <rule name="Los Alamos" id="LOS_ALAMOS">
        <pattern case_sensitive="yes">
            <token>Los</token>
            <token>Alamos</token>
        </pattern>
        <disambig action="immunize"/>
    </rule>

    <rule name="Valleys" id="VALLEYS">
        <pattern case_sensitive="yes">
            <token regexp="yes">Death|Silicon</token>
            <token>Valley</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="Oak Ridge" id="OAK_RIDGE">
        <pattern case_sensitive="yes">
            <token>Oak</token>
            <token>Ridge</token>
        </pattern>
        <disambig action="immunize"/>
    </rule>

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

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

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

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

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

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

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

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

    <rule name="Open Source" id="OPEN_SOURCE">
        <pattern>
            <token>Open</token>
            <token>Source</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>
    <rule name="Open-Source-Software" id="OPEN_SOURCE_SOFTWARE">
        <pattern>
            <token>Open-Source-Software</token>
        </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/ -->
            <token>Ein</token>
            <token>und</token>
            <token>Alles</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="à la carte" id="A_LA_CARTE">
        <pattern>
            <token>à</token>
            <token>la</token>
            <token>carte</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="Big Ben" id="BIG_BEN">
        <pattern>
            <token>Big</token>
            <token regexp="yes">Ben|Data</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="coram publico" id="CORAM_PUBLICO">
        <pattern>
            <token>coram</token>
            <token>publico</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="peu à peu" id="PEU_A_PEU">
        <pattern>
            <token>peu</token>
            <token>à</token>
            <token>peu</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="noch und nöcher" id="NOCH_UND_NOECHER">
        <pattern>
            <token>noch</token>
            <token>und</token>
            <token>nöcher</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="Coq au Vin" id="COQ_AU_VIN">
        <pattern>
            <token>Coq</token>
            <token>au</token>
            <token>Vin</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="Air Force" id="AIR_FORCE">
        <pattern>
            <token>Air</token>
            <token>Force</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="cui bono" id="CUI_BONO">
        <pattern>
            <token>Cui</token>
            <token>Bono</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="In- und Ausland" id="IN_UND_AUSLAND">
        <pattern>
            <token>In-</token>
            <token regexp='yes'>und|oder|beziehungsweise</token>
            <token>Ausland</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="in- und ausländisch" id="IN_UND_AUSLAENDISCH">
        <pattern>
            <token>in-</token>
            <token regexp='yes'>und|oder|beziehungsweise</token>
            <token regexp='yes'>ausländisch(e|er|es|em|en)?</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="Memento mori" id="MEMENTO_MORI">
        <pattern>
            <token>Memento</token>
            <token>mori</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

    <rule name="Fair Play" id="FAIR_PLAY">
        <!-- http://www.korrekturen.de/wortliste/fair_play.shtml -->
        <pattern case_sensitive="yes">
            <token>Fair</token>
            <token>Play</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>
    
    <rule name="University of" id="UNIVERSITY_OF">
        <pattern case_sensitive="yes">
            <token>University</token>
            <token>of</token>
        </pattern>
        <disambig action="ignore_spelling"/>
    </rule>

</rules>
