Difference between revisions of "Cross Model Elements"

From Apertium
Jump to navigation Jump to search
Line 81: Line 81:
 
== Values for <code>&lt;s></code> element ==
 
== Values for <code>&lt;s></code> element ==
   
 
=== Literals ===
<!--
 
=== Constants ===
 
   
  +
<e>
* Constants are elements in lower-case. For example, <code>m</code>, <code>adj</code>, etc.
 
  +
&lt;p>
  +
<r>$lemmaA<s n="adj"/></l>
  +
<r>$lemmaB<s n="adj"/></r>
  +
</p>
  +
</e>
  +
  +
Use literals (as in <code><s n="adj"/></code>) to match exactly that element.
   
 
=== Variables ===
 
=== Variables ===
Line 90: Line 96:
 
There are two types of variables:
 
There are two types of variables:
   
# '''X-elements''': one <code>&lt;s></code> element. Example: <code>&lt;s n="X1"/></code>
+
* '''<code>$</code>-elements''': one <code>&lt;s></code> element. For example, <code>&lt;s n="$cat"/></code> can refer to <code>&lt;s n="adj"/></code>.
# '''S-elements''': lists of <code>&lt;s></code> elements. Example: <code>&lt;s n="S1"/></code>
+
* '''<code>@</code>-elements''': are used to indicate a sequence of <code>&lt;s></code> elements. In this case, <code>&lt;s n="@tail"/></code>, can refer to the sequence <code><s n="n"/><s n="m"/><s n="sg"/></code>
  +
-->
 
  +
Example:
  +
  +
<e>
  +
&lt;p>
  +
<l>$lemmaA<s n="'''$cat'''"/><s n="'''@tailA'''"/></l>
  +
<r>$lemmaB<s n="$cat"/><s n="*"/></r>
  +
</p>
  +
</e>
  +
  +
  +
If you are not interested in storing the value to use it afterwards, there are 2 other symbols available: <code>?</code> and <code>*</code>:
  +
* '''<code>?</code>''': same pattern as in <code>$</code>-elements.
  +
* '''<code>*</code>''': same pattern as in <code>@</code>-elements.
  +
  +
Example:
  +
  +
<e>
  +
&lt;p>
  +
<l>$lemmaA<s n="n"/>'''<s n="?"/>'''<s n="sg"/></l>
  +
<r>$lemmaB<s n="n"/>'''<s n="*"/>'''</r>
  +
</p>
  +
</e>
  +
  +
In the example above, <code><s n="?"/></code> might be either <code><s n="m"/></code>, <code><s n="f"/></code>, etc, but the value is not stored in a variable because it's not used in any other place in the cross action.
   
 
[[Category:Documentation]]
 
[[Category:Documentation]]

Revision as of 10:57, 8 February 2008

Main article: Cross Model

cross-model element

cross-model element is a set of cross actions (cross-action elements).

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

cross-action element

Each cross actions consists of a pair (pattern,action-set).

<cross-action id="pattern-1" a="author">
  <description>Cross action 1</description>
  <pattern>
    ...
  </pattern>
  <action-set>
    <action>
      ...
    </action>
    ...
    <action>
      ...
    </action>
  </action-set>
</cross-action>

pattern element

<pattern>
  <!-- Element in bilingual dictionary AB-->
  <e>
    <p>
      <l>$lemmaA...</l>
      <r>$lemmaB...</r>

  </e>
  <!-- Element in bilingual dictionary BC-->
  <e r="RL">
    <p>
      <l>$lemmaB...</l>
      <r>$lemmaC...</r>

  </e>
</pattern>

action-set element

The action-set element is a list of actions to be performed when a pair of candidate elements matches the pattern.

<action-set>
  <action>
    <e>
      <p>
        <l>$lemmaA...</l>
        <r>$lemmaC...</r>

    </e>
  </action>
  <action>
  ...
  </action>
</action-set>

Values for <s> element

Literals

<e>
  <p>
    <r>$lemmaA</l>
    <r>$lemmaB</r>

</e>

Use literals (as in ) to match exactly that element.

Variables

There are two types of variables:

  • $-elements: one <s> element. For example, <s n="$cat"/> can refer to <s n="adj"/>.
  • @-elements: are used to indicate a sequence of <s> elements. In this case, <s n="@tail"/>, can refer to the sequence

Example:

<e>
  <p>
    <l>$lemmaA</l>
    <r>$lemmaB</r>

</e>


If you are not interested in storing the value to use it afterwards, there are 2 other symbols available: ? and *:

  • ?: same pattern as in $-elements.
  • *: same pattern as in @-elements.

Example:

<e>
  <p>
    <l>$lemmaA</l>
    <r>$lemmaB</r>

</e>

In the example above, might be either , , etc, but the value is not stored in a variable because it's not used in any other place in the cross action.