Information Technology Reference
In-Depth Information
Figure 8.5.
A lexicon in Prolog
lexicon.pl
article(a). article(the).
common_noun(park,X) :- park(X).
common_noun(tree,X) :- tree(X).
common_noun(hat,X) :- hat(X).
common_noun(man,X) :- person(X), sex(X,male).
common_noun(woman,X) :- person(X), sex(X,female).
adjective(big,X) :- size(X,big).
adjective(small,X) :- size(X,small).
adjective(red,X) :- color(X,red).
adjective(blue,X) :- color(X,blue).
preposition(on,X,Y) :- on(X,Y).
preposition(in,X,Y) :- in(X,Y).
preposition(beside,X,Y) :- beside(X,Y).
% The preposition 'with' is flexible in how it is used.
preposition(with,X,Y) :- on(Y,X). % Y can be on X
preposition(with,X,Y) :- in(Y,X). % Y can be in X
preposition(with,X,Y) :- beside(Y,X). % Y can be beside X
% Any word that is not in one of the four categories above.
proper_noun(X,X) :- \+ article(X), \+ adjective(X,_),
\+ common_noun(X,_), \+ preposition(X,_,_).
The predicate preposition (
)
holds when the preposition w can be used
to describe the relation between the objects x and y in the world model. So, for
example, this clause is in the lexicon:
preposition(with,X,Y) :- on(Y,X).
This says that if object Y is on object X (in the world model), then that relation
can be what is described when using the preposition with .
w , x , y
(
)
Finally, the predicate proper_noun
holds when the word w is a name for
the object x in the world model. There are two simplifying assumptions here:
- Any word that does not belong to the other categories is a proper noun.
- The constants in the world model like john and tree02 are proper names.
w , x
One thing to notice is that the words in the lexicon are sometimes the same as the
predicates and constants in the world model:
common_noun(hat,X) :- hat(X).
adjective(small,X) :- size(X,small).
preposition(in,X,Y) :- in(X,Y).
 
Search WWH ::




Custom Search