Difference between revisions of "User:Popcorndude/Recursive Transfer"

From Apertium
Jump to navigation Jump to search
(Created page with " == Coding Challenge == All my code is on GitHub at https://github.com/mr-martian/GSoC19-recursive So far (as of 3/4/19) I have reimplemented the Python script from the pro...")
 
(use real example)
Line 9: Line 9:
Example:
Example:


cat = a b c;
gender = m f;
#lex $cat -> #(x.$cat);
#noun $gender -> #(n.$gender);
node $cat -> lex lex { 2 1 } ;
#adj $gender -> #(adj.$gender);
NP $gender -> noun adj { 2 1 } ;


The defines a category "cat" consisting of &lt;a&gt;, &lt;b&gt;, and &lt;c&gt;. It then defines a terminal node type "lex" which matches things of the form "lemma<x><C>", where C is in cat. The last line defines a non-terminal node "node" which matches two lexs and swaps them. It is parameterized by the cat, as is lex, so the result is that this will match "soup<x><a> sandwich<x><a>" or "blah<x><c> bloop<x><c>" but not "sheep<x><a> shoop<x><c>".
The defines a category "gender" consisting of &lt;m&gt; and &lt;f&gt;. The lexical categories "noun" and "adj", matching things of the form "word<n><C>" and "word<adj><C>", respectively, where C is <m> or <f>. The last line defines a non-terminal node "NP" which matches a noun followed by an adjective of the same gender, so "carro<n><m>/car<n> rojo<adj><m>/red<adj>" would become "rojo<adj><m>/red<adj> carro<n><m>/car<n>" but "carro<n><m>/car<n> roja<adj><f>" would not be matched.

Revision as of 00:45, 5 March 2019


Coding Challenge

All my code is on GitHub at https://github.com/mr-martian/GSoC19-recursive

So far (as of 3/4/19) I have reimplemented the Python script from the prototype and added support for attribute categories and parameterized nodes.

Example:

gender = m f;
#noun $gender -> #(n.$gender);
#adj $gender -> #(adj.$gender);
NP $gender -> noun adj { 2 1 } ;

The defines a category "gender" consisting of <m> and <f>. The lexical categories "noun" and "adj", matching things of the form "word<n><C>" and "word<adj><C>", respectively, where C is <m> or <f>. The last line defines a non-terminal node "NP" which matches a noun followed by an adjective of the same gender, so "carro<n><m>/car<n> rojo<adj><m>/red<adj>" would become "rojo<adj><m>/red<adj> carro<n><m>/car<n>" but "carro<n><m>/car<n> roja<adj><f>" would not be matched.