Grammar Specs

From UNL Wiki
(Difference between revisions)
Jump to: navigation, search
(Network-to-Tree rules)
(Redirected page to Grammar)
 
(326 intermediate revisions by 2 users not shown)
Line 1: Line 1:
UNL-NL grammars are sets of rules for translating UNL expressions into natural language (NL) sentences and NL sentences into UNL expressions. They are normally unidirectional, i.e., the enconversion grammar (NL-to-UNL) is different from the deconversion grammar (UNL-to-NL), even though they share the same basic syntax. In order to standardize the language resources in the UNL framework, the UNDL Foundation recommends the adoption of the following specifications for both UNL-to-NL and NL-to-UNL grammars. This formalism, however, is not supported by the UNL Centre's tools, and it is only required by those interested in using UNDL Foundation's tools.
+
#REDIRECT [[Grammar]]
 
+
== Types of rules ==
+
 
+
In the UNL Grammar there are two basic types of rules:
+
 
+
;Transformation rules
+
:Used to generate natural language sentences out of UNL graphs and vice-versa.
+
;Disambiguation rules
+
:Used to improve the performance of transformation rules by constraining their applicability.
+
 
+
The Transformation Rules follow the very general formalism
+
 
+
α:=β;
+
 
+
where the left side α is a condition statement, and the right side β is an action to be performed over α.
+
 
+
The Disambiguation Rules, which were directly inspired by the UNL Centre's former co-occurrence dictionary and knowledge base, follows a slightly different formalism:
+
 
+
α=P;
+
 
+
where the left side α is a statement and the right side P is an integer from 0 to 255 that indicates the probability of occurrence of α. 
+
 
+
We present both types of rules and their role in the UNL System. We introduce, first, the basic symbols that are used both by transformation and disambiguation rules; next, we present the transformation rules and their several subtypes; and finally we present the disambiguation rules.
+
 
+
== Basic symbols ==
+
 
+
Both transformation and disambiguation rules use the same set of basic symbols:
+
 
+
<div align="center">
+
{| border="1" cellpadding="2"
+
|+
+
==== Basic symbols used in UNL grammar rules ====
+
!Symbol
+
!Definition
+
!Example
+
|-
+
|?
+
|any letter or digit
+
|?b = 1b, 2b, ab, bb
+
|-
+
|$
+
|any letter
+
|$b = ab, bb, cb, db
+
|-
+
|#
+
|any digit
+
|#b = 1b, 2b, 3b, 4b
+
|-
+
|*
+
|any sequence of letters or digits
+
|*b = 1b, 11b, 111b,
+
|-
+
|“ “
+
|string
+
|“buy” = “buy”
+
|-
+
|( , )
+
|complex expression
+
|
+
|-
+
|<nowiki>,</nowiki>
+
|and
+
|a,b = a and b
+
|-
+
|<nowiki>^</nowiki>
+
|not
+
|^a = not a
+
|-
+
|( )
+
|optional
+
|a(b)c = ac or abc
+
|-
+
|{ }
+
|or
+
|{a,b} = a or b
+
|-
+
|*
+
|To be repeated more than 0 times
+
|a* = a, aa, aaa, …
+
|-
+
|&
+
|and + blank space
+
|a&b = a b
+
|-
+
|<nowiki>+</nowiki>
+
|add
+
|<nowiki>+</nowiki>a = add a
+
|-
+
|<nowiki>-</nowiki>
+
|remove
+
|<nowiki>-</nowiki>a = remove a
+
|-
+
|%##
+
|placeholder for nodes
+
|%01
+
|-
+
|&##
+
|placeholder for attributes
+
|&01
+
|-
+
|#
+
|placeholder for NLWs
+
|#01
+
|-
+
|}
+
</div>
+
<br />
+
<br />
+
 
+
The following symbols are related to the structure of the UNL Dictionary, as illustrated below:<br />
+
:[NLW] {} “UW” (aa=AA, bb=BB, …) <L,F,P>;<br />
+
::[book] {} “book(icl>document)” (pos=NOU) <EN,0,0>;<br />
+
::[foot] {} “foot(icl>vertebrate foot) (pl=”feet”) <EN,0,0>;<br />
+
::[baby] {} “baby(icl>child) (pl=”y”>”ies”) <EN,0,0>;<br />
+
::[[bring] [back]] {} “to bring back(icl>to bring) (pos=VER) <EN,0,0>;<br />
+
 
