Index

From UNL Wiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
Indexes (%) are used for co-indexing nodes, attributes and values inside and between the left and the right side of [[T-rule]]s.
+
Indexes (%) are used for co-indexing nodes in [[T-rule]]s and [[D-rule]]s.
  
== Use ==
+
=== T-rules ===
:X(%a;)Y(%a;) (the first node of X is also the first node of Y)
+
In [[T-rule]]s, indexes are used:
:X(%a;%b):=Y(%b;%a); (the first node of X becomes the second node of Y, and the second node of X becomes the first node of Y)
+
*to associate nodes in the left side of the rule (CONDITION) to nodes in the right side of the rule (ACTION):
:X(%a;)Y(%a;):=Z(%a); (if the first node of X is the first node of Y then make it the single node of Z)
+
:*(%a)(%b)(%c):=(%b); (delete the first and the third nodes, and keep the second)
<blockquote>Any co-indexation is made by the use of indexes and not by the repetition of features. In that sense, '''X(A;)Y(A;)''' is different from '''X(%a;)Y(%a;)'''. In the former case, the first node of X is not necessarily the first node of Y, they only share the same feature A; in the latter case, the first node of X is necessarily the first node of Y.</blockquote>
+
:*(%a)(%b)(%c):=(%c)(%b)(%a); (reverse the order)
;
+
:*rel(%a;%b;%c):=rel(%a;%b); (remove the third argument of the relation rel)
;Indexes may also be used to transfer attribute values expressed in the format ATTRIBUTE=VALUE:
+
:*rel(%a;%b;%c):=rel(%c;%b;%a); (reverse the order of the arguments of the relation rel)
:X(A,%a,ATT1=VAL1;B,%b):=X(%a;%b,ATT1=%a); (the value "VAL1" of "ATT1" of %a is copied to the node %b)
+
*to associate nodes within the left side of the rules
 +
:*(%a)(%b)(%a):=(%b); (delete the first and the third nodes, if they are the same)
 +
:*rel1(%a;%b)rel2(%a;%c):=rel3(%a;%c); (replace the relations rel1 and rel2 by the relation rel3 if the first argument of rel1 is the first argument of rel2)
 +
*to copy values of attributes between nodes
 +
:*(%a)(%b):=(%a)(%b,GEN=%a); (copy the value of the attribute GEN from the node %a to the node %b if the node %b comes after the node %a)
 +
:*NA(%a;%b):=NA(%a;%b,GEN=%b); (copy the value of the attribute GEN from the node %a to the node %b if there is a relation NA between them)
 +
*to test values of attributes within the left side of the rules
 +
:*(%a)(%b,GEN=%a):=; (delete the nodes %a and %b if they have the same value of the attribute GEN)
 +
:*rel1(%a;%b,GEN=%b):=rel2(%a;%b); (replace the relation rel1 by rel2 if the arguments of rel1 have the same value of the attribute GEN)
  
== Syntax ==
+
=== D-rules ===
Indexes are made of any sequence of alphanumeric characters and underscore preceded by %:
+
In [[D-rule]]s, indexes are used to test values of attributes within the left side of the rules
 +
:*(%a,ART)(%b,NOU,GEN=%a)=1; (nouns following articles normally have the same gender of the article)
 +
 
 +
=== Syntax ===
 +
Indexes are made of any sequence of alphanumeric characters and underscore preceded by % and starting by alphabetic characters:
 
:%index
 
:%index
 
:%a
 
:%a
Line 17: Line 29:
 
:%a1
 
:%a1
 
:<strike>%first index</strike> (no blank spaces are allowed)
 
:<strike>%first index</strike> (no blank spaces are allowed)
<blockquote>%01 (numbers are used for default indexation and must be avoided - see below)</blockquote>
+
:<strike>%_a</strike> (indexes must start with alphabetic characters)
 +
:<strike>%03</strike> (numeric characters cannot be used as user-defined indexes)
  
