Simply Logical – Chapter 7© Peter Flach, 2000 Context-free grammar sentence--> noun_phrase,verb_phrase. noun_phrase--> proper_noun. noun_phrase--> article,adjective,noun.

Slides:



Advertisements
Similar presentations
Chapter 4 Syntax Part IV.
Advertisements

Artificial Intelligence: Natural Language and Prolog
International Technology Alliance In Network & Information Sciences International Technology Alliance In Network & Information Sciences Fact Extraction.
Simply Logical – Chapter 2© Peter Flach, 2000 Clausal logic Propositional clausal logic Propositional clausal logic expressions that can be true or false.
Prolog programming....Dr.Yasser Nada. Chapter 8 Parsing in Prolog Taif University Fall 2010 Dr. Yasser Ahmed nada prolog programming....Dr.Yasser Nada.
1 First order theories (Chapter 1, Sections 1.4 – 1.5)
Logic Programming Two possible work modes: 1.At the lab: Use SICstus Prolog. To load a prolog file (*.pl or *.pro extension) to the interpreter, use: ?-
Simply Logical – Chapter 3© Peter Flach, 2000 :-teaches(peter,ai_techniques) :-teaches(peter,expert_systems) :-teaches(peter,computer_science) ?-student_of(S,peter)
Day 1 Punctuation and Capitalization
Day 1 Punctuation and Capitalization
Number bonds to 10,
Day 1 Punctuation and Capitalization
1 Programming Languages (CS 550) Mini Language Interpreter Jeremy R. Johnson.
CSA2050: DCG I1 CSA2050 Introduction to Computational Linguistics Lecture 8 Definite Clause Grammars.
Logic Programming – Part 2 Lists Backtracking Optimization (via the cut operator) Meta-Circular Interpreters.
Logic Programming – Part 2 Lists Backtracking Optimization (via the cut operator) Meta-Circular Interpreters.
Cs7120 (Prasad)L21-DCG1 Definite Clause Grammars
CSA4050: Advanced Topics in NLP Semantics IV Partial Execution Proper Noun Adjective.
Logic Programming (cont’d): Lists Lists in Prolog are represented by a functor (similar to cons in Scheme): 1.The empty list is represented by the constant.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Prolog COMP 112 #
Dinosaur Ghosts Writing & Grammar Transitive and Intransitive Verbs Being Verbs and Linking Verbs.
1 Grammars and Parsing Allen ’ s Chapters 3, Jurafski & Martin ’ s Chapters 8-9.
DEFINITE CLAUSE GRAMMARS Ivan Bratko University of Ljubljana Faculty of Computer and Information Sc.
1 CS 385 Fall 2006 Chapter 14 Understanding Natural Language Problems.
Noun. Noun - verb noun Noun - verb article- adj. - adj. - Noun - verb.
Introduction to Prolog What is Prolog? Application Areas of Prolog How does Prolog work? (Syntax of Prolog) Program Structure.
Parsing: Features & ATN & Prolog By
LING 364: Introduction to Formal Semantics Lecture 4 January 24th.
Context Free Grammar S -> NP VP NP -> det (adj) N
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 2 Tutorials Revision of formalisation Interpreting logical statements in NL Form and Content of an Argument.
LING 388: Language and Computers Sandiway Fong Lecture 13: 10/10.
Grammar Rules. Pronouns 1.Use as a S, DO, PN, or IO 2.Personal pronouns may be adjectives 3.Relative pronouns may introduce adjective clauses.
For Friday Finish chapter 23 Homework: –Chapter 22, exercise 9.
LING 388: Language and Computers Sandiway Fong Lecture 7.
Overview Project Goals –Represent a sentence in a parse tree –Use parses in tree to search another tree containing ontology of project management deliverables.
Natural Language Processing Lecture 6 : Revision.
CS : Language Technology for the Web/Natural Language Processing Pushpak Bhattacharyya CSE Dept., IIT Bombay Constituent Parsing and Algorithms (with.
PHRASE STRUCTURE GRAMMARS RTNs ATNs Augmented phrase structure rules / trees.
Computing Science, University of Aberdeen1 CS4025: Logic-Based Semantics l Compositionality in practice l Producing logic-based meaning representations.
Semantic Construction lecture 2. Semantic Construction Is there a systematic way of constructing semantic representation from a sentence of English? This.
The man bites the dog man bites the dog bites the dog the dog dog Parse Tree NP A N the man bites the dog V N NP S VP A 1. Sentence  noun-phrase verb-phrase.
Parts of Speech Major source: Wikipedia. Adjectives An adjective is a word that modifies a noun or a pronoun, usually by describing it or making its meaning.
LANGUAGE ARTS LA WORKS UNIT 3 REVIEW STUDY GUIDE.
Making it stick together…
Curry A Tasty dish? Haskell Curry!. Curried Functions Currying is a functional programming technique that takes a function of N arguments and produces.
Natural Language Processing Slides adapted from Pedro Domingos
◦ Process of describing the structure of phrases and sentences Chapter 8 - Phrases and sentences: grammar1.
The final chapter.  Constituents ◦ Natural groupings of a sentence  Morphemes ◦ Smallest meaningful units of a word  How to test whether a group of.
Unit 1 Language Parts of Speech. Nouns A noun is a word that names a person, place, thing, or idea Common noun - general name Proper noun – specific name.
When our vacation ended Piper and Levy climbed up in the tree, and they would not answer their mother. 1. Which answer contains the prepositional phrase.
SYNTAX.
Context Free Grammars. Slide 1 Syntax Syntax = rules describing how words can connect to each other * that and after year last I saw you yesterday colorless.
Grammars.
The World of Verbs.
Daily Grammar Practice Week One Grade 8
Statistical NLP: Lecture 3
Day 1: Punctuation & Capitalization
FORMAL LANGUAGES AND AUTOMATA THEORY
Day 1: Punctuation & Capitalization
Chapter 4 Basics of English Grammar
A Review of words and phrases cont.
Grundlagen Englisch Verb patterns HFW Bern Philipp Brunner.
For the week of October DGP For the week of October
Daily Grammar Practice Week One Grade 8
Linguistic Essentials
Chapter 4 Basics of English Grammar
Curry A Tasty dish? Haskell Curry!.
Day 1 Punctuation and Capitalization
Lecture 7: Definite Clause Grammars
HSP3 Grammar Review By: [Insert your name].
Presentation transcript:

Simply Logical – Chapter 7© Peter Flach, 2000 Context-free grammar sentence--> noun_phrase,verb_phrase. noun_phrase--> proper_noun. noun_phrase--> article,adjective,noun. noun_phrase--> article,noun. verb_phrase--> intransitive_verb. verb_phrase--> transitive_verb,noun_phrase. article--> [the]. adjective--> [lazy]. adjective--> [rapid]. proper_noun--> [achilles]. noun--> [turtle]. intransitive_verb--> [sleeps]. transitive_verb--> [beats]. p.132

Simply Logical – Chapter 7© Peter Flach, 2000 Parse treesentencenoun_phraseverb_phrase articleadjectivenountransitive_verbnoun_phrase proper_noun achillesbeatsturtlerapidthe p.133

Simply Logical – Chapter 7© Peter Flach, 2000 Exercise 7.1 p.133

Simply Logical – Chapter 7© Peter Flach, 2000 Exercise 7.2 (1) p.133sentence np,vp pn,vp art,adj,n,vp art,n,vp [achilles], vp [the], adj,n,vp [the], n,vp [the],[lazy], [the],[rapid], [the],[turtle], vp [the],[lazy], [turtle],vp [the],[rapid],

Simply Logical – Chapter 7© Peter Flach, 2000 Exercise 7.2 (2)[the],[lazy], [turtle],vp [the],[lazy], [turtle],iv [the],[lazy], [turtle],tv,np [the],[lazy], [turtle],[sleeps] [the],[lazy], [turtle],[beats],np [the],[lazy], [turtle],[beats], pn [the],[lazy], [turtle],[beats], art,adj,n [the],[lazy], [turtle],[beats], art,n [the],[lazy], [turtle],[beats], [achilles] [the],[lazy], [turtle],[beats], [the],n [the],[lazy], [turtle],[beats], [the],[turtle] [the],[lazy], [turtle],[beats], [the],adj,n [the],[lazy], [turtle],[beats], [the],[lazy],n [the],[lazy], [turtle],[beats], [the],[rapid],n [the],[lazy], [turtle],[beats], [the],[lazy],[turtle] [the],[lazy], [turtle],[beats], [the],[rapid],[turtle] p.133

Simply Logical – Chapter 7© Peter Flach, 2000 Difference lists in grammar rules noun phrase verb phrase VP2 VP1 NP1 sentence(NP1-VP2):- noun_phrase(NP1-VP1), verb_phrase(VP1-VP2) p.135

Simply Logical – Chapter 7© Peter Flach, 2000 Meta-level vs. object-level META- LEVEL OBJECT- LEVEL GRAMMAR PARSING s --> np,vp s(L,L0):- np(L,L1), vp(L1,L0) ?-phrase(s,L) ?-s(L,[]) p.136

Simply Logical – Chapter 7© Peter Flach, 2000 Non-terminals with arguments sentence--> noun_phrase(N),verb_phrase(N). noun_phrase--> article(N),noun(N). verb_phrase--> intransitive_verb(N). article(singular)--> [a]. article(singular)--> [the]. article(plural)--> [the]. noun(singular)--> [turtle]. noun(plural)--> [turtles]. intransitive_verb(singular)--> [sleeps]. intransitive_verb(pluralr)--> [sleep]. p.137

Simply Logical – Chapter 7© Peter Flach, 2000 Constructing parse trees sentence(s(NP,VP))--> noun_phrase(NP),verb_phrase(VP). noun_phrase(np(N))--> proper_noun(N). noun_phrase(np(Art,Adj,N))--> article(Art),adjective(Adj), noun(N). noun(N). noun_phrase(np(Art,N))--> article(Art),noun(N). verb_phrase(vp(IV))--> intransitive_verb(IV). verb_phrase(vp(TV,NP))--> transitive_verb(TV), noun_phrase(NP). article(art(the))--> [the]. adjective(adj(lazy))--> [lazy]. adjective(adj(rapid))--> [rapid]. proper_noun(pn(achilles))--> [achilles]. noun(n(turtle))--> [turtle]. intransitive_verb(iv(sleeps))--> [sleeps]. transitive_verb(tv(beats))--> [beats]. ?-phrase(sentence(T),[achilles,beats,the,lazy,turtle]) T = s(np(pn(achilles)), vp(tv(beats), np(art(the), adj(lazy), n(turtle)))) p.137-8

Simply Logical – Chapter 7© Peter Flach, 2000 Prolog goals in grammar rules numeral(N)--> n1_999(N). numeralN)--> n1_9(N1),[thousand],n1_999(N2), {N is N1*1000+N2}. {N is N1*1000+N2}. n1_999(N)--> n1_99(N). n1_999(N)--> n1_9(N1),[hundred],n1_99(N2), {N is N1*100+N2}. {N is N1*100+N2}. n1_99(N)--> n0_9(N). n1_99(N)--> n10_19(N). n1_99(N)--> n20_90(N). n1_99(N)--> n20_90(N1),n1_9(N2),{N is N1+N2}. n0_9(0)--> []. n0_9(N)--> n1_9(N). n1_9(1)--> [one]. n1_9(2)--> [two]. … n10_19(10)--> [ten]. n10_19(11)--> [eleven]. … n20_90(20)--> [twenty]. n20_90(30)--> [thirty]. … ?-phrase(numeral(2211),N). N = [two,thousand,two,hundred,eleven] ?-phrase(numeral(2211),N). p.138-9

