Friday, 24 February 2017

AUTOMATIC CONVERSION OF NATURAL LANGUAGE SENTENCES INTO LOGIC FORMS, Syed J. Ashraf, at el, 20th Mar 1989 Posted on June 7, 2013

Meta Knowledge/ Knowledge Calculus - classification of Action Research

AUTOMATIC CONVERSION OF NATURAL LANGUAGE SENTENCES INTO LOGIC FORMS, Syed J. Ashraf, at el, 20th Mar 1989


 MESSAGE: DEDICATED TO ANONYMOUS COMBATANTS OF KNOWLEDGE

مکتب علم الل مہد منل لحد   Learning continues from birth to death
*************
AUTOMATIC CONVERSION OF NATURAL LANGUAGE
SENTENCES INTO LOGIC FORMS
( AN APPLICATION REVIEW )


HILAL A. QURESHI, SYED J. ASHRAF AND WADOOD AHMAD

(Received 20th March, 1989)

 Abstract
 An interference Engine has been developed in Prolog to parse natural language sentences into their Predicate Logic form indicating scoping, quantification,  singular/plural of nouns and different  forms of verbs. Definite Clause Grammar has been extended in the present study. The Logic forms generated retain the meaning contents of the input sentences discarding their English language structure.
 Introduction
 Among the branches of Artificial Intelligence (AI), Natural Language Processing (NLP) has been second to expert systems (ES) when considered from point of view of research and application. In the next few years, it is going to be explored more vigorously. The motivation for this interest in NLP arises from the desire to

1.       Make   machines easier for humans to use by accepting Natural Language (NL)  input and producing NL output.
2.       Gain better understanding of how humans store, think about and communicate   knowledge.  Better knowledge of human reasoning, decision making and self expressions is more important than designing a few products that display human like capabilities.
3.       Translate one human language into another with the help of computers.    This has turned out to be problem of much larger dimensions and complexity than it was initially thought to be.
By Natural language we mean some agreement amongst humans living in some part of this world on what different words or symbols mean and in what ways can these be combined to carry meanings of various combination of symbols and words in more complex combinations. In other words NL is a collection of symbols, words and grammars.
By a NL program we mean a collection of software instructions capable of accepting inputs in human language and parse these inputs in tokens or components of two types namely, terminals and non–terminals. The software then uses grammar stored in terms of terminals, non–terminals and other constraints to check whether the parsed input is a  valid structure that can be expected to carry meanings. Finally, the program applies semantic rules to determine the meanings of structure in proper context.
Prolog For Natural Languages Processing
The logic programming language Prolog is specially suited for the NLP because of the following reasons .
1.       Natural Language grammars expressing non–terminals in terms of terminals   can be written directly as Prolog Program for the analysis and synthesis of natural language sentences.
2.       Prolog can produce the semantic representation of natural language text in logical forms in a natural way.
3.       Interfacing can be done with logical forms for answering queries etc by Prolog’s Inference Engine or by procedures built on top of Prolog.
Grammar Of Natural Language
                                        The objective of Natural Language grammar is to associate both semantic structure as well as syntactic structure with a sentence. The syntactic structure represents the division of sentences into phrases, subphrases and subsubphrases etc. whereas the semantic structure carries meanings and is used in inference for Database query or for Expert System. One such grammar type called Definite Clause Grammar (DCG) developed by Pereira and Warren (1980), has been extended in the present study. We will still be restricted to sentences whose structural variation will be confined to those allowed by the extended grammar adopted and will be able to use words that have been defined in our domain of constrained semantics.
Logic Form Language
                                        The semantic structure of sentences will be expressed in a particular version of predicate logic called Logical Form Language (LFL) which treats quantification, scoping and unification adequately. In LFL, each grammatical unit (part of speech) is expressed as a predicate with suitable number of arguments to carry the meanings. In the event a word is used in different senses, there is a different predicate for each of word sense used in the form that shows the intended sense.
