Information Technology Reference
In-Depth Information
Figure 8.7.
A first trace of the noun phrase parser
?- np([a,big,tree],X).
Call: (7) np([a, big, tree], _G322)
Call: (8) article(a)
Exit: (8) article(a)
Call: (8) np2([big, tree], _G322)
Call: (9) adjective(big, _G322)
Call: (10) size(_G322, big)
Exit: (10) size(george, big)
% George is big.
Exit: (9) adjective(big, george)
Call: (9) np2([tree], george)
. . .
this fails, but then eventually
. . .
Redo: (10) size(_G322, big)
Exit: (10) size(tree01, big)
% Tree01 is big.
Exit: (9) adjective(big, tree01)
Call: (9) np2([tree], tree01)
Call: (10) common_noun(tree, tree01)
Exit: (10) common_noun(tree, tree01) % Tree01 is a tree.
Call: (10) mods([], tree01)
Exit: (10) mods([], tree01)
Exit: (9) np2([tree], tree01)
Exit: (8) np2([big, tree], tree01)
Exit: (7) np([a, big, tree], tree01)
X = tree01
the Y stand in the appropriate relation for the preposition word (as determined by the
preposition predicate in the lexicon).
The exception to this pattern in the parser of extracting the first word from a list
occurs with the predicate mods . Instead of just working on the head and on the tail
of a list of words, it uses append to break the list into two pieces: the first piece
must be a pp , and the second piece must be another mods . This allows breaking
apart a list such as [in,the,park,with,a,red,hat] into two lists: [in,the,park]
and [with,a,red,hat] . (See section 7.3 on append .)
8.2.4 Putting the pieces together
After a world model, a lexicon, and a parser have been loaded into Prolog, the pro-
gram is ready to parse and interpret noun phrases. To do this, the np predicate is
queried with a list of words as the first argument and a variable as the second. Prolog
attempts to locate an object from the world model described by the noun phrase.
 
Search WWH ::




Custom Search