Simply Logical – Chapter 7© Peter Flach, 2000 Interpretation The meaning of the proper noun Socrates is the term socrates The meaning of the proper noun Socrates is the term socrates proper_noun(socrates)--> [socrates]. The meaning of the property mortal is a mapping from terms to literals containing the unary predicate mortal The meaning of the property mortal is a mapping from terms to literals containing the unary predicate mortal property(X=>mortal(X))--> [mortal]. The meaning of a proper noun - verb phrase sentence is a clause with empty body and head obtained by applying the meaning of the verb phrase to the meaning of the proper noun The meaning of a proper noun - verb phrase sentence is a clause with empty body and head obtained by applying the meaning of the verb phrase to the meaning of the proper noun sentence((L:-true))--> proper_noun(X),verb_phrase(X=>L). ?-phrase(sentence(C),[socrates,is,mortal]. C = (mortal(socrates):-true) p.140

Simply Logical – Chapter 7© Peter Flach, 2000 Exercise 7.4 A transitive verb is a binary mapping from a pair of terms to literals A transitive verb is a binary mapping from a pair of terms to literals transitive_verb(Y=>X=>likes(X,Y)) --> [likes]. A proper noun instantiates one of the arguments, returning a unary mapping A proper noun instantiates one of the arguments, returning a unary mapping verb_phrase(M) --> transitive_verb(Y=>M),proper_noun(Y). p.140

Simply Logical – Chapter 7© Peter Flach, 2000 Interpretation (2) sentence((L:-true)) --> proper_noun(X),verb_phrase(X=>L). sentence((H:-B)) --> [every],noun(X=>B),verb_phrase(X=>H). % NB. separate determiner rule removed, see later verb_phrase(M)--> [is],property(M). property(M)--> [a],noun(M). property(X=>mortal(X))--> [mortal]. proper_noun(socrates)--> [socrates]. noun(X=>human(X))--> [human]. p.140-1

Simply Logical – Chapter 7© Peter Flach, 2000 Interpretation (3) ?-phrase(sentence(C),S). C = human(X):-human(X) S = [every,human,is,a,human]; C = mortal(X):-human(X) S = [every,human,is,mortal]; C = human(socrates):-true S = [socrates,is,a,human]; C = mortal(socrates):-true S = [socrates,is,mortal]; p.141

Simply Logical – Chapter 7© Peter Flach, 2000 Determiners Determiner sentences have the form every/some [noun] [verb- phrase] (NB. meanings of some sentences require 2 clauses) Determiner sentences have the form every/some [noun] [verb- phrase] (NB. meanings of some sentences require 2 clauses) sentence(Cs) --> determiner(M1,M2,Cs),noun(M1),verb_phrase(M2). determiner(X=>B, X=>H,[(H:-B)]) --> [every]. determiner(sk=>H1,sk=>H2,[(H1:-true),(H1:-true)] --> [some]. ?-phrase(sentence(Cs),[D,human,is,mortal]). D = every, Cs = [(mortal(X):-human(X))]; D = some, Cs = [(human(sk):-true),(mortal(sk):-true)] p.141

Simply Logical – Chapter 7© Peter Flach, 2000 Questions question(Q)--> [who],[is],property(X=>Q). question(Q)--> [is],proper_noun(X),property(X=>Q). question((Q1,Q2))-->[is],[some],noun(sk=>Q1), property(sk=>Q2). p.142

Simply Logical – Chapter 7© Peter Flach, 2000 Querying a rulebase handle_input(Question,Rulebase):- phrase(question(Query),Question),% question prove_rb(Query,Rulebase),!,% it can be solved transform(Query,Clauses),% transform to phrase(sentence(Clauses),Answer),% answer show_answer(Answer), nl_shell(Rulebase). p.143