Transformation over relations

From UNL Wiki
(Difference between revisions)
Jump to: navigation, search
Line 3: Line 3:
 
=== Altering nodes in a relation ===
 
=== Altering nodes in a relation ===
 
Elements of nodes in relations are altered through the operators + (add) and - (delete). The operator + may be omitted.  
 
Elements of nodes in relations are altered through the operators + (add) and - (delete). The operator + may be omitted.  
rel(%x,A;%y,B):=rel(%x,+C;%y,+D); (add the feature C to %x and D to %y)
+
*rel(%x,A;%y,B):=rel(%x,+C;%y,+D); (add the feature C to %x and D to %y)
rel(%x,A;%y,B):=rel(%x,C;%y,D);(the same as above)
+
*rel(%x,A;%y,B):=rel(%x,C;%y,D);(the same as above)
rel(%x,A;%y,B):=rel(%x,-A;%y); (delete the feature A from %x)
+
*rel(%x,A;%y,B):=rel(%x,-A;%y); (delete the feature A from %x)
 
"strings", [headwords] and [[UWs]] are considered to be features (but a single node may have only one of each)
 
"strings", [headwords] and [[UWs]] are considered to be features (but a single node may have only one of each)
rel(%x;%y):=rel(%x,"a";%y); (replace the existing string in %x, if any, by "a")
+
*rel(%x;%y):=rel(%x,"a";%y); (replace the existing string in %x, if any, by "a")
rel(%x;%y):=rel(%x,[A];%y);(replace the existing headword in %x, if any, by [A])
+
*rel(%x;%y):=rel(%x,[A];%y);(replace the existing headword in %x, if any, by [A])
rel(%x;%y):=rel(%x,[[A]];%y); (replace the existing UW in %x, if any, by [[A]])
+
*rel(%x;%y):=rel(%x,[[A]];%y); (replace the existing UW in %x, if any, by [[A]])
  
 
=== Creating nodes in a relation ===
 
=== Creating nodes in a relation ===
+
Nodes are created when they are not co-indexed to any node in the left side (see [[Indexation]]):
 +
*rel(%x,A;%y,B):=rel(%x;%y;'''%z,+A'''); (the node %z, with the feature A, is created as a new argument of the relation rel)
  
 +
=== Deleting nodes in a relation ===
 +
Nodes are deleted when they are not co-indexed to any node in the right side (see [[Indexation]]):
 +
*rel(%x,A;%y,B;'''%z,C'''):=rel(%x;%y); (the node %z is deleted as an argument of the relation rel)
 +
Nodes are completed deleted if, and only if, they are not part of any other relation
  
 +
=== Creating relations ===
 +
Relations are created by the operator + (add) before the relation to be created. This operator may not be omitted.
 +
*rel(%x;%y):=+rel2(%x;%z); (a new relation rel2 is created between the nodes %x and %z; the original relation is not altered)
 +
Creation of relations is a possible source of infinite loops. In order to prevent the rule from applying eternally, the conditions must be altered:
 +
*rel(%x;%y)^rel2(%x;%z):=:=+rel2(%x;%z);
  
 +
=== Deleting relations ===
 +
Relations are deleted when they are not repeated in the right side, except in case of +
 +
*rel(%x;%y):=; (the relation rel between the nodes %x and %y is deleted)
 +
*rel(%x;%y):=rel2(%x;%y); (the relation rel between %x and %y is deleted and a new relation rel2 is created in its place) (replacement)
 +
*rel(%x;%y):=+rel2(%x;%y); (the relation rel is preserved and a new relation rel2 is created) (creation)
  