+
 
+
<div align="center">
+
{|border="1" cellpadding="2"
+
|+
+
==== Basic symbols used for dictionary entries ====
+
!Symbol
+
!Definition
+
!Example
+
|-
+
|[ ]
+
|NLW
+
|[book]
+
|-
+
|[[ ]]
+
|UW
+
|[[book(icl>document)]]
+
|-
+
|lower-case string (LCS)
+
|Attribute
+
|pos
+
|-
+
|upper-case string (UCS)
+
|Value
+
|NOU
+
|-
+
|LCS=UCS
+
|Feature
+
|pos=NOU
+
|-
+
|LCS:=”nlwv“
+
|variant of the NLW in the case of LCS
+
|pl:=”feet”
+
|-
+
|LCS:=mod
+
|modification of the NLW in the case of LCS
+
|pl:=”y”>”ies”
+
|-
+
|[[NLW][NLW]]
+
|segmentation of NLW for infixation
+
|[[bring] [back]]
+
|}
+
</div>
+
 
+
== Transformation rules ==
+
 
+
Natural language sentences and UNL graphs are supposed to convey the same amount of information in different structures: whereas the former arranges data as an ordered list of words, the latter organizes it as a hypergraph. In that sense, translating from natural language into UNL and from UNL into natural language is ultimately a matter of transforming lists into networks and vice-versa.
+
+
Both EUGENE and IAN, the UNDLF generation and analysis tools, assume that such transformation should be carried out progressively, i.e., through a transitional data structure: the tree, which could be used as an interface between lists and networks. Accordingly, the UNL Grammar states seven different types of rules (LL, TT, NN, LT, TL, TN, NT), as indicated below:
+
 
+
*ANALYSIS (NL-UNL)
+
**LL - List Processing (list-to-list)
+
**LT - Surface-Structure Formation (list-to-tree)
+
**TT - Syntactic Processing (tree-to-tree)
+
**TN - Deep-Structure Formation (tree-to-network)
+
**NN - Semantic Processing (network-to-network)
+
 
+
*GENERATION (UNL-NL)
+
**NN - Semantic Processing (network-to-network)
+
**NT - Deep-Structure Formation (network-to-tree)
+
**TT - Syntactic Processing (tree-to-tree)
+
**TL - Surface-Structure Formation (tree-to-list)
+
**LL - List Processing (list-to-list)
+
 
+
The whole process can be illustrated by the Diagram 1 below. The NL original sentence is supposed to be preprocessed, by the LL rules, in order to become an ordered list. Next, the resulting List Structure is parsed with the LT rules, so as to unveil its Surface Syntactic Structure, which is already a tree. The Tree Structure is further processed by the TT rules in order to expose its inner organization, the Deep Syntactic Structure, which is supposed to be more suitable to the semantic interpretation. Then, the Deep Syntactic Structure is projected into a semantic network by the TN rules. The resultant semantic network is then post-edited by the NN rules in order to comply with UNL Standards and generate the UNL Graph.
+
 
+
The reverse process is carried out during natural language generation. The UNL graph is preprocessed by the NN rules in order to become a more easily tractable semantic network. The resulting Network Structure is converted, by the NT rules, into a syntactic structure, which is still distant from the surface structure, as it is directly derived from the semantic arrangement. This Deep Syntactic Structure is subsequently transformed into a Surface Syntactic Structure by the TT rules. The Surface Syntactic Structure undergoes many other changes according to the TL rules, which generate a NL-like List Structure. This List Structure is finally realized as a natural language sentence by the LL rules.
+
 
+
=== Network-to-Network Rules ===
+
 
+
The network-to-network rules (NN) are used for processing networks, both in analysis and in generation. During analysis, these rules are used for post-editing the semantic network structure derived from the syntactic module in order to generate the UNL graph; in generation, they are used for pre-editing the UNL graph, transforming it into a semantic network that would be more appropriate for sentence generation.
+
 
+
The NN rules follow the general syntax below:
+
 
+
<SEM>(“,”<SEM>)*”:=”((”-“)<SEM>(“,”<SEM>)*)”;”
+
 
+
Where:<br />
+
<SEM>::={agt,aoj,...,via}”(“<NODE>”;”<NODE>”)”<br />
+
<NODE>:= relations, placeholders, indexes, NLWs, UWs, attributes or values<br />
+
 
+
There are 4 different subtypes of NN rules:
+
 
+
<div align="center">
+
{| cellpadding="5" border="1"
+
|+
+
==== NN rules ====
+
!ACTION
+
!RULE
+
|-
+
|ADD RELATION
+
|SEM(A;B):=+SEM(C;D);
+
|-
+
|DELETE RELATION
+
|SEM(A;B):=-SEM(A,B);
+
|-
+
|REPLACE RELATION
+
|SEM(A;B):=SEM(C;D);
+
|-
+
|MERGE RELATION
+
|SEM(A;B),SEM(C;D):=SEM(E;F);
+
|-
+
|DIVIDE RELATION
+
|SEM(A;B):=SEM(C;D),SEM(E;F);
+
|}
+
Where SEM is any of the existing UNL relations, and A, B, C, D, E and F are variables.
+
</div> 
+
 
+
=== Tree-to-Tree Rules ===
+
 
+
The tree-to-tree rules (TT) are used for processing trees, both in analysis and in generation. During analysis, these rules are used for revealing the deep structure out of the surface structure; in generation, they are used for transforming the deep into the surface syntactic structure.
+
The TT rules follow the general syntax below:
+
 
+
<SYN>(“,”<SYN>)*”:=”((”-“)<SYN>(“,”<SYN>)*)”;”
+
 
+
Where:<br />
+
<SYN>::={syntactic relation}”(“<NODE>”(“;”<NODE>”)*)”<br />
+
<NODE>:= relations, placeholders, indexes, NLWs, UWs, attributes or values<br />
+
 
+
Syntactic relations are n-ary: they can have as many arguments (nodes) as necessary.
+
 
+
There are 5 different subtypes of TT rules:
+
 
+
<div align="center">
+
{|cellpadding="5" border="1"
+
|+
+
==== TT rules ====
+
!ACTION
+
!RULE
+
|-
+
|ADD RELATION
+
|SYN(A;B):=+SYN(C;D) ;
+
|-
+
|DELETE RELATION
+
|SYN(A;B):=-SYN(A;B);
+
|-
+
|REPLACE RELATION
+
|SYN(A;B):=SYN(C;D);
+
|-
+
|MERGE RELATION
+
|SYN(A;B),SYN(C;D):=SYN(E;F);
+
|-
+
|DIVIDE RELATION
+
|SYN(A;B):=SYN(C;D),SYN(E;F);
+
|}
+
Where SYN is a syntactic relation, and A, B, C, D, E and F are variables.
+
 
+
 
+
As syntactic relations are n-ary, the REPLACE RELATION may also be used to ADD or DELETE nodes.
+
 
+
 
+
{|border="1" cellpadding="5"
+
|+
+
==== Special types of TT replace relations ====
+
!ACTION
+
!RULE
+
|-
+
|ADD NODE
+
|SYN(A;B):=SYN(A;B;C);
+
|-
+
|DELETE NODE
+
|SYN(A;B):=SYN(A);
+
|-
+
|}
+
 
+
Where SYN is a syntactic relation, and A, B and C are variables.
+
</div>
+
 
+
=== List-to-List Rules ===
+
 
+
The list-to-list (LL) rules are used for processing lists, both in analysis and in generation. In analysis, these rules are used for pre-editing the natural language sentence and preparing the input to the syntactic module; in generation, they are used for post-editing the output of the syntactic module and generating the natural language sentence.
+
 
+
The LL rules follow the syntax below:
+
“(”<NODE>”)”(“,(”<NODE>”)”)”:=”(”-“)“(”<NODE>”)”(“,(”<NODE>”)”)*)”;”
+
 
+
Where:<br />
+
<NODE>:= relations, placeholders, indexes, NLWs, UWs, attributes or values<br />
+
 
+
There are 5 different subtypes of LL rules:
+
 
+
<div align="center">
+
{|cellpadding="5" border="1"
+
|+
+
====LL rules====
+
!ACTION
+
!RULE
+
|-
+
|ADD
+
|(A):=(A),(B); or (A):=(B),(A);
+
|-
+
|DELETE
+
|(A):=-(A);
+
|-
+
|REPLACE
+
|(A):=(B);
+
|-
+
|MERGE
+
|(A),(B):=(C);
+
|-
+
|DIVIDE
+
|(A):=(B),(C);
+
|}
+
Where A, B and C are variables.
+
</div>
+
 
+
=== List-to-Tree Rules ===
+
 
+
The list-to-tree (LT) rules are used to parse the list structure into a (surface) tree structure. It is used only in analysis, and all LT rules follow the syntax below:
+
 
+
“(”<NODE>”)”(“,(”<NODE>”)”):=<SYN>(“,<SYN>”)*”;”
+
 
+
Where:<br />
+
<SYN>::={syntactic relation}”(“<NODE>”;”<NODE>”)”<br />
+
<NODE>:= relations, placeholders, indexes, NLWs, UWs, attributes or values<br />
+
 
+
There is a single type of LT rule:
+
 
+
<div align="center">
+
{|cellpadding="5" border="1"
+
|+
+
==== LT rule ====
+
!ACTION
+
!RULE
+
|-
+
|REPLACE
+
|(A):=SYN(B;C);
+
|}
+
Where SYN is a syntactic relation, and A, B and C are variables
+
</div>
+
 
+
=== Tree-to-List Rules ===
+
 
+
The tree-to-list (TL) rules are used to linearize the (surface) tree structure into a list structure. It is used only in generation, and all TL rules follow the syntax below:
+
 
+
<SYN>(“,<SYN>”)*:=“(”<NODE>”)”(“,(”<NODE>”>”)”;”
+
 
+
Where:<br />
+
<SYN>::={syntactic relation}”(“<NODE>”;”<NODE>”)”<br />
+
<NODE>:= relations, placeholders, indexes, NLWs, UWs, attributes or values<br />
+
 
+
There is a single type of TL rule:
+
 
+
<div align="center">
+
{|cellpadding="5" border="1"
+
|+
+
==== TL rule ====
+
!ACTION
+
!RULE
+
|-
+
|REPLACE
+
|SYN(A;B):=(C);
+
|}
+
Where SYN is a syntactic relation and A, B and C are variables
+
</div>
+
 
+
=== Tree-to-Network Rules ===
+
 
+
The tree-to-network (TN) rules derive a semantic network out of a syntactic tree. It is used only in analysis, and all TN rules follow the syntax below:
+
 
+
<SYN>”(“,<SYN>)*”:=”<SEM>(“,”<SEM>)*”;”
+
 
+
Where:<br />
+
<SYN>::={syntactic relation}”(“<NODE>”;”<NODE>”)”<br />
+
<SEM>::={agt,aoj,...,via}”(“<NODE>”;”<NODE>”)”<br />
+
<NODE>:= relations, placeholders, indexes, NLWs, UWs, attributes or values<br />
+
 
+
There is a single type of TN rule:
+
 
+
<div align="center">
+
{|cellpadding="5" border="1"
+
|+
+
==== TN rule ====
+
!ACTION
+
!RULE
+
|-
+
|REPLACE
+
|SYN(A;B):=SEM(C;D);
+
|}
+
Where SYN is a syntactic relation, SEM is a semantic relation, and A, B, C and D are variables.
+
</div>
+
 
+
=== Network-to-Tree Rules ===
+
 
+
The network-to-tree (NT) rules reorganizes the network structure as a deep tree structure. It is used only in generation, and all the NT rules follow the syntax below:
+
<SEM>”(“,<SEM>)*”:=”<SYN>(“,”<SYN>)*”;”
+
 
+
Where:<br />
+
<SEM>::={agt,aoj,...,via}”(“<NODE>”;”<NODE>”)”<br />
+
<SYN>::={syntactic relation}”(“<NODE>”;”<NODE>”)”<br />
+
<NODE>:= relations, placeholders, indexes, NLWs, UWs, attributes or values<br />
+
There is a single type of TN rule:
+
 
+
<div align="center">
+
{|cellpadding="5" border="1"
+
|+
+
==== TN rule ====
+
!ACTION
+
!RULE
+
|-
+
|REPLACE
+
|SEM(A;B):=SYN(C;D);
+
}
+
Where SYN is a syntactic relation, SEM is a semantic relation, and A, B, C and D are variables.
+
</div>
+

Latest revision as of 19:11, 19 August 2013

  1. REDIRECT Grammar
Software