== Indexation ==
+
=== Default Indexation ===
;Default indexation
+
If not explicitly informed, indexation is done automatically by the machine, as follows:
:If omitted, indexes are assigned by default, according to the following rules:
+
*if the '''number of nodes is the same''' in the left and in the right side, NODES ARE CO-INDEXED, starting from left to right
:Default indexes are assigned from left to right in each side of the rule according to the position of the nodes:
+
*:("a")("b")("c"):=("d")("e")("f"); is the same as ("a",%01)("b",%02)("c",%03):=("d",%01)("e",%02)("f",%03); (i.e., "a" will be replaced by "d", "b" by "e", and "c" by "f")
::X(A;B)Y(C;D) is the same as X('''%01''',A;'''%02''',B)Y('''%03''',C;'''%04''',D)
+
*:rel("a";"b";"c"):=rel("d";"e";"f"); is the same as rel("a",%01;"b",%02;"c",%03):=rel("d",%01;"e",%02;"f",%03);
:Default indexation is done only for non-indexed nodes (i.e., user-defined indexes prevail over indexes assigned by default):
+
*if the '''number of nodes is not the same''' in both sides, NODES ARE NOT CO-INDEXED
::X(A,%A;B)Y(C,%C;D) is the same as X(A,%A;B,'''%02''')Y(C,%C;'''%04''',D)
+
*:("a")("b")("c"):=("d")("e"); is the same as ("a",%01)("b",%02)("c",%03):=("d",%04)("e",%05); (i.e., "a", "b" and "c" will be deleted, and "d" and "e" will be created)
:::(Notice that the user-defined indexes %A and %C are preserved and not replaced by default indexes)
+
*:rel("a";"b";"c"):=rel("d";"e"); is the same as rel("a",%01;"b",%02;"c",%03):=rel("d",%04;"e",%05);
:In default indexation, left-side nodes are automatically co-indexed with right-side nodes '''if and only if''' their position and number are the same:
+
Default indexes are also assigned to hyper-nodes and sub-nodes by the notation <PARENT NODE><CHILD NODE>, where <PARENT NODE> may be, itself, a sub-node:
::X(A;B):=Y(C;D); is the same as X('''%01''',A;'''%02''',B):=Y('''%01''',C;'''%02''',D);
+
:*(((A))):=(((B))); is the same as (%01(%01%01(%01%01%01,A))):=(%01(%01%01(%01%01%01,B)));
::X(A;B):=Y(C;D;E); is the same as X('''%01''',A;'''%02''',B):=Y('''%03''',C;'''%04''',D;'''%05''',E);
+
:*X(Y(A;B);C) is the same as X('''%01''',Y('''%01%01''',A;'''%01%02''',B);'''%02''')
:::(there is no co-indexation between the left and the right side in the latter case, because the number of the nodes is not the same)
+
::*%01 = Y(A;B), %02 = C, %01%01 = A, %01%02 = B
:Default indexes are also assigned to hyper-nodes and sub-nodes
+
:*X(Y(Z(A;B);C);D) is the same as X('''%01''',Y('''%01%01''',Z('''%01%01%01''',A;'''%01%01%02''',B);'''%01%02''',C);'''%02''',D)
::(((A))):=(((B))); is the same as (%01(%01%01(%01%01%01,A))):=(%01(%01%01(%01%01%01,B)));
+
::*%01 = Y(Z(A;B);C), %02 = D, %01%01 = Z(A;B), %01%02 = C, %01%01%01 = A, %01%01%02 = B
:In default indexation, sub-nodes are informed by the syntax <PARENT NODE><CHILD NODE>, where <PARENT NODE> may be, itself, a sub-node:
+
In order to avoid ambiguities, it is highly recommended that indexes are replaced by user-defined labels made of any sequence of alphabetic characters and underscore:
::X(Y(A;B);C) is the same as X('''%01''',Y('''%01%01''',A;'''%01%02''',B);'''%02''')
+
:("a",%a)("b",%b):=("c",%a)("d",%b); instead of (A)(B):=(C)(D);
:::%01 = Y(A;B), %02 = C, %01%01 = A, %01%02 = B
+
::X(Y(Z(A;B);C);D) is the same as X('''%01''',Y('''%01%01''',Z('''%01%01%01''',A;'''%01%01%02''',B);'''%01%02''',C);'''%02''',D)
+
:::%01 = Y(Z(A;B);C), %02 = D, %01%01 = Z(A;B), %01%02 = C, %01%01%01 = A, %01%01%02 = B
+
;Non-indexed nodes in the right side means ADDITION, whereas left-side nodes that are not referred to in the right side means DELETION
+
:X(%a;%b):=Y(%a;X;%b); is the same as X(%a;%b):=Y(%a;'''%02''',X,;%b); (it means that a new node with the feature X will be created for the relation Y)
+
:X(%a;%b;%c):=Y(%a;%c); (it means that the second node of X will be deleted from the relation Y)
+
  
