Natural Language Processing AI - Weeks 19 Natural Language Processing PART 2 Lee McCluskey, room 2/07

Slides:



Advertisements
Similar presentations
Application: Yacc A parser generator A context-free grammar An LR parser Yacc Yacc input file:... definitions... %... production rules... %... user-defined.
Advertisements

Prolog programming....Dr.Yasser Nada. Chapter 8 Parsing in Prolog Taif University Fall 2010 Dr. Yasser Ahmed nada prolog programming....Dr.Yasser Nada.
Natural Language Processing Lecture 2: Semantics.
Cs7120 (Prasad)L21-DCG1 Definite Clause Grammars
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Prolog COMP 112 #
1 Grammars and Parsing Allen ’ s Chapters 3, Jurafski & Martin ’ s Chapters 8-9.
Statistical NLP: Lecture 3
DEFINITE CLAUSE GRAMMARS Ivan Bratko University of Ljubljana Faculty of Computer and Information Sc.
01/11/04 AIPP Lecture 11: Parsing and Semantics in DCGs1 Parsing and Semantics in DCGs Artificial Intelligence Programming in Prolog Lecturer: Tim Smith.
1 CS 385 Fall 2006 Chapter 14 Understanding Natural Language Problems.
Fall 2008Programming Development Techniques 1 Topic 9 Symbol Manipulation Generating English Sentences Section This is an additional example to symbolic.
Natural Language Processing DCG and Syntax NLP DCG A “translation” example: special case A DCG recogniser.
LING NLP 1 Introduction to Computational Linguistics Martha Palmer April 19, 2006.
For Monday Read Chapter 23, sections 3-4 Homework –Chapter 23, exercises 1, 6, 14, 19 –Do them in order. Do NOT read ahead.
CPSC Compiler Tutorial 9 Review of Compiler.
Natural Language Processing - Feature Structures - Feature Structures and Unification.
Understanding Natural Language
NLP Syntax1 Syntax The Structure of language Dave Inman.
FACS Week 14 Grammars and their properties; Introduction to Parsing Lee McCluskey, room 2/07
Natural Language Processing AI - Weeks 19 Natural Language Processing PART 2 Lee McCluskey, room 2/07
Parsing Using Logic Programing (well Prolog) Lee McCluskey, room 2/07
CS 330 Programming Languages 09 / 13 / 2007 Instructor: Michael Eckmann.
Natural Language Processing AI - Weeks 19 & 20 Natural Language Processing Lee McCluskey, room 2/07
 Christel Kemke 2007/08 COMP 4060 Natural Language Processing Feature Structures and Unification.