The entire clause or sentence can also be expressed as a predicate with arguments that are logical forms, constants or variables. LFL expressions are represented as Prolog goals that can answer queries directly. LFL is a more powerful language than Prolog and hence new inference procedures have been written on top of Prolog for semantic evaluation of sentences. LFL are being studied more and more vigorously to define suitable predicates for word senses which are natural for humans. The work of D.Lewis (1975) on the quantification of adverbs and that of Sain – Dizer (1980) on two different representations of ‘many’ are presented as examples. Rules for the formation of Logic Form Language  ( A Walker et al(1986)   ) are presented next.
a.       If P is a predicate of LFL (either a word sense or non–lexical predicate) taking an arguments and each XI. X2, …… Xn is either a constant or a logical form ( as required   by   the predicate   P   for   that   argument)    or is   a   variable     ,     then P(X1,X2, ……….. Xn) is a logical form.
b.       If   P and Q  are logical forms then (P&Q) is a logical form.
c.       If  P is a logical form and E is a variable,   then P:E (read as  P indexed by E) is a logical form. When an indexed logical form P:E appears as a part of larger logical form Q,  and the index variable E is used elsewhere in Q. E can be thought of roughly as standing for P together with its context.
Examples of logical forms of some typical sentenses are presented next to indicate the richness of these forms.
1).      “ I believe that each man likes mangoes ” leads to logic form believe1  ( i, each (man1(X).  like1 (X. mangoes))).
Where   beleive1.man1   and like1 are specific senses of verb “believe”, noun “man” and verb “like”.
2).      “Ahmed asks Ali to find Aslam” leads to logic form ask (Ahmed, Ali,  find (Ali, Aslam))
 3).      “Ali is seen by Akbar” leads to logic form be passive (Ali, seen(Akbar. Ali))
4).      “each boy eats several apples” leads to logic form each (boy(X). several(apple(Y).  eat(X.Y))) we see double quantification nested “several” within “each”
5).      “each man that owns a car washes it “leads to logic form each (man (X)&car(Y) & own(X. Y), wash(X. Y))
 6).      “Every body that knows many people knows    Aslam”  leads to logic from every(person(X) & many(person(Y) & know(Xo,Y). Xo–X).know (X.Aslam)) Here X is the counting variable of every and Y is the counting variable of many, X could not be taken in the base clause of many,  hence  Xo  was used as crossectional variable which   is related by equality to higher bound X in the focus clause of   “  many  ”.  A general sense of many is given by : cardlist  (X,  person(X)    &   knowt (Y,X), Y.B) cardlist (X, person(X) & know (Y,X), Y,B) & cardlist  (X,person(X) & know (Y.X) & Y– ahmed.Y.BF) & large  (BF, B,Y).
 Where cardlist represents cardinality of a set. BF is cardinality of set of people  ahmed knows,  B is the cardinality of set of people most people know.
 7).      “salma owns a cat ” leads to logic form ex ( cat(X),  own( Salma.X))
 8).      “some students like every game ” leads to two possible   logic forms
  a)     ex (student(X). all (game(Y). likes (X.Y))
  b)     all  (game (Y, ex (student(X). like (X,Y)))
 9).      “Every body is not here yet” not (yet (all  (person(X), here(X))))
 10).    “Jawed always buys books at paramount “leads to logic form always ((book(X) & buy(jawed,X)  : E,  at (paramount, E))
 11).    “Jawed   ran    fastest   yesterday    ”    leads    to    logic    forms depending upon whether forces is on “yesterday” or on “Jawed” “fastest (run (jawed): E. yesterday (E)  )” fastest (yesterday (run (X)  ),X – jawed )
 12).    “Jawed is good as a singer but bad as a batsman ” leads to logic form but( good  (singer  (X),X – Jawed ).bad (batsman(X).X – jawed))
