Difference between revisions of "Cross Model"

From Apertium
Jump to navigation Jump to search
(Default pattern example added)
(Link to French page)
 
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Modèle croisé|En français]]

{{main|Crossdics}}
{{main|Crossdics}}


== Cross Model ==
== Cross Model ==


=== Defining cross actions ===
By default, the <code>apertium-crossdics</code> tool uses a simple cross model (<code>schemas/cross-model.xml</code>) defining only a default pattern-action rule.

<cross-model>
<cross-action id="default" a="ebenimeli">
<description>'''Default pattern'''</description>
<pattern>
<e>
$lt;p>
<l>'''$lemmaA'''<s n="'''$cat'''"/><s n="'''@tailA'''"/></l>
<r>'''$lemmaB'''<s n="'''$cat'''"/><s n="'''*'''"/></r>
</p>
</e>
<e>
$lt;p>
<l>'''$lemmaB'''<s n="'''$cat'''"/><s n="'''*'''"/></l>
<r>'''$lemmaC'''<s n="'''$cat'''"/><s n="'''@tailC'''"/></r>
</p>
</e>
</pattern>
<action-set>
<action>
<e>
$lt;p>
<l>'''$lemmaA'''<s n="'''$cat'''"/><s n="'''@tailA'''"/></l>
<r>'''$lemmaC'''<s n="'''$cat'''"/><s n="'''@tailC'''"/></r>
</p>
</e>
</action>
</action-set>
</cross-action>
</cross-model>


Cross actions are needed to cross certain language pairs correctly.


However, more specific cross actions might be needed in order to cross certain language pairs correctly. Defining a new '''cross schema''' with concrete '''pattern-action''' elements solves this problem.


These patterns and actions are described in XML, as follows:
These patterns and actions are described in XML, as follows:
Line 56: Line 26:
Click on each element in the schema above or read more about [[Cross Model Elements|cross model elements]].
Click on each element in the schema above or read more about [[Cross Model Elements|cross model elements]].


== Example of pattern-action ==
=== Example of pattern-action ===


=== Pattern ===
==== Pattern ====
<cross-action id="pattern-1" a="ebenimeli">
<cross-action id="pattern-1" a="ebenimeli">
<description>Pattern 1</description>
<description>Pattern 1</description>
Line 64: Line 34:
<e>
<e>
&lt;p>
&lt;p>
<l>'''$lemmaA'''<s n="'''n'''"/><s n="'''$X'''"/></l>
<l>'''$lemmaA'''<s n="'''n'''"/><v n="'''X'''"/></l>
<r>'''$lemmaB'''<s n="'''n'''"/><s n="'''$Y'''"/></r>
<r>'''$lemmaB'''<s n="'''n'''"/><v n="'''Y'''"/></r>
</p>
</p>
</e>
</e>
Line 79: Line 49:
<e>
<e>
&lt;p>
&lt;p>
<l>'''$lemmaA'''<s n="'''n'''"/><s n="'''$X'''"/></l>
<l>'''$lemmaA'''<s n="'''n'''"/><v n="'''X'''"/></l>
<r>'''$lemmaC'''<s n="'''n'''"/><s n="'''$Y'''"/></r>
<r>'''$lemmaC'''<s n="'''n'''"/><v n="'''Y'''"/></r>
</p>
</p>
</e>
</e>
Line 88: Line 58:


[[Pattern-Action example|Example]] of how this cross action could be applied.
[[Pattern-Action example|Example]] of how this cross action could be applied.

=== Default cross action ===
By default, the <code>apertium-crossdics</code> tool uses a simple cross model (<code>schemas/cross-model.xml</code>) defining only a default pattern-action rule.

<cross-model>
<cross-action id="default" a="ebenimeli">
<description>'''Default pattern'''</description>
<pattern>
<e>
&lt;p>
<l>'''$lemmaA'''<v n="'''cat'''"/><t n="'''tailA'''"/></l>
<r>'''$lemmaB'''<v n="'''cat'''"/><t/></r>
</p>
</e>
<e>
&lt;p>
<l>'''$lemmaB'''<v n="'''cat'''"/><t/></l>
<r>'''$lemmaC'''<v n="'''cat'''"/><t n="'''tailC'''"/></r>
</p>
</e>
</pattern>
<action-set>
<action>
<e>
&lt;p>
<l>'''$lemmaA'''<v n="'''cat'''"/><t n="'''tailA'''"/></l>
<r>'''$lemmaC'''<v n="'''cat'''"/><t n="'''tailC'''"/></r>
</p>
</e>
</action>
</action-set>
</cross-action>
</cross-model>

In the example above:
* <code><v n="cat"/></code> is a variable that can store just one element (for example, <code><s n="adj"/></code>). In this example we use a variable because we need to use the value in the <code>action</code> element. Besides that, we force the value of the first <code><s n="..."/></code> element to be the same. There is another symbol (<code><v/></code>) that can be used if we don't want to use the value afterwards.
* the tag <code><t/></code> is a sequence of 0 or more <code><s n="..."/></code> elements.
* <code><t n="tailA"/></code> and <code><t n="tailC"/></code> are also sequences of 0 or more <code><s n="..."/></code> elements, but, in this particular case, we store the value in a variable because we need to use it afterwards (in the <code>action</code> element).