1 Understanding Natural Language The Natural Language Understanding Problem 14.1Deconstructing Language: A Symbolic Analysis 14.2Syntax 14.3Syntax.
Formal Aspects of Computer Science – Week 12 RECAP Lee McCluskey, room 2/07
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Using Definite Knowledge: NLP and nl_interface.pl Notes for Ch.3 of Poole et.
LING 388: Language and Computers Sandiway Fong Lecture 8.
March 1, 2009 Dr. Muhammed Al-Mulhem 1 ICS 482 Natural Language Processing INTRODUCTION Muhammed Al-Mulhem March 1, 2009.
LING/C SC/PSYC 438/538 Lecture 19 Sandiway Fong 1.
Grammars and Parsing. Sentence  Noun Verb Noun Noun  boys Noun  girls Noun  dogs Verb  like Verb  see Grammars Grammar: set of rules for generating.
Lecture 19 Methods of simulation of understanding of NL
Computing Science, University of Aberdeen1 CS4025: Grammars l Grammars for English l Features l Definite Clause Grammars See J&M Chapter 9 in 1 st ed,
Prolog and grammars Prolog’s execution strategy is useful for writing parsers for natural language (eg. English) and programming languages (interpreters.
CCSB354 ARTIFICIAL INTELLIGENCE (AI)
ICS611 Introduction to Compilers Set 1. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
ITEC 380 Organization of programming languages Lecture 2 – Grammar / Language capabilities.
Lecture 12: 22/6/1435 Natural language processing Lecturer/ Kawther Abas 363CS – Artificial Intelligence.
1 CS 385 Fall 2006 Chapter 14 Understanding Natural Language (omit 14.4)
For Friday Finish chapter 23 Homework: –Chapter 22, exercise 9.
LING 388: Language and Computers Sandiway Fong Lecture 7.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
LANGUAGE TRANSLATORS: WEEK 3 LECTURE: Grammar Theory Introduction to Parsing Parser - Generators TUTORIAL: Questions on grammar theory WEEKLY WORK: Read.
Intro to Lexing & Parsing CS 153. Two pieces conceptually: – Recognizing syntactically valid phrases. – Extracting semantic content from the syntax. E.g.,
Natural Language Processing AI - Weeks 18 & 20 Natural Language Processing Lee McCluskey, room 2/07
LING 388: Language and Computers Sandiway Fong Lecture 18.
Understanding Natural Language
Natural Language Processing 1.‘append’ program - two lists to one or split one list into two 2.How to write a parser in Prolog, how it works (ref. Paul’s.
Parsing. Language A set of strings from an alphabet which may be empty, finite or infinite. A language is defined by a grammar and we may also say that.
Syntax Why is the structure of language (syntax) important? How do we represent syntax? What does an example grammar for English look like? What strategies.
Artificial Intelligence: Natural Language
Grammars Grammars can get quite complex, but are essential. Syntax: the form of the text that is valid Semantics: the meaning of the form – Sometimes semantics.
Artificial Intelligence: Natural Language
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.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Computing Science, University of Aberdeen1 CS4025: Grammars l Grammars for English l Features l Definite Clause Grammars See J&M Chapter 9 in 1 st ed,
◦ Process of describing the structure of phrases and sentences Chapter 8 - Phrases and sentences: grammar1.
PZ03BX Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ03BX –Recursive descent parsing Programming Language.
Parsing and Code Generation Set 24. Parser Construction Most of the work involved in constructing a parser is carried out automatically by a program,
Natural Language Processing AI Revision Lee McCluskey, room 2/07
GRAMMARS & PARSING. Parser Construction Most of the work involved in constructing a parser is carried out automatically by a program, referred to as a.
Natural Language Processing (NLP)
NATURAL LANGUAGE PROCESSING
LING/C SC/PSYC 438/538 Lecture 19 Sandiway Fong 1.
Natural Language Processing (NLP)
Definite Clause Grammars
CS : Speech, NLP and the Web/Topics in AI
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
Artificial Intelligence 2004 Speech & Natural Language Processing
Presentation transcript:

Natural Language Processing AI - Weeks 19 Natural Language Processing PART 2 Lee McCluskey, room 2/07

Natural Language Processing NLP: the process Natural Language Generation Translation Summary/ Classification Knowledge Base: representation of meaning UNDERSTANDING PROCESS (“Natural Language Understanding”) Text (sentence, , news story..) -- Parsing -- Referencing -- Meaning Extraction and Integration

Natural Language Processing NLP: the process Knowledge Base: representation of meaning UNDERSTANDING PROCESS (“Natural Language Understanding”) Text “The cat sits on the mat” sentence npvp The cat sits on the mat Fact(type: statement, agent: cat-002, action: sits_on, object: mat-001) Fact(type: statement, agent: Fido, action: is_a, object: cat) Fact(type: statement, agent: Freda, action: loves, object: Fido)

Natural Language Processing NLP (NLU) : typical process 1.Scanning 2.Parsing 3.Finding referents for pronouns etc 4.Resolving Ambiguities 5.Meaning Extraction 6.Meaning Integration

Natural Language Processing NLP (NLU) : tools to help Parser- Generators (e.g. YACC, JavaCUP) are tools which input BNF Grammars and output Parsers for computer languages such as programming languages. Extra information can be added to the Grammar to make the Parser output useful information. PGs can be used for Natural Language Processing also. Parser Generator Grammar Parser Sentence / program Parse Tree or Syntax Error Report

Natural Language Processing NLP (NLU) : Definite Clause Grammars Prolog has a built in Parser Generator tool called the “Definite clause grammar” See This interprets grammar rules as “recursive descent” parsers (hence generating a parser immediately from the grammar). DCG - very simple example – here is a BNF grammar: --> --> i | sentences --> parse

Natural Language Processing NLP (NLU) : Definite Clause Grammars Grammar with this Prolog-looking syntax sentence --> noun, verb, noun. noun --> [i]. noun --> [sentences]. verb --> [parse]. Input this to the Prolog Interpreter gives a listing of: sentence(A, B) :- noun(A, C), verb(C, D), noun(D, B). noun(A, B) :- A = [ i | B]. noun(A, B) :- A = [sentences | B]. verb(A, B) :- A = [ parse | B ]. Try it out with sentence([i,parse,sentences],A).

Natural Language Processing Larger Example – BNF grammar for a bit of English sentence --> noun_phrase verb_phrase noun_phrase--> determiner adjective noun noun_phrase--> adjective noun noun_phrase--> determiner noun noun_phrase --> noun verb_phrase--> verb noun_phrase verb_phrase--> verb preposition noun_phrase determiner --> a | an adjective --> fruit noun --> flies | fruit | time | arrow noun --> banana verb --> like | flies preposition --> like

Natural Language Processing Example in Prolog DCG syntax sentence --> noun_phrase, verb_phrase. noun_phrase--> determiner, adjective, noun. noun_phrase--> adjective, noun. noun_phrase--> determiner, noun. verb_phrase--> verb, noun_phrase. verb_phrase--> verb, preposition, noun_phrase. determiner --> [a]. adjective --> [fruit]. noun --> [flies]. noun --> [banana]. noun --> [fruit]. noun --> [time]. noun --> [arrow]. verb --> [like]. verb --> [flies]. preposition --> [like]. This Grammar can now be loaded into Prolog and ACTS LIKE A PARSER.

Natural Language Processing Prolog Grammar Rules sentence(A, B) :- noun_phrase(A, C), verb_phrase(C, B). noun_phrase(A, B) :- determiner(A, C), adjective(C, D), noun(D, B). noun_phrase(A, B) :- adjective(A, C), noun(C, B). noun_phrase(A, B) :- determiner(A, C), noun(C, B). verb_phrase(A, B) :- verb(A, C), noun_phrase(C, B). verb_phrase(A, B) :- verb(A, C), preposition(C, D), noun_phrase(D, B). determiner(A,B) :- A = [a|B]. adjective(A,B) :- A = [fruit| B]. noun(A,B) :- A = [flies|B]. noun(A,B) :-A = [banana|B]. noun(A,B) :-A= [fruit|B]. noun(A,B) :-A = [time|B]. noun(A,B) :-A = [arrow|B]. verb(A,B) :-A = [like|B]. verb(A,B) :-A = [flies|B]. preposition(A,B) :- A = [like|B]. This is the Prolog Code that the Grammar Translates to. The variables implement a kind of “stream processing”

Natural Language Processing Getting More From the Parsing Stage Other functions we might need – extract information about the parse, and ensure constraints are maintained in various parts of the sentence, eg - Return parse tree - Check consistency of gender - Checking consistency of number sentence(sentence( NP, VP)) --> noun_phrase(NP, No, Gender), verb_phrase(VP, No, Gender). -- build up parse tree as “self describing” term -- when a part of the sentence commits to number or gender, then record it for consistency

Natural Language Processing NLP (NLU) : Definite Clause Grammars Grammar with this Prolog-looking syntax sentence(s(subject(S),V,object(O))) --> noun(S), verb(V), noun(O). noun(noun(i)) --> [i]. noun(noun(sentence)) --> [sentences]. verb(verb(parse)) --> [parse]. Input this to the Prolog Interpreter gives a listing of: sentence(s(subject(S), V, object(O)), A, B) :- noun(S, A, C), verb(V, C, D), noun(O, D, B). noun(noun(i), A, B) :- A = [ i | B]. noun(noun(sentence), A, B) :- A = [sentences | B]. verb(verb(parse), A, B) :- A = [ parse | B ]. Try it out sentence(Tree, [i,parser,sentences],X). X = [], Tree = s(subject(noun(i)),verb(parser),object(noun(sentence))) ? yes

Natural Language Processing Parsing + Returning a Parse Tree /* syntax bit + No (-singular or plural) + Gender (-Masc, Fem or Inamin.)*/ s entence(sentence( NP, VP)) --> noun_phrase(NP, No, Gender), verb_phrase(VP, No, Gender). noun_phrase(noun_phrase([D,N]), No,Gender) --> d(D, No,Gender), n(N, No,Gender). verb_phrase(verb_phrase([V,N]), No,Gender) --> v(V, No,Gender), noun_phrase(N, _,_). /* no ref to no or gen of object*/ verb_phrase(verb_phrase([V]), No,Gender) --> v(V, No,Gender). d(determiner(the), No,Gender) --> [the]. d(determiner(a), singular,Gender) --> [a]. d(determiner(some), plural,Gender) --> [some]. d(determiner(all), plural,Gender) --> [all]. n(noun(apple), singular, inanimate) --> [apple]. n(noun(apples), plural, inanimate) --> [apples]. n(noun(man), singular, animate) --> [man]. n(noun(men), plural, animate) --> [men]. v(verb(eat), singular, animate) --> [eats]. v(verb(eats), plural, animate) --> [eat]. v(verb(sing), singular, animate) --> [sings]. v(verb(sings), plural, animate) --> [sing]. sentence(X,[the,man,eats,the,apples],Y). X = sentence( noun_phrase([determiner(the),noun(man)]), verb_phrase([verb(eat), noun_phrase([determiner(the),noun(apples)])])), Y = [] ?