<?xml version="1.0" encoding="utf-8"?>

<transfer>
  <section-def-cats>

    <!-- this shouldn't include 'sent' or other punctuation -->
   <def-cat n="main-reading">
      <cat-item tags="n"/> <!-- In case of abessive SIZ it's <n>+<post.*> without the <nom> tag-->
      <cat-item tags="n.*"/>
      <cat-item tags="np.*"/>
      <cat-item tags="adj"/>
      <cat-item tags="adj.*"/>
      <cat-item tags="num.*"/>
      <cat-item tags="prn.*"/>
      <cat-item tags="det.*"/>
      <cat-item tags="v.*"/>
      <cat-item tags="vaux.*"/>
      <cat-item tags="adv.*"/>
      <cat-item tags="post.*"/>
      <cat-item tags="postadv.*"/>
      <cat-item tags="cnjcoo.*"/>
      <cat-item tags="cnjsub.*"/>
      <cat-item tags="cnjadv.*"/>
      <cat-item tags="ij.*"/>
      <cat-item tags="abbr.*"/>
      <cat-item tags="cop.*"/>
      <cat-item tags="part.*"/>
      <cat-item tags="ideo.*"/>
    </def-cat>

    <def-cat n="sub-reading1">
      <!-- Personal copulas and abessive/privative postposition -->
      <cat-item tags="cop.p1.*"/>
      <cat-item tags="cop.p2.*"/>
      <cat-item tags="cop.p3.*"/>
      <cat-item lemma="sız" tags="post"/>
      <cat-item lemma="sız" tags="post.*"/>
      <cat-item lemma="lı" tags="post"/>
      <cat-item lemma="lı" tags="post.*"/>
    </def-cat>

    <def-cat n="sub-reading2">
      <!-- Every other thing in Karakalpak which most likely will be translated
           with a clitic. Can appear after cat="sub-reading1" -->
      <cat-item tags="qst"/>
      <cat-item tags="mod_ass"/>
      <cat-item tags="mod_ind"/>
      <cat-item tags="emph"/>
      <cat-item tags="postadv"/>
      <cat-item lemma="da" tags="cnjcoo"/>
    </def-cat>

  </section-def-cats>

  <section-def-attrs>
    <def-attr n="a_qst">
      <attr-item tags="qst"/>
    </def-attr>
  </section-def-attrs>

  <section-def-vars>
    <def-var n="a" v="~"/>
  </section-def-vars>

  <section-def-lists>
    <def-list n="karakalpak_clitics">
      <list-item v="shı"/>
      <list-item v="ma"/>
      <list-item v="meken"/>
      <list-item v="g'oy"/>
      <list-item v="-aq"/>
      <list-item v="g'ana"/>
      <list-item v="da"/>
    </def-list>
  </section-def-lists>

  <section-rules>

    <rule>
      <pattern>
        <pattern-item n="main-reading"/>
      </pattern>
      <action>
        <out>
          <var n="a"/>
          <lu>
            <clip pos="1" side="tl" part="whole"/>
          </lu>
        </out>
      </action>
    </rule>

    <rule comment="REGLA: 2a;
      For sequence [stem + personal copula/abessive + other clitics]">
      <pattern>
        <pattern-item n="main-reading"/>
        <pattern-item n="sub-reading1"/> <!-- Personal copulas/Abessive -->
        <pattern-item n="sub-reading2"/> <!-- All other clitics -->
      </pattern>
      <action>
	<choose>
	  <when>
	    <test>
	      <in caseless="yes">
		<clip pos="3" side="tl" part="lem"/>
		<list n="karakalpak_clitics"/>
	      </in>
	    </test>
	    <out>
	      <mlu>
		<lu>
		  <clip pos="1" side="tl" part="whole"/>
		</lu>
		<lu>
		  <clip pos="2" side="tl" part="whole"/>
		</lu>
		<lu>
		  <clip pos="3" side="tl" part="whole"/>
		</lu>
	      </mlu>
	    </out>
	  </when>
	  <otherwise>
	    <out>
	      <mlu>
		    <lu>
	    	  <clip pos="1" side="tl" part="whole"/>
	    	</lu>
	    	<lu>
	    	  <clip pos="2" side="tl" part="whole"/>
	    	</lu>
	      </mlu>
	      <b/>
          <lu>
	        <clip pos="3" side="tl" part="whole"/>
	      </lu>
	    </out>
	  </otherwise>
	</choose>
      </action>
    </rule>

    <rule comment="REGLA: 2b; makes personal copulas/abessive to clitics">
      <pattern>
        <pattern-item n="main-reading"/>
        <pattern-item n="sub-reading1"/> <!-- Personal copulas/Abessive -->
      </pattern>
      <action>
        <out>
          <mlu>
            <lu>
              <clip pos="1" side="tl" part="whole"/>
            </lu>
            <lu>
              <clip pos="2" side="tl" part="whole"/>
            </lu>
          </mlu>
        </out>
      </action>
    </rule>

    <rule comment="REGLA:3;
      makes stuff contained in list=karakalpak_clitics to clitics">
      <pattern>
	<pattern-item n="main-reading"/>
	<pattern-item n="sub-reading2"/>
      </pattern>
      <action>
	<choose>
	  <when>
	    <test>
	      <in caseless="yes">
		<clip pos="2" side="tl" part="lem"/>
		<list n="karakalpak_clitics"/>
	      </in>
	    </test>
	    <out>
	      <mlu>
		<lu>
		  <clip pos="1" side="tl" part="whole"/>
		</lu>
		<lu>
		  <clip pos="2" side="tl" part="whole"/>
		</lu>
	      </mlu>
	    </out>
	  </when>
	  <otherwise>
	    <out>
	      <lu>
		<clip pos="1" side="tl" part="whole"/>
	      </lu>
	      <b/>
	      <lu>
		<clip pos="2" side="tl" part="whole"/>
	      </lu>
	    </out>
	  </otherwise>
	</choose>
      </action>
    </rule>

  </section-rules>

</transfer>