== Compound NLWs ==
+
=== Observations ===
;Special indexes (#) are used to make reference to the internal structure of the field <NLW> in the dictionary
+
#Non-indexed nodes in the right side means ADDITION, whereas left-side nodes that are not referred to in the right side means DELETION
:(X)(Y):=(X,#02)(Y)(X,#01);
+
#:X(%a;%b):=Y(%a;X;%b); is the same as X(%a;%b):=Y(%a;'''%02''',X,;%b); (it means that a new node with the feature X will be created for the relation Y)
::The rule above is used for complex dictionary entries such as:
+
#:X(%a;%b;%c):=Y(%a;%c); (it means that the second node of X will be deleted from the relation Y)
:::[[A][B]] "uw" (X, #01(ATT=AAA), #02(ATT=BBB)) <flg,fre,pri>;
+
#Any co-indexation is made by the use of indexes and not by the repetition of features.
::It means that, given (X)(Y), the output should be (B)(Y)(A).
+
#:''''X(A;)Y(A;)''' is different from '''X(%a;)Y(%a;)'''.
 +
#::In the former case, the first node of X is not necessarily the first node of Y, they only share the same feature A; in the latter case, the first node of X is necessarily the first node of Y.</blockquote>

Revision as of 20:36, 21 August 2013

Indexes (%) are used for co-indexing nodes in T-rules and D-rules.

Contents

T-rules

In T-rules, indexes are used:

  • to associate nodes in the left side of the rule (CONDITION) to nodes in the right side of the rule (ACTION):
  • (%a)(%b)(%c):=(%b); (delete the first and the third nodes, and keep the second)
  • (%a)(%b)(%c):=(%c)(%b)(%a); (reverse the order)
  • rel(%a;%b;%c):=rel(%a;%b); (remove the third argument of the relation rel)
  • rel(%a;%b;%c):=rel(%c;%b;%a); (reverse the order of the arguments of the relation rel)
  • to associate nodes within the left side of the rules
  • (%a)(%b)(%a):=(%b); (delete the first and the third nodes, if they are the same)
  • rel1(%a;%b)rel2(%a;%c):=rel3(%a;%c); (replace the relations rel1 and rel2 by the relation rel3 if the first argument of rel1 is the first argument of rel2)
  • to copy values of attributes between nodes
  • (%a)(%b):=(%a)(%b,GEN=%a); (copy the value of the attribute GEN from the node %a to the node %b if the node %b comes after the node %a)
  • NA(%a;%b):=NA(%a;%b,GEN=%b); (copy the value of the attribute GEN from the node %a to the node %b if there is a relation NA between them)
  • to test values of attributes within the left side of the rules
  • (%a)(%b,GEN=%a):=; (delete the nodes %a and %b if they have the same value of the attribute GEN)
  • rel1(%a;%b,GEN=%b):=rel2(%a;%b); (replace the relation rel1 by rel2 if the arguments of rel1 have the same value of the attribute GEN)

D-rules

In D-rules, indexes are used to test values of attributes within the left side of the rules

  • (%a,ART)(%b,NOU,GEN=%a)=1; (nouns following articles normally have the same gender of the article)

Syntax

Indexes are made of any sequence of alphanumeric characters and underscore preceded by % and starting by alphabetic characters:

%index
%a
%first_index
%a1
%first index (no blank spaces are allowed)
%_a (indexes must start with alphabetic characters)
%03 (numeric characters cannot be used as user-defined indexes)

Default Indexation

If not explicitly informed, indexation is done automatically by the machine, as follows:

  • if the number of nodes is the same in the left and in the right side, NODES ARE CO-INDEXED, starting from left to right
    ("a")("b")("c"):=("d")("e")("f"); is the same as ("a",%01)("b",%02)("c",%03):=("d",%01)("e",%02)("f",%03); (i.e., "a" will be replaced by "d", "b" by "e", and "c" by "f")
    rel("a";"b";"c"):=rel("d";"e";"f"); is the same as rel("a",%01;"b",%02;"c",%03):=rel("d",%01;"e",%02;"f",%03);
  • if the number of nodes is not the same in both sides, NODES ARE NOT CO-INDEXED
    ("a")("b")("c"):=("d")("e"); is the same as ("a",%01)("b",%02)("c",%03):=("d",%04)("e",%05); (i.e., "a", "b" and "c" will be deleted, and "d" and "e" will be created)
    rel("a";"b";"c"):=rel("d";"e"); is the same as rel("a",%01;"b",%02;"c",%03):=rel("d",%04;"e",%05);

Default indexes are also assigned to hyper-nodes and sub-nodes by the notation <PARENT NODE><CHILD NODE>, where <PARENT NODE> may be, itself, a sub-node:

  • (((A))):=(((B))); is the same as (%01(%01%01(%01%01%01,A))):=(%01(%01%01(%01%01%01,B)));
  • X(Y(A;B);C) is the same as X(%01,Y(%01%01,A;%01%02,B);%02)
  • %01 = Y(A;B), %02 = C, %01%01 = A, %01%02 = B
  • X(Y(Z(A;B);C);D) is the same as X(%01,Y(%01%01,Z(%01%01%01,A;%01%01%02,B);%01%02,C);%02,D)
  • %01 = Y(Z(A;B);C), %02 = D, %01%01 = Z(A;B), %01%02 = C, %01%01%01 = A, %01%01%02 = B

In order to avoid ambiguities, it is highly recommended that indexes are replaced by user-defined labels made of any sequence of alphabetic characters and underscore:

("a",%a)("b",%b):=("c",%a)("d",%b); instead of (A)(B):=(C)(D);

Observations

  1. Non-indexed nodes in the right side means ADDITION, whereas left-side nodes that are not referred to in the right side means DELETION
    X(%a;%b):=Y(%a;X;%b); is the same as X(%a;%b):=Y(%a;%02,X,;%b); (it means that a new node with the feature X will be created for the relation Y)
    X(%a;%b;%c):=Y(%a;%c); (it means that the second node of X will be deleted from the relation Y)
  2. Any co-indexation is made by the use of indexes and not by the repetition of features.
    'X(A;)Y(A;) is different from X(%a;)Y(%a;).
    In the former case, the first node of X is not necessarily the first node of Y, they only share the same feature A; in the latter case, the first node of X is necessarily the first node of Y.</blockquote>
Software