- Up - | Next >> |
Associating semantic representations with sentences using DCGs.
So how do we associate semantic representations with sentences using our little DCG?
Task 2
Let us first address the lexical items. We need to associate ``John'' with the constant , ``Mary'' with the constant
, ``walks'' with the unary relation symbol
, and ``loves'' with the binary relation symbol
. The following piece of DCG code makes these associations. Note that the arities of
walk
and love
are explicitly included as part of the Prolog representation.
pn(john)--> [john].
pn(mary)--> [mary].
iv(walk(_))--> [walks].
tv(love(_,_))--> [loves].
Task 3
How do we combine semantic representations? Here's a first (rather naive) attempt: Let's introduce a new symbol to mark all places where two representations are combined into one. For example, we can define a prolog operator +
for this purpose.
?- Question!
Give the Prolog code needed to define such a +
operator.
Let us incorporate this idea into our DCG. We'll do as we did for the lexical items, and supply additional arguments. For example, we get an s
rule:
s(NPSem+VPSem) --> np(NPSem), vp(VPSem).
and a vp
rule for transitive verbs:
vp(VSem+NPSem) --> tv(VSem),np(NPSem).
Additionally, we will need the following rules that do not combine anything but rather lift the semantic representation of a lower category to that of a higher one:
np(X) --> pn(X).
vp(X) --> iv(X).
firstAttempt.pl
: View Download
With our newly augmented DCG, we are now able to construct semantic representations for the sentences we parse. For instance, parsing the sentence ``John loves Mary.'' by posing the query s(Sem,[john,loves,mary],[])
gives us the semantic representation john+(love(_,_)+mary)
.
But is that what we want? No, not yet. What we want of course is to arrive at the first-order formula . So far, the only thing we have is a complex Prolog term consisting of the semantic representations for the words in our input sentence in a sequence. Or - rather - not just in a sequence. If we look at it more closely, the structure of the term we get reflects the structure of the syntactic tree constructed by our DCG in the way it is bracketed. Only so far we have no clue how we can use this structure to put
john
and mary
in their right places, namely the first and, respectively, the second argument slot of love(_,_)
.
- Up - | Next >> |