These special tags are explained in the section [[Cross_Model_Elements#Values_for_.3Cs.3E_element|Cross Model Elements]]

==Limitations==
Some pairs use bidix pardefs, e.g.
<pre><e><p><l>lemmaA</l><r>lemmaB</r></p> <par n="vblex_adj"/></e></pre>

It does not seem to be possible to put par elements into the crossmodel. What you can do is run
<pre>
awk '/<par [^>]*n="vblex_adj"/{gsub(/<\/[lr]>/, "<s n=\"vblex_adj\"/>&")} {print}' <orig.bi.dix >new.bi.dix
</pre>
to add a fake s-tag, then run crossdics, and then remove the fake s-tag afterwards. This seems to work.


== See also ==
== See also ==
Line 97: Line 117:
* [http://apertium.svn.sourceforge.net/viewvc/apertium/trunk/apertium-crossdics/schemas/crossmodel.dtd?view=markup&sortby=date Cross model DTD]
* [http://apertium.svn.sourceforge.net/viewvc/apertium/trunk/apertium-crossdics/schemas/crossmodel.dtd?view=markup&sortby=date Cross model DTD]


[[Category:Documentation]]
[[Category:Dixtools]]
[[Category:Documentation in English]]

Latest revision as of 08:39, 6 October 2014

En français

Main article: Crossdics

Cross Model[edit]

Defining cross actions[edit]

Cross actions are needed to cross certain language pairs correctly.

These patterns and actions are described in XML, as follows:

<!DOCTYPE cross-model SYSTEM "crossmodel.dtd">
<cross-model>
  <cross-action id="pattern-1" a="author">
    <pattern>...</pattern>
    <action-set>...</action-set>
  </cross-action>
  ...
  <cross-action id="pattern-n" a="author">
    <pattern>...</pattern>
    <action-set>...</action-set>
  </cross-action>
</cross-model>

Click on each element in the schema above or read more about cross model elements.

Example of pattern-action[edit]

Pattern[edit]

<cross-action id="pattern-1" a="ebenimeli">
  <description>Pattern 1</description>
  <pattern>
    <e>
      <p>
        <l>$lemmaA<v n="X"/></l>
        <r>$lemmaB<v n="Y"/></r>

    </e>
    <e r="RL">
      <p>
        <l>$lemmaB</l>
        <r>$lemmaC</r>

    </e>
  </pattern>
  <action-set>
    <action>
      <e>
        <p>
          <l>$lemmaA<v n="X"/></l>
          <r>$lemmaC<v n="Y"/></r>

      </e>
    </action>
  </action-set>
</cross-action>

Example of how this cross action could be applied.

Default cross action[edit]

By default, the apertium-crossdics tool uses a simple cross model (schemas/cross-model.xml) defining only a default pattern-action rule.

<cross-model>
  <cross-action id="default" a="ebenimeli">
    <description>Default pattern</description>
    <pattern>
      <e>
        <p>
          <l>$lemmaA<v n="cat"/><t n="tailA"/></l>
          <r>$lemmaB<v n="cat"/><t/></r>

      </e>
      <e>
        <p>
          <l>$lemmaB<v n="cat"/><t/></l>
          <r>$lemmaC<v n="cat"/><t n="tailC"/></r>

      </e>
    </pattern>
    <action-set>
      <action>
        <e>
          <p>
            <l>$lemmaA<v n="cat"/><t n="tailA"/></l>
            <r>$lemmaC<v n="cat"/><t n="tailC"/></r>

        </e>
      </action>
    </action-set>
  </cross-action>
</cross-model>

In the example above:

  • <v n="cat"/> is a variable that can store just one element (for example, ). In this example we use a variable because we need to use the value in the action element. Besides that, we force the value of the first element to be the same. There is another symbol (<v/>) that can be used if we don't want to use the value afterwards.
  • the tag <t/> is a sequence of 0 or more elements.
  • <t n="tailA"/> and <t n="tailC"/> are also sequences of 0 or more elements, but, in this particular case, we store the value in a variable because we need to use it afterwards (in the action element).

These special tags are explained in the section Cross Model Elements

Limitations[edit]

Some pairs use bidix pardefs, e.g.

<e><p><l>lemmaA</l><r>lemmaB</r></p> <par n="vblex_adj"/></e>

It does not seem to be possible to put par elements into the crossmodel. What you can do is run

awk '/<par [^>]*n="vblex_adj"/{gsub(/<\/[lr]>/, "<s n=\"vblex_adj\"/>&")} {print}' <orig.bi.dix >new.bi.dix

to add a fake s-tag, then run crossdics, and then remove the fake s-tag afterwards. This seems to work.

See also[edit]

External links[edit]