<?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" ?>
<!--
Spanish Disambiguation Rules for LanguageTool
Copyright (C) 2011 Juan Martorell
-->
<rules lang="es" 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="S">
      <token postag="(N.{2}|[ADP].{3}|V.{4})[SN].*" postag_regexp="yes"/>
    </equivalence>

    <equivalence type="P">
      <token postag="(N.{2}|[ADP].{3}|V.{4})[PN].*" postag_regexp="yes"/>
    </equivalence>
  </unification>

  <unification feature="gender">
    <equivalence type="M">
      <token postag="(N.|[ADP].{2}|V.{3})[CM].*" postag_regexp="yes"/>
    </equivalence>

    <equivalence type="F">
      <token postag="(N.|[ADP].{2}|V.{3})[CF].*" postag_regexp="yes"/>
    </equivalence>
  </unification>

  <!-- D_R_N : Det + Adverbio + Nombre-->

  <rule id="D_R_N" name="Det + Adv +Nom">
    <pattern>
      <token postag="D.*" postag_regexp="yes"/>

      <marker>
        <token postag="R.*" postag_regexp="yes"/>
      </marker>

      <token postag="N.*" postag_regexp="yes"><exception>son</exception><exception postag="(C|SP).*" postag_regexp="yes"/></token>
    </pattern>

    <disambig action="filter" postag="R.*"/>
  </rule>

  <!-- DDN : Determinante posesivo + Determinante indefinido + Nombre -->

  <rule id="DDN_u" name="Det + Nom + Adj">
    <pattern>
      <marker>
        <unify>
          <feature id="gender"/>

          <feature id="number"/>

          <token postag="D.*" postag_regexp="yes"/>

          <token postag="D.*" postag_regexp="yes"/>

          <token postag="N.*" postag_regexp="yes"/>
        </unify>
      </marker>
    </pattern>

    <disambig action="unify"/>
  </rule>

  <!-- DNA : Det + Nombre + adjetivo-->

  <rule id="DNA" name="Det + Nom + Adj">
    <pattern>
      <marker>
        <unify>
          <feature id="gender"/>

          <feature id="number"/>

          <token postag="D.*" postag_regexp="yes"/>

          <token postag="N.*" postag_regexp="yes"/>

          <token postag="A.*" postag_regexp="yes"/>
        </unify>
      </marker>
    </pattern>

    <disambig action="unify"/>

    <example inputform="una[unir/VMM03S0,unir/VMSP1S0,unir/VMSP3S0,uno/DI0FS0,uno/PI0FS000]" outputform="una[uno/DI0FS0]" type="ambiguous">Es <marker>una</marker> ocasión romántica.</example>

    <example type="untouched">Es una romántica ocasión.</example>
  </rule>

  <!-- DAN : Determinante + Adjetivo + Nombre-->

  <rule id="DAN" name="Det + Adj + Nom">
    <pattern>
      <marker>
        <unify>
          <feature id="gender"/>

          <feature id="number"/>

          <token postag="D.*" postag_regexp="yes"/>

          <token postag="A.*" postag_regexp="yes"/>

          <token postag="N.*" postag_regexp="yes"><exception postag="[DC].*" postag_regexp="yes"/><exception regexp="yes">de|son</exception></token>
        </unify>
      </marker>
    </pattern>

    <disambig action="unify"/>

    <example inputform="una[unir/VMM03S0,unir/VMSP1S0,unir/VMSP3S0,uno/DI0FS0,uno/PI0FS000]" outputform="una[uno/DI0FS0]" type="ambiguous">Es <marker>una</marker> romántica ocasión.</example>

    <example type="untouched">Es una ocasión romántica.</example>
  </rule>

  <!-- NSN : Nom + Nom/Prep + Nom/Adj = prep -->

  <rule id="NSN" name="Nom + Nom/Prep + Nom/Adj">
    <pattern>
      <token postag="N.*" postag_regexp="yes"><exception postag="RN|CS" postag_regexp="yes"/></token>

      <marker>
        <token postag="S.*" postag_regexp="yes"/>
      </marker>

      <token postag="[NA].*" postag_regexp="yes"/>
    </pattern>

    <disambig action="filter" postag="S.*"/>
  </rule>

  <!-- ANA : Adj + Nom/Adj + Adj = Nom -->

  <rule id="ANA" name="Adj + Nom/Adj + Adj">
    <pattern>
      <token postag="A.*" postag_regexp="yes"><exception postag="N.*" postag_regexp="yes"/></token>

      <marker>
        <and>
          <token postag="N.*" postag_regexp="yes"/>

          <token postag="A.*" postag_regexp="yes"/>
        </and>
      </marker>

      <token postag="A.*" postag_regexp="yes"><exception postag="N.*" postag_regexp="yes"/></token>
    </pattern>

    <disambig action="filter" postag="N.*"/>
  </rule>

  <!--P_V Cuando está delante de un verbo, se trata de un pronombre-->

  <rule id="P_V" name="Pronombre + Verbo">
    <pattern>
      <marker>
        <and>
          <token postag="D.*" postag_regexp="yes"/>

          <token postag="[PN].*" postag_regexp="yes"/>
        </and>
      </marker>

      <token postag="V.*" postag_regexp="yes"><exception postag="N|V.N.*" postag_regexp="yes"/></token>
    </pattern>

    <disambig action="filter" postag="P.*|N.*"/>
  </rule>

  <!--D_AN Detrás de un determinante, va el nombre y no el adjetivo-->

  <rule id="D_AN" name="Art + Nom/Adj = Nom">
    <pattern>
      <token postag="D.*" postag_regexp="yes"><exception postag="R.*" postag_regexp="yes"/><exception>lo</exception></token>

      <marker>
        <and>
          <token postag="N.*" postag_regexp="yes"/>

          <token postag="A.*" postag_regexp="yes"/>

          <token negate_pos="yes" postag="V.*" postag_regexp="yes"/>
        </and>
      </marker>

      <token negate_pos="yes" postag="N.*" postag_regexp="yes"/>
    </pattern>

    <disambig action="filter" postag="N.*"/>

    <example inputform="blanca[blanco/AQ0FS0,blanco/NCFS000]" outputform="blanca[blanco/NCFS000]" type="ambiguous">Me gusta la <marker>blanca</marker>.</example>

    <example type="untouched">Eran demasiado siniestros.</example>
  </rule>

  <!-- D_N Cuando está delante de un nombre, se trata de un determinante.-->

  <rule id="D_N" name="Artículo + Nombre">
    <pattern>
      <marker>
        <token postag="D.*" postag_regexp="yes"><exception inflected="yes">todo</exception><exception postag="R.*" postag_regexp="yes"/></token>
      </marker>

      <token postag="[PNA].*" postag_regexp="yes"><exception postag="V.*" postag_regexp="yes"/></token>
    </pattern>

    <disambig action="filter" postag="D.*"/>
  </rule>


  <!--sobre (no preposición, nombre)-->
  <rule id="SOBRE" name="sobre (nombre)">
    <pattern>
      <token postag="D..MS." postag_regexp="yes"><exception inflected="yes">todo</exception><exception postag="R.*" postag_regexp="yes"/></token>
      <marker>  
         <token postag="NCMS000">sobre</token>
      </marker>
      <token><exception postag="D.*" postag_regexp="yes"/></token>
    </pattern>

    <disambig action="filter" postag="N.*"/>
    <example type="untouched">Este sobre el otro.</example>
  </rule>

  
  <!-- P_N Posesivo + nombre -->
  <rule id="PN" name="Pos + Nom ">
    <pattern>
      <marker>
        <unify>
          <feature id="gender"/>
          <feature id="number"/>
          <token postag="DP.*" postag_regexp="yes"/>
          <token postag="N.*" postag_regexp="yes"><exception postag="C.|S.*|R.*" postag_regexp="yes"/></token>
        </unify>
      </marker>
    </pattern>
    
    <disambig action="unify"/>
    <!--example: su hermano-->
  </rule>
  
  <rule id="PUNCT" name="puntuación">
    <pattern>
      <token regexp="yes">[.;:!?…()\[\]&#8210;&#8211;&#8212;&#8213;\-]</token>
    </pattern>
    <disambig action="add"><wd pos="_PUNCT"></wd></disambig>
  </rule>
  
  <!-- ROMAN NUMERALS : Detección de números romanos (adaptado de la versión catalana) -->
  <rule id="ROMAN_NUMERALS" name="números romanos">
    <pattern case_sensitive="yes">
      <marker>
        <token regexp="yes">(?=.)M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})</token>
      </marker>
    </pattern>
    <disambig action="ignore_spelling"/>
  </rule>
  
</rules>