13).    “did Jawed see Salma yesterday ? ”  yesno (yesterday (see (jawed,X), X – Salma  )  )
 Whoever Jawed saw yesterday,  Salma was one among them.
 14).    “After cat eats,  it sleeps” leads to logic form after (cat(X) & eat(X)     , sleep (X)  )
 15).    “When Zaid arrived, he was tired” leads to logic form past(when (arrived (zaid). tired (zaid)  )
 Logic Forms For Verbs
                               The verb is the head or the main word of a sentence that contains informations about the action.
Modifiers grouped as complements and adjuncts are normally present around the head verb to modify its meanings.  For example in the sentence   “Ahmad definitely knows the little girl”,  the modifiers of “knows’ are “Ahmad”, adverbal  “definitely” and object nounphrase    “the little girl”. The LFL word sense predicate for this head verb will have one argument for each complement of the verb. Only a few verbs have senses that are    represented by predicates with no arguments as “It shows    “,    others are represented by predicates with one two or atmost three arguments.
 Inflections
 A word sense is called intensional if atleast one of its arguments is a logic form.
Many words have varied forms like the necessary tenses of the verb or plural of a noun. Such words, slightly differing in lexicon but related, are called inflections. One of their form is chosen as the citation form ( The infinitive form of a verb ) and this is used as the indexing operator in the lexicon. The constraints in the grammar can be implemented by associating features with the inflection forms of a word. English verbs forms are of two types non–finite and finite. The nonfinite inflectional
 inf – infinitive – take
ing – present participle – taking
en – pset participle – taken.
The finite verb forms have a tense and can show, variation for person and the number. Hence, for finite verb we use a feature that is a compound term fin (Pers. Num. Tense) where pers is persl for first person or pers3 for third person. Num is sg(singular) or pl(plural) and tense is past or pres. (Second person is not indicated because it behaves like third person P1ura1).
The following three finite forms cover most of English verbs
1)       fin(pers3;sg,pres) – has an  ‘s’ or  ‘as’ ending
2)       fin (* . * .   pres) – has the form of infinitive.
3)       fin (* . *.  past)
A predicate that relates a verb form V and its inflection feature lnf1 to its infinitive   form  V  inf  is of the form verbf (V.Vinf,Inf1) whose special occurrences are verbf (sees.see.fin (pers3.sg,pres)) verbffaw,see,  fin(*.*. past )   )
 In English language all verbs, other like than “be”  or model verbs like “can” can be covered adequately by storing at most five distinct inflectional forms.
 V                 Inf
Vs                fin(pers3,sg,pers)
Ved              Past
Ven en         Past participle.
Ving ing      Present participle
 All these Inflectional forms are placed in compact unit clauses. These received verbs form is formed in there forms and its inflection passed back for further follow up action.
 For nouns a predicate nounf (N.nsg,nura) will be used for relating  a noun to its singular form nsg (used as citation form)  giving clauses like nounf (men,man,p1) or noun (man.men sg).
 Inference Procedure
                     As logical form language is more powerful than Prolog, a separate inference engine must be written on top of that of Prolog to represent the meanings of and later to interpret the Natural Language sentences of the constrained domain. In the present study, the following Inference Engine has been developed for parsing Natural Language sentences and generating their logical  form.
 Start :–
 readln(S)
separate (S,SL)
logic_form (LFL,SL, (), FORMS),
logic_form(S,U,W,SFORM)  :–
np(X,V,P,S,U,V,NFORM)
vp(X,VP,V,W,VFORM)
append (NFORM,VFORM,SFORM),
 np (X, FOCUS, NP, U,Z,NFORM) :–
det(BASE, FOCUS, NP,U,V),
noun (X,B,V,W,NL),
rel_clause (X,B, Base, W,Z,VL)
append ([NL],VL,NFORM)
 np(X,NP,NP,U,V,(INF)) :–
name (X,U,V,NF),
np(X,NP,NP,(U:Z), Z,(1) :–
pn(U),
vb(_,X,_,NP,_),
 noun(X,ad (ALFL,NLFL), (U:V), Z,NFORM) :–
adj (U,X,ALFL),
noun(X,NLFL,V, Z, NFORM),
 noun (X,P, (N:T], T,NF) :–
nn(N,X,P,NF),
 name(e(N), (N:T), T,n (N,3)) :–
nm(N),
 vp(X,VP,U,W, (n(VK,RT) : VFORM) :–
aux(U,XX,VK,I),
verb(X,Y, VF, XX,V,VFM),
np(Y,VF,VP,V,W,NFORM),
append((VFM), NFORM,VFORM),
rt_verb_inf(VFORM,INF),
check_inf(I, INF, RT),
 vp(X,VP,U,W,(n(VK,RT) : VFORM)) :–
aux(U,XX,VK,I),
verb3(X,Y,Z,VP,XX,V,VFRM),
object_phrase(Y,Z,V,W,OFRM),
append ( IVFRM), OFRM, VFORM),
rt_verb_ inf (VFORM, INF),
check_inf (I, INF, RT),
 rel_clause(X,B, ad(B,VP), (that:U),V, RLFORM) :–
vp(X,VP,U,V,RLFORM),
rel_clause (_,B,B,U,U,(1),
 verb (X,Y,P, (V:T), T,VFORM) :–
vb(V,X,Y,P,VFORM),
 object_phrase (BASE,Z,V,W,NFOR) :–
det(BASE, Z,_,V,Ll),
noun(_,BASE, LI,X,NFORM),
to_phrase(X,L),
np(Z,_,_,L,W,NMFORM),
append (INFORM), NMFORM, NFOR),
 NATURAL LANGUAGE SENTENCES
 object_phrase(Y,VF,V,W,OFORM) :–
                                        np(Y,_,_,V,X,M1),
to_phrase(X, L),
verb(Y,X1,VF,L,V1,M2),
np(Xl,VF,_,Vl,W,M3),
append (M1, (M2), M4),
append(M4,M3,0F0RM),
 dot    ,F, P, (D:U),U) :–