[edit] Deleting nodes
+
=== Replacing relations ===
In linear rules, nodes are deleted if they are not repeated (co-indexed) in the right side:
+
Relations in the left side are replaced by relations in the right side, except in case of +:
(%x)(%y):=(%x); (the node %y will be deleted)
+
*rel(%x;%y):=rel2(%x;%y); (the relation rel between %x and %y is deleted and a new relation rel2 is created in its place)  
In other rules, nodes are deleted if they are not repeated (co-indexed) in the right side and are not part of any other relation:
+
*rel1(%x;%y)rel2(%y;%z):=rel3(%x;%z); (the relations rel1 and rel2 are deleted and a new relation rel3 is created in their place) (merge)
rel(%x;%y):=rel(%x); (the node %y will be deleted if, and only if, it is not part of any other relation)
+
*rel(%x;%y):=rel1(%x;%y)rel2(%y;%z); (the relation rel is deleted and two new relations rel1 and rel2 are created in its place) (divide)
[edit] Creating nodes
+
Nodes are created through the use of new indexes in the right side:
+
("a",%x)("b",%y):=(%x)(%y)("c",%z); (the node %z will be created)
+
("a",%x)("b",%y):=(%x)("c",%z); (the node %z will be created, and %b will be deleted)
+
[edit] Duplicating (cloning) nodes
+
Nodes may be duplicated by repeating indexes on the right side along with the command #CLONE:
+
("a",^CLONED,%x):=(%x,+CLONED)(%x,+CLONED,#CLONE);
+
("a") becomes ("a")("a")
+
In order to avoid infinite recursion, it is important to change the condition on the right side (in the example above, the feature +CLONED, assigned to all instances of the clone, prevents the rule from applying indefinitely)
+
Clones contain the same elements of the original nodes, unless they are explicitly altered during the cloning:
+
("a",[a],[[a]],A,^CLONED,%x):=(%x,+CLONED)(%x,+CLONED,#CLONE);
+
("a",[a],[[a]],A) becomes ("a",[a],[[a]],A,CLONED)("a",[a],[[a]],A,CLONED)
+
(A,^CLONED,%x):=(%x,-A,+B,+CLONED)(%x,-A,+C,+CLONED,#CLONE);
+
(A) becomes (B,CLONED)(C,CLONED)
+
[edit] Splitting nodes
+
One node may be split into two or more nodes through the use of splitting rules. Consider, for instance, the cases below:
+
Splitting rules deal only with strings and apply only to nodes with the feature TEMP.
+
Original node: ("abc",TEMP)
+
Split rule: ("abc"):=("ab")("c");
+
Resulting nodes: ("ab",TEMP)("c",TEMP);
+
However, if the original node was ("abc"), without TEMP, the rule would not have been applied (i.e., it is necessary to assign the feature TEMP to the node before splitting it)
+
Splitting rules are conservative: the elements of the original node, except the string, will be preserved unless explicitly altered.
+
Original node: ("abc",[abc],[[abc]],A,B,C,TEMP)
+
Split rule: ("abc"):=("ab")("c");
+
Resulting nodes: ("ab",[abc],[[abc]],A,B,C,TEMP)("c",[abc],[[abc]],A,B,C,TEMP) (i.e., the elements of the original node will be copied to the new nodes)
+
However, if the rule was: ("abc"):=("ab",-A,-B,-C,-TEMP,+AB)("c",-TEMP);
+
The result would be: ("ab",[abc],[[abc]],AB)("c",[abc],[[abc]],C,TEMP)
+
[edit] Merging nodes (&)
+
Two or more nodes may be merged by the command &:
+
(%x)(%y)(%z):=(%x&%y&%z);
+
In the example above("a")("b")("c") becomes ("abc")
+
Merge operations concatenate headwords and UWs, and join features
+
("hw1",[[uw1]],F1,%x)("hw2",[[uw2]],F2,%y)("hw3",[[uw3]],F3,%z):=(%x&%y&%z);
+
The resulting node is ("hw1hw2hw3",[[uw1uw2uw3]],F1,F2,F3)
+
Compare the difference
+
(%x)(%y):=(%z); (the nodes %x and %y are replaced by %z, and their features are lost unless explicitly included in %z)
+
(%x)(%y):=(%x&%y); (the nodes %x and %y are merged)
+
[edit] Retrieving entries in the dictionary after tokenization (?)
+
During transformation (i.e., after tokenization), dictionary entries may be accessed from transformation rules by the command "?"
+
(?[headword]) retrieves the first entry in the dictionary with the headword "headword"
+
(?[[uw]]) retrieves the first entry in the dictionary with the UW "uw"
+
(?[headword],?[[uw]],?feature) retrieves the first entry in the dictionary with the headword "headword", the UW "uw" and the feature "feature"
+
Regular expressions, variables and disjunction may also be used in dictionary search
+
(?[/abcd./]) retrieves the first entry in the dictionary whose headword has 5 characters and begins with "abcd" (this works only in natural language generation)
+
(?[[/abcd./]]) retrieves the first entry in the dictionary whose UW has 5 characters and begins with "abcd" (this works only in natural language analysis)
+
Obligatory parameters
+
Due to the indexation algorithm, the headword is obligatory in IAN and the UW is obligatory in EUGENE:
+
(?[headword]) will work only in IAN
+
(?[[uw]]) will work only in EUGENE
+
(?feature) will not work in IAN or EUGENE
+
Variables
+
In order to avoid repetition, dictionary look-up may use the values of indexed nodes in the left side
+
(?[%x]) retrieves the first entry in the dictionary with the same headword of the node %x
+
(?[[%x]]) retrieves the first entry in the dictionary with the same UW of the node %x
+
(?[%x],ATT=%x) retrieves the first entry in the dictionarz with the same headword of the node %x and whose attribute ATT has the same value of the attribute ATT of the node %x
+
Example
+
Dictionary search is used mainly in natural language generation
+
(N,NUM,GEN,@def,%noun):=(?[[]],?ART,?DEF,?NUM=%noun,?GEN=%noun)(%noun,-@def);
+
In case of node %noun with the features noun (N), number (NUM) and gender (GEN), and with the attribute @def (definite), search the first entry in the dictionary associated with the UW "" (empty UW) with the features ART and DEF, and whose attributes NUM and GEN have the same values of the ones of the node %noun, and insert it in front of the noun. Remove @def from the noun in order to avoid an infinite loop.
+
[edit] Triggering rules (!)
+
Inflectional rules are triggered in the grammar by the command "!"<ATTRIBUTE>.
+
Given the dictionary entry:
+
[foot] "foot" (POS=NOU, NUM(PLR:="oo":"ee")) <eng,0,0>;
+
The rule NUM(PLR:="oo":"ee") is triggered by !NUM
+
For instance:
+
(NUM=PLR,^inflected):=(!NUM,+inflected); or
+
(PLR,^inflected):=(!NUM,+inflected); or
+
(NUM,^inflected):=(!NUM,+inflected);
+
In the first case (NUM=PLR), the system verifies if the attribute "NUM" is set and if it has the value "PLR". In the second and in the third case, the system simply verifies if the word has any feature (attribute or value) equal to "PLR" or "NUM".
+
It's important to stress that, as the features of the dictionary are defined by the user, there is no way of pre-assigning attribute-value pairs. In that sense, it's not possible to infer that "PLR" will be a value of the attribute "NUM" except through an assignment of the form "NUM=PLR" (i.e., given only "PLR" or "NUM", is not possible to state "NUM=PLR").
+
 
+
 
+
==
+
There are four types of S-rules:
+
;Change
+
<CONDITION> := <RELATION>;
+
:Change the attributes of the constituents of the relation. The relation itself is not affected. Features are added through "+" and deleted through "-".
+
:*VA(%head;%adjt):=VA(%head,+C;%adj,-D); (add the feature C to the head and remove the feature D from the adjunct)
+
;Create
+
<CONDITION> := +<RELATION>;
+
:Create a new relation. Nodes to be created must be defined as strings (between quotes) or lemmas (between brackets), if not co-indexed to an existing node.
+
:*VA(%head;%adjt):=+VC(%head;"c"); (add the relation VC between the head and "c", which is created.)
+
;Delete
+
<CONDITION> := -<RELATION>;
+
:Delete a relation between the head and the argument. The head and the argument are not deleted.
+
:*VA(%head;%adjt):=-VA(%head;%adjt); (delete the relation VA between the head and its arguments. The nodes are not deleted)
+
;Replace
+
<RELATION> := <RELATION>;
+
:Replace the relation in the left side by the one in the right side
+
:*VA(%head;%any):=VC(%head;%any); (replace the relation VA by VC)
+
:Two special cases of replacement are
+
:;Merge: <RELATION><RELATION> := <RELATION>;
+
::Replace the relations in the left side by the ones in the right side.
+
::*VA(%head;%adjt)VC(%head;%comp):=VB(VB(%head;%adjt);%comp); (VA and VC are deleted, and VB is created)
+
:;Divide: <RELATION> := <RELATION><RELATION>;
+
::Replace the relation in the left side by those in the right side.
+
::*VA(%head;%adjt):=VC(%head;%x)VC(%head;%y); (VA is deleted, and the two VCs are created)
+
 
+
Where:<br/>
+
*<CONDITION> (to be repeated 0 or more times) may be a [[Tagset|tag]] or a <RELATION> that defines when the rule is applied. It may be empty in general cases (i.e., if the rule is always applied).
+
*<RELATION> (to be repeated 1 or more times) may be:
+
**a [[Syntactic roles|syntactic relation]] containing the <HEAD>, in case of head-only relations (VH, NH, JH, PH, IH, CH, AH, DH), or the <HEAD> and <ARGUMENT> (i.e, complement, adjunct or specifier), in case of binary relations (VA, VC, VS, VB, NA, NC, NS, etc).
+
**a [[Universal Relation|semantic relation]], containing the <SOURCE> and the <TARGET>.
+
*<HEAD>, <ARGUMENT>, <SOURCE> and <TARGET> may be expressed as
+
**a "string" (strings come between parentheses);
+
**a [lemma] (lemmas come between square brackets);
+
**a feature or a set of features, separated by comma, and extracted from the [[Tagset|UNDLF Tagset]];
+
**an [[#Indexes|index]];
+
**an action, to be performed by adding features (through "+"), deleting features (through "-"), or through the right side of an [[A-rule]] (i.e., prefixation, suffixation, infixation); or
+
**a <RELATION> itself (i.e., rules may be recursive).
+
 
+
 
+
 
+
 
+
*REL1(%x;%y):=REL2(%x;%y); (replacement)
+
*REL(%x;%y):=; (deletion)
+
*REL1(%x;%y):=+REL2(%w;%z); (creation)
+
  
 
=== Creating hyper-relations ===
 
=== Creating hyper-relations ===
 
Hyper-relations are created through encapsulating relations:
 
Hyper-relations are created through encapsulating relations:
*REL1(%x;%y)REL2(%x;%z):=REL1(REL2(%x;%z);%y); (the relation REL1 between %x and %y becomes a hyper-relation between the relation REL2(%x;%z) and the node %y.)
+
*rel1(%x;%y)rel2(%x;%z):=rel1(rel2(%x;%z);%y); (the relation rel1 between %x and %y becomes a hyper-relation between the relation rel2(%x;%z) and the node %y.)
  
 
=== Transforming hyper-relations into simple relations ===
 
=== Transforming hyper-relations into simple relations ===
 
Hyper-relations are transformed into simple relations by removing their internal relations:
 
Hyper-relations are transformed into simple relations by removing their internal relations:
*REL1(REL2(%x;%z);%y):=REL1(%x;%y)REL2(%x;%z); (the hyper-relation REL1 between the relation REL2(%x;%z) and the node %y is transformed into a simple relation between the nodes %x and %y; the relatin REL2(%x;%z) is not affected.)
+
*rel1(rel2(%x;%z);%y):=rel1(%x;%y)rel2(%x;%z); (the hyper-relation rel1 between the relation rel2(%x;%z) and the node %y is transformed into a simple relation between the nodes %x and %y; the relatin rel2(%x;%z) is not affected.)

Revision as of 18:42, 21 August 2013

Relations and hyper-relations are altered, replaced, created and deleted by T-rules:

Contents

Altering nodes in a relation

Elements of nodes in relations are altered through the operators + (add) and - (delete). The operator + may be omitted.

  • rel(%x,A;%y,B):=rel(%x,+C;%y,+D); (add the feature C to %x and D to %y)
  • rel(%x,A;%y,B):=rel(%x,C;%y,D);(the same as above)
  • rel(%x,A;%y,B):=rel(%x,-A;%y); (delete the feature A from %x)

"strings", [headwords] and UWs are considered to be features (but a single node may have only one of each)

  • rel(%x;%y):=rel(%x,"a";%y); (replace the existing string in %x, if any, by "a")
  • rel(%x;%y):=rel(%x,[A];%y);(replace the existing headword in %x, if any, by [A])
  • rel(%x;%y):=rel(%x,A;%y); (replace the existing UW in %x, if any, by A)

Creating nodes in a relation

Nodes are created when they are not co-indexed to any node in the left side (see Indexation):

  • rel(%x,A;%y,B):=rel(%x;%y;%z,+A); (the node %z, with the feature A, is created as a new argument of the relation rel)

Deleting nodes in a relation

Nodes are deleted when they are not co-indexed to any node in the right side (see Indexation):

  • rel(%x,A;%y,B;%z,C):=rel(%x;%y); (the node %z is deleted as an argument of the relation rel)

Nodes are completed deleted if, and only if, they are not part of any other relation

Creating relations

Relations are created by the operator + (add) before the relation to be created. This operator may not be omitted.

  • rel(%x;%y):=+rel2(%x;%z); (a new relation rel2 is created between the nodes %x and %z; the original relation is not altered)

Creation of relations is a possible source of infinite loops. In order to prevent the rule from applying eternally, the conditions must be altered:

  • rel(%x;%y)^rel2(%x;%z):=:=+rel2(%x;%z);

Deleting relations

Relations are deleted when they are not repeated in the right side, except in case of +

  • rel(%x;%y):=; (the relation rel between the nodes %x and %y is deleted)
  • rel(%x;%y):=rel2(%x;%y); (the relation rel between %x and %y is deleted and a new relation rel2 is created in its place) (replacement)
  • rel(%x;%y):=+rel2(%x;%y); (the relation rel is preserved and a new relation rel2 is created) (creation)

Replacing relations

Relations in the left side are replaced by relations in the right side, except in case of +:

  • rel(%x;%y):=rel2(%x;%y); (the relation rel between %x and %y is deleted and a new relation rel2 is created in its place)
  • rel1(%x;%y)rel2(%y;%z):=rel3(%x;%z); (the relations rel1 and rel2 are deleted and a new relation rel3 is created in their place) (merge)
  • rel(%x;%y):=rel1(%x;%y)rel2(%y;%z); (the relation rel is deleted and two new relations rel1 and rel2 are created in its place) (divide)

Creating hyper-relations

Hyper-relations are created through encapsulating relations:

  • rel1(%x;%y)rel2(%x;%z):=rel1(rel2(%x;%z);%y); (the relation rel1 between %x and %y becomes a hyper-relation between the relation rel2(%x;%z) and the node %y.)

Transforming hyper-relations into simple relations

Hyper-relations are transformed into simple relations by removing their internal relations:

  • rel1(rel2(%x;%z);%y):=rel1(%x;%y)rel2(%x;%z); (the hyper-relation rel1 between the relation rel2(%x;%z) and the node %y is transformed into a simple relation between the nodes %x and %y; the relatin rel2(%x;%z) is not affected.)
Software