Cross-model ro

From Apertium
Revision as of 17:02, 9 January 2011 by Cristipiticul (talk | contribs)
Jump to navigation Jump to search
Main article: Crossdics

Cross Model

Definirea acţiunilor de încrucişare (cross actions)

Acţiunile de încrucişare sunt necesare pentru încrucişarea corectă a perechilor de limbi.

Aceste tipare şi acţiuni sunt descrise în XML. De exemplu:

<!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>

Exemplu de acţiune-tipar (pattern-action)

Tipar

<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>

Exemplu cum această acţiune de încrucişare ar putea fi aplicată.

Acţiune de încrucişare implicită

Implicit, unealta apertium-crossdics foloseşte un model de încrucişare simplu (schemas/cross-model.xml). Acesta defineşte o singură regulă pattern-action.

<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>

În exemplul de mai sus:

  • <v n="cat"/> este o variabilă care poate reţine doar un element (de exemplu, ). În acest exemplu am folosit o variabilă deoarece avem nevoie să folosim valoarea în elementul action. Mai forţăm şi valoarea primului element să fie identică. Acolo mai este un simbol (<v/>) care poate fi folosit dacă nu vrem să folosim apoi valoarea.
  • Eticheta <t/> este o secvenţă de 0 sau mai multe elemente .
  • <t n="tailA"/> şi <t n="tailC"/> sunt de asemenea secvenţe de 0 sau mai multe elemente , dar, în acest caz particular, stocăm valoarea într-o variabilă pentru că trebuie să o folosim apoi (în elementul action).

Vezi şi

Linkuri externe

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:

  • <v n="..."/> tag: one <s> element. For example, <v n="cat"/> can refer to <s n="adj"/>. Value "adj" will be stored in variable "cat".
  • <t n="..."/> tag: is used to indicate a sequence of <s> elements. In this case, <t n="tail"/>, can refer to the sequence . Sequence "n.m.sg" will be stored in variable "tail".

Example:

<e>
  <p>
    <l>$lemmaA<v n="cat"/><t n="tailA"/></l>
    <r>$lemmaB<v n="cat"/><t/></r>

</e>

If you are not using the value of <v...> or <t...>, do not define any n attribute, that is:

  • <v/>: 1 element.
  • <t/>: 0 or more element(s).

Example:

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

</e>

In the example above, <v/> 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.