dt (D,B,F,P),
                               The process starts by reading generating a list of tokens from the sentence, ‘logic_form’ returns the logic form by calling ‘np’ (the noun phrase predicate) and ‘vp’ (the verb phrase predicate), The noun phrase ‘ np’ is defined as a determiner followed by a noun followed by a relational clause (i,e that ) or just a proper noun or a pronoun that makes the base of the verb as its object, The verb phrase ‘ vp’ is defined as a verb followed by a noun phrase, ‘noun’ is either just a noun ‘nn’ or it is an adjective followed by a noun,’rel_clause’ separates the ‘that’ from the list and returns the corresponding verb phrase, The output from all of the predicates is an associated logical form of the type given below,


  1. nn(man,X,man(X)),
  2. pn(himself),
  3. nm (ahmed),
  4. adj(good,X,good(X)),
  5. dt(each,B,F,all(B,F)),
  6. vb(washes,X,Y,washes(X,Y)),
 The, logical form of a common noun is one place predicate man is man where X is the object, same is the logical form for adjectives, In case of determiners, the logical form is the associated determiner along with its Base and Focus, In case of verb the associated verb is returned with its object and subject, The logical form of a proper noun is the name itself, The case of pronoun is very different, here the logical form is determined by first determining the object at which this pronoun is intended,
 Operational Results
                               The Inference Engine mentioned above handles quantification, singulars or plurals of nouns, all the five inflectional    forms of verb and the passive voice of sentences, This inference engine has been used with a very restriced Knowledge Base to generate logical forms, Some of the outputs, produced by our Inference procedure are presented below,

1,       SENTENCE –> each man loves a woman
LOGIC FORM –> all(man(X), ex(woman(Y), love(X,Y)))
(man (singular), sent (active voice),  love(fin), woman (singular))
 2,       SENTENCE –> every woman that loves a man loves ahmed
          LOGIC FORM – > all(and(woman(Y),ex(man(X), love(Y,X))), love(Y,ahmed))
(woman (singular), sent (active voice),  love (fin), man (singular)
sent (active voice), love (fin) ahmed (proper noun))
 3,       SENTENCE –> each woman that loves ahmed loves a man
          LOGIC FORM –> all(and(woman(Y), love(Y,ahmed)), ex(man(X),love(Y,X)))
(woman (singular), sent (active voice), love (fin), ahmed (proper noun)
sent (active voice),  love(fin), man (singular))
 4,       SENTENCE –> every man that owns a car washes it
LOGIC FORM –> all(and(man(X),ex(car(Y),own(X,Y))),wash(X,Y))
(man(singular),sent  (active voice),own  (fin),car    (singular),
sent (active voice),wash (fin))
 5,       SENTENCE –> each boy eats several apples
LOGIC FORM –> all (boy(X),several (apple(Y),eat (X,Y)))
(boy (singular),sent (active voice),eat (fin),apple(plural))
 6,       SENTENCE –> beena owns a cat
LOGIC FORM –> ex(cat(X),own(beena,X))
(beena (proper noun),sent (active voice),own (fin),cat (singular))
 7,       SENTENCE –> the good old nice man likes every car
LOGIC FORM –> the(and(good(X),and(old(X),and(nice(X),man(X)))),
all(car(Y,like(X,Y)))
(man (singular),sent (active voice),like (fin),car (singular))
 8,       SENTENCE –> every man likes himself
LOGIC FORM –> all(man(X),like(X,X))
(man (singular),sent  (active voice),like (fin))

9,       SENTENCE –> ahmed likes himself
LOGIC FORM –> like(ahmed,ahmed)
(ahmed (proper noun),sent  (active voice),like (fin))

10,     SENTENCE –> ahmed gave the cat to beena
LOGIC FORM –> give(ahmed,cat(X),beena)
(ahmed (proper noun),sent (active voice),give (past),cat (singular),beena
(proper noun))
 11,     SENTENCE –> beena has taken the cat from ahmed
LOGIC FORM –> take(beena,cat(X),ahmed)
(beena  (proper noun),has (present perfect),take (past participle)
,cat  (singular),ahmed  (proper noun))
 12,     SENTENCE –> beena took the cat from ahmed
LOGIC FORM –> take(beena,cat(X),ahmed)
(ahmed (proper noun),sent (active voice),take (past),cat (singular)
,ahmed (proper noun))
 13      SENTENCE  –> ahmed was given the cat by beena
LOGIC FORM –> give(ahmed,cat(X),beena)
 14,     SENTENCE – > beena is taking the cat to ahmed
LOGIC FORM –> take(beena,cat(X), ahmed)
(ahmed (proper noun), is (active voice), take (present participle),
cat (singular), beena (proper noun))
 15,     SENTENCE –> beena has taken the cat from ahmed
LOGIC FORM –> take (beena,cat (X),ahmed)
ahmed (proper noun), has (present perfect), take (past participle)
cat (singular), beena (proper noun))
 16,     SENTENCE –> ahmed has a car
LOGIC FORM –> ex(car(X),has (ahmed,X))
(ahmed (proper noun), sent (active voice), has (infinitive)
car (singular))
 17,     SENTENCE –> ahmed asked beena to find wadood
LOGIC FORM –> ask (ahmed, beena, find (beena,wadood))
(ahmed (proper noun),sent (active voice), ask (past),
beena (proper noun), find (infinitive),wadood (proper noun)),
 18,     SENTENCE –> a man likes himself
LOGIC FORM –> ex(man(X),like(X,X))
(man (singular),sent (active voice),like (fin))
 Conclusion
 The Inference Engine described above works satisfactorily to parse the natural languages sentences into their grammatical parts and gives enough information about the tenses of verbs, the voice of sentences and the classification of nouns, The logical for generated for the sentences retain the essential meanings, The inflections generated for verbs and nouns can be used to decide the thematic roles of various objects, The work on the determination of thematic roles is continuing with an objective to be able to draw meanings and answer queries,
 Acknowledgement
 The authors express their thanks to the Institute of Computer Science, BCCI–FAST, Karachi for patronage and support,
 References
 (1)     D Lewis “Adverbs of quantification ” Formal Semantics
of Natural Languages – Cambridge Univesity Press (1975),
 (2)     Pareira and Warren “Definite Clause Grammar for Language Analysis – A    survey of formalism and a comparison with transition network ” Artificial Intelligence Vol 13, 231–278 (1980),
 (3)     Saint–Dizier “An Approach to Natural Language Semantics in Logic Programming ”  Journal of Logic Programming (1986),
 (4)     Adrian Walker   “Knowledge System and Prolog”
Addison–Wesley (1987),
 (5)     P H Wintson  “Artificial Intelligence” Addison–Wesley (1984),
 *********** 
FOR PROMOTION OF LEARNEDNESS SHARE WITH FRIENDS ABOUT;
   
  1. CAUSE AND EVENTS – SPATIAL And TEMPORAL RESPECTIVELY:                         https://be4gen.wordpress.com/2012/11/16/cause-and-events-spatial-temporal-respectively/

  1. WHETHER ‘BRAIN-POWER’ OR ‘HEART-IMPULSE’ PLINTHS ‘HUMAN GEN’? http://sunedu.wordpress.com/2012/09/17/whether-brain-power-or-heart-impulse-plinths-human-gen/

************
Advertisements
Related

No comments:

Post a Comment