Difference between revisions of "Cross Model"

From Apertium
Jump to navigation Jump to search
(→‎Default cross action: --> new notation)
Line 91: Line 91:


In the example above:
In the example above:
* <code>$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>?</code>) that can be used if we don't want to use the value afterwards.
* <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 symbol <code>*</code> is a sequence of 0 or more <code><s n="..."/></code> elements.
* the tag <code><t/></code> is a sequence of 0 or more <code><s n="..."/></code> elements.
* <code>@tailA</code> and <code>@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).
* <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).


How to use these symbols (<code>?</code>,<code>*</code>) and variables (<code>$</code>, <code>@</code>) is explained in the section [[Cross_Model_Elements#Values_for_.3Cs.3E_element|Cross Model Elements]]
These special tags are explained in the section [[Cross_Model_Elements#Values_for_.3Cs.3E_element|Cross Model Elements]]


== See also ==
== See also ==

Revision as of 10:14, 10 March 2008

Main article: Crossdics

Cross Model

Defining cross actions

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

Pattern

<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

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

See also

External links