Once lists are encoded as FDs, grammars need to be defined to traverse the
lists and unify them according to the specific semantic of each list.
Lists are traversed by recursive grammars, using the constituent traversal
mechanism implemented by cset. The following example shows how to use the
input shown above to build a clause out of the semantic input, by composing
elements of the appropriate type. The grammar contains the categories
semantic, find1 and find2. The easiest way to explain how this
function works is by taking a procedural interpretation of the FUF flow of
control. This procedural interpretation is explained in detail in Appendix
. A constituent can be viewed as a procedure, that receives a
certain set of parameters and computes new return values. In this example,
the constituent semantic receives as input the features ents and
rels which as shown in the FD input above. It computes a new
feature clause as output, which is a linguistic constituent. To this
end, it also uses two local variables stored in the features ent1 and
rel1. All in all, the function of this category is to map a
description of a semantic content into a linguistic clause description.
The grammar also implements two other categories, find1 and find2, which are the ones related to list processing. These categories can be interpreted as procedures searching a list for one or two matches. The simpler one is find1. Find1 receives two input parameters in1 and 1st-match which are a list of FDs and an FD. The category searches the list for the first-match in the list which can be unified with the feature 1st-match. When it is found, the feature 1st-match and the element in the list are unified (conflated). The category find2 operates the same way but for two features 1st-matchA and 1st-matchB.
;; A grammar to find matching elements in the list of semantic binary
;; relations and compose the matched elements into a linguistic clause
;; structure.
(def-grammar rules ()
(clear-bk-class)
'((ALT
(((cat semantic)
(ent1 ((cat find2)
(in2 {^2 ents})
(1st-matchA ((concept player) (name stockton)))
(1st-matchB ((concept stat)))))
(rel1 ((cat find1)
(in1 {^2 rels})
(1st-match ((concept stat-rel)
(args ((carrier {^4 ent1 1st-matchA})
(stat {^4 ent1 1st-matchB})))))))
(cset ((= ent1 rel1)))
(clause ((cat clause)
(process stat)
(args {^2 rel1 1st-match args}))))
|
The list traversal is implemented in the category find1. The grammar for find1 contains a typical list recursion, similar to the following Lisp function:
(defun find1 (in1 match1)
(if (equal match1 (car in1))
match1
(find1 (cdr in1) match1)))
|
Naturally, since the grammar is written in FUF it performs differently, but the structure is similar. The if test is implemented as an alt, and the recursive call is implemented by a cset expansion to the sub-constituent rest. This structure is typical of the FUF list traversal categories and can be found in a similar form in the SURGE segment dealing with conjunctions.