Professional Documents
Culture Documents
INTRODUCTION:
2. What is prolog?
The name prolog was taken from the phrase “programming in logic".
Prolog is a logic programming language. It is a general purpose language often associated
with artificial intelligence and computational linguistics. It has a purely logical subset,
called "pure Prolog", as well as a number of extralogical features.
The language was first conceived by a group around Alain Colmerauer in
Marseille, France, in the early 1970s, while the first compiler was written by David H. D.
Warren in Edinburgh, Scotland. Prolog was one of the first logic programming languages,
and remains among the most popular such languages today, with many free and
commercial implementations available. While initially aimed at natural language
processing, the language has since then stretched far into other areas like theorem
proving, expert systems, games, automated answering systems, ontologies and
sophisticated control systems, and modern Prolog environments support the creation of
graphical user interfaces, as well as administrative and networked applications.
1
language processing would enable a computer to understand texts or speech and to
interact accordingly with human beings.
Understanding or translating texts automatically and talking to an artificial
conversational assistant are major challenges for the computer industry. Although this
final goal has not been reached yet, in spite of constant research, it is being ap-
proached every day, step-by-step. Even if we have missed Stanley Kubrick’s prediction of
talking electronic creatures in the year 2001, language processing and understanding
techniques have already achieved results ranging from very promising to near perfect.
The description of these techniques is the subject of this book.
• Spelling and grammar checkers. These programs are now ubiquitous in text pro-
cessors, and hundred of millions of people use them every day. Spelling checkers
are based on computerized dictionaries and remove most misspellings that occur
in documents. Grammar checkers, although not perfect, have improved to a point
that many users could not write a single e-mail without them. Grammar checkers
use rules to detect common grammar and style errors (Jensen et al. 1993).
• Text indexing and information retrieval from the Internet. These programs are
among the most popular of the Web. They are based on spiders that visit Internet
sites and that download texts they contain. Spiders track the links occurring on
the pages and thus explore the Web. Many of these systems carry out a full text
indexing of the pages. Users ask questions and text retrieval systems return the
Internet addresses of documents containing words of the question. Using statis-
tics on words or popularity measures, text retrieval systems are able to rank the
documents (Salton 1988, Brin and Page 1998).
• Speech dictation of letters or reports. These systems are based on speech recog-
nition. Instead of typing using a keyboard, speech dictation systems allow a user
to dictate reports and transcribe them automatically into a written text. Systems
2
like IBM’s ViaVoice have a high performance and recognize English, French,
German, Spanish, Italian, Japanese, Chinese, etc. Some systems transcribe radio
and TV broadcast news with a word-error rate lower than 10% (Nguyen et al.
2004).
:-op(lO0,yfx,'~'),
op(100,yfx,':'),
op(90,xfy,'#').
3
03) sem(elephant#1,birthYear:lg80, ). 04) sem(elephant#1,P,S) :-
isa(elephant,P,elephant#1:S).
07) sem(mammal,P,S) :-
isa(animal,P,mammallS).
08) sem(animal,P,S) :-
isa(oreature,P,animallS);
hasa(faee,P,animallS);
hasa(body,P,animallS).
Now the meanings of the sem, isa and hasa predicates, which are
important to descriptions in DCKR, are explained later using the DCKR examples
given above.
The first argument in the sem predicate is the Objects name.
Objects are broadly divided into two types, individuals and prototypes . Psychologists
often refer to prototypes as stereotypes. An Object name with # represents an
individuals name and the one without # prototype name, For example, clyde#1 and
elephant, which appears in 01l and 05), represent an individual name and a
prototype name, respectively. A set of Horn clauses, headed by the sem predicate
with the same individual name or prototype name represents an individual object or
a prototype object, respectively.
4
11) isa(Upper,P,S) :- 12) hasa(Part,X:Y,S) :-
P = isa:Upper; X = = hasa,
sem(Upper,P,S). (Y = Part; sem(Part,hasa:Y,S)).
The isa predicate and the hasa predicates are used for the
inheritance of knowledge through subordinate-superordinate and part-whole relations,
respectively. DCKR is provided with the bottomof predicate, which is used in the
body of 09). By using the predicate, it is possible to know what the calling
individual (the individual that called the world of prototypes) is and extract the
knowledge held by that individual. This is accomplished by using the third
argument in the sem predicate, since in the third argument of the sem predicate is
stacked the route followed in tracing the hierarchy. For example, 09) identifies the
individual .(caller) B by means of the bottomof predicate and calculates his age by
using B's birthyear. Therefore,
if
?-sem(elephant#1, age: X,_).
is executed, 09) is reached by the isa predicate in 04), 05) and 07). As a result.
X=6
is derived by the Prolog interpreter. Also, if
?-sem(elephant#1,P, _ ).
is executed, all properties about elephant#l call be obtained as follows:
P = birthYear:1980;
P = isa:elephant;
P = isa:mammal ;
P = bloodTelnp:warm;
P = isa:animal;
P = isa:creature;
P = age:6
is exeeutcd,
X = clyde#l;
X = elephant#l;
5
X = elephant
Finally, if
?-sem (animal ,hasa:X,_). .
From the semantic processing procedures in i) through iii) above, the following call
be seen:
6
Thus, if lexical items are described in DCKR programs central to semantic
processing call be replaced by the basic computation mechanism built in Prolog.
Sdec(SynVp,SemSdec) - - >
np(SynSub j,SemSub j),
vp(SynVp,SemVp),
{concord(SynSub j,SynVp),
seminterp(SemVp,sub j : SemSub j,SemSdec) }.
8. Test result:
input sentences:
He opens the door with a key.
sem(open#5,P,S) :- isa(open,P,open#SIS).
sem(open#5,agent:he#4, ).
sem(open#5,instrument:key#7,).
sem(open#5,object:door#6, ).
sem(he#4,P,S/ :- isa(he,P,he#41S).
sem(door#6,P,S) :- isa(door,P,door#61S).
sem(door#6,det:the, ).
7
sem(key#7,P,S) :- isa(key,P,key#71S).
sem(key#7,det:a,_).
Besides, results of semantic processing of "the door with a key" are obtained but
their explanation is omitted.
Here it is to be noted that results of semantic processing are also in
DCKR form. By obtaining semantic processing results in DCKR form, it is
possible to get, for example,
sem(open#J,instrument:X, )
from the interrogative sentence "With what does he open the door?" and get the
answer
X=key#7
by merely executing that.
9. Conclusion:
8
general knowledge and a dictionary are described in DCKR, part of context
processing and the greater part of semantic processing can be left to the functions
built in Prolog. As for syntactic processing, the grammar rules described in DCG
[ Pereira 802] automatically converted into a Prolog program, and parsing can be
replaced by Prolog program execution.
10. References:
9
TABLE OF CONTENTS
1____________________________________________________________________
INTRODUCTION 1
2____________________________________________________________________
WHAT IS PROLOG? 1
3____________________________________________________________________
LINGUISTICS AND LANGUAGE PROCESSING 1
4____________________________________________________________________
APPLICATION OF LANGUAGE PROCESSING 2
5____________________________________________________________________
DCKR 3
6____________________________________________________________________
KNOWLEDGE REPRESENTATION IN DCKR 3
7____________________________________________________________________
SEMANTIC PROCESSING OF NATURAL LANGUAGE 4
7.1. DESCRIPTIONS OF LEXICAL ITEMS IN DCKR 6
7.2. DESCRIPTION OF GRAMMAR RULE 7
8___________________________________________________________________
THE RESULT 7
9___________________________________________________________________
CONCLUTION 8
10__________________________________________________________________
REFERANCE 9
10