SlideShare a Scribd company logo
1 of 41
Lecture 7: Definite Clause Grammars ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Context free grammars ,[object Object],[object Object],[object Object],[object Object]
Example of a CFG ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ingredients of a grammar  ,[object Object],[object Object],[object Object],s    np vp np    det n vp    v np vp    v det     the det     a n     man n     woman v     shoots
A little bit of linguistics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
More linguistics ,[object Object],[object Object]
Context free rules ,[object Object],[object Object],[object Object],[object Object],[object Object],s    np vp np    det n vp    v np vp    v det     the det     a n     man n     woman v     shoots
Grammar coverage ,[object Object],[object Object],[object Object]
Syntactic structure ,[object Object],[object Object],[object Object],[object Object],[object Object],s    np vp np    det n vp    v np vp    v det     the det     a n     man n     woman v     shoots
Parse trees ,[object Object],[object Object],[object Object],[object Object]
Grammatical strings ,[object Object],[object Object],[object Object],[object Object]
Generated language ,[object Object],[object Object],[object Object],[object Object]
Recogniser ,[object Object],[object Object]
Information about structure ,[object Object],[object Object],[object Object]
Parser  ,[object Object],[object Object],[object Object],[object Object],[object Object]
Context free language ,[object Object],[object Object],[object Object],[object Object],[object Object]
Theory vs. Practice ,[object Object],[object Object],[object Object],[object Object],[object Object]
CFG recognition in Prolog ,[object Object],[object Object],[object Object],[object Object]
CFG recognition using append/3 s (C):- np(A), vp(B), append(A,B,C). np (C):- det(A), n(B), append(A,B,C). vp (C):- v(A), np(B), append(A,B,C). vp (C):- v(C). det([the]).  det([a]).  n([man]).  n([woman]).  v([shoots]).
CFG recognition using append/3 ?- s ([the,woman,shoots,a,man]). yes ?- s (C):- np(A), vp(B), append(A,B,C). np (C):- det(A), n(B), append(A,B,C). vp (C):- v(A), np(B), append(A,B,C). vp (C):- v(C). det([the]).  det([a]).  n([man]).  n([woman]).  v([shoots]).
CFG recognition using append/3 ?- s (S). S = [the,man,shoots,the,man]; S = [the,man,shoots,the,woman]; S = [the,woman,shoots,a,man] … s (C):- np(A), vp(B), append(A,B,C). np (C):- det(A), n(B), append(A,B,C). vp (C):- v(A), np(B), append(A,B,C). vp (C):- v(C). det([the]).  det([a]).  n([man]).  n([woman]).  v([shoots]).
CFG recognition using append/3 ?- np ([the,woman]). yes ?-  np (X). X = [the,man]; X = [the,woman] s (C):- np(A), vp(B), append(A,B,C). np (C):- det(A), n(B), append(A,B,C). vp (C):- v(A), np(B), append(A,B,C). vp (C):- v(C). det([the]).  det([a]).  n([man]).  n([woman]).  v([shoots]).
Problems with this recogniser ,[object Object],[object Object],[object Object]
Difference lists ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
CFG recognition using difference lists s (A-C):- np(A-B), vp(B-C). np (A-C):- det(A-B), n(B-C).  vp (A-C):- v(A-B), np(B-C).  vp (A-C):- v(A-C). det([the|W]-W).  det([a|W]-W).  n([man|W]-W).  n([woman|W]-W).  v([shoots|W]-W).
CFG recognition using difference lists ?- s ([the,man,shoots,a,man]-[ ]). yes ?- s (A-C):- np(A-B), vp(B-C). np (A-C):- det(A-B), n(B-C).  vp (A-C):- v(A-B), np(B-C).  vp (A-C):- v(A-C). det([the|W]-W).  det([a|W]-W).  n([man|W]-W).  n([woman|W]-W).  v([shoots|W]-W).
CFG recognition using difference lists ?-  s (X-[ ]). S = [the,man,shoots,the,man]; S = [the,man,shoots,a,man]; … . s (A-C):- np(A-B), vp(B-C). np (A-C):- det(A-B), n(B-C).  vp (A-C):- v(A-B), np(B-C).  vp (A-C):- v(A-C). det([the|W]-W).  det([a|W]-W).  n([man|W]-W).  n([woman|W]-W).  v([shoots|W]-W).
Summary so far ,[object Object],[object Object],[object Object],[object Object]
Definite Clause Grammars ,[object Object],[object Object],[object Object]
DCGs: first example s  --> np, vp. np  --> det, n. vp  --> v, np. vp  --> v. det  --> [the].  det  --> [a]. n   --> [man].  n   --> [woman].  v   --> [shoots].
DCGs: first example ?- s ([a,man,shoots,a,woman],[ ]). yes ?- s  --> np, vp. np  --> det, n. vp  --> v, np. vp  --> v. det  --> [the].  det  --> [a]. n   --> [man].  n   --> [woman].  v   --> [shoots].
DCGs: first example ?-  s (X,[ ]). S = [the,man,shoots,the,man]; S = [the,man,shoots,a,man]; … . s  --> np, vp. np  --> det, n. vp  --> v, np. vp  --> v. det  --> [the].  det  --> [a]. n   --> [man].  n   --> [woman].  v   --> [shoots].
DCGs: second example ,[object Object],[object Object],[object Object],s --> s, conj, s.  s  --> np, vp. np  --> det, n.  vp  --> v, np.  vp  --> v. det  --> [the].  det  --> [a]. n   --> [man].  n   --> [woman].  v   --> [shoots]. conj --> [and].  conj --> [or].  conj --> [but].
DCG without left-recursive rules s --> simple _ s, conj, s.  s --> simple _ s. simple _ s  --> np, vp. np  --> det, n.  vp  --> v, np.  vp  --> v. det  --> [the].  det  --> [a]. n   --> [man].  n   --> [woman].  v   --> [shoots]. conj --> [and].  conj --> [or].  conj --> [but].
DCGs are not magic! ,[object Object],[object Object],[object Object]
DCGs: third example ,[object Object],[object Object],[object Object],[object Object],[object Object]
DCGs: third example s  --> []. s  --> l,s,r. l  --> [a]. r  --> [b]. ?-  s ([a,a,a,b,b,b],[ ]). yes ?-  s ([a,a,a,a,b,b,b],[ ]). no ,[object Object]
DCGs: third example s  --> []. s  --> l,s,r. l  --> [a]. r  --> [b]. ?- s(X,[ ]). X = [ ]; X = [a,b]; X = [a,a,b,b]; X = [a,a,a,b,b,b] … . ,[object Object]
Exercises ,[object Object],[object Object],[object Object]
Summary of this lecture  ,[object Object],[object Object],[object Object],[object Object]
Next lecture ,[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot (18)

Flat unit 3
Flat unit 3Flat unit 3
Flat unit 3
 
Final formal languages
Final formal languagesFinal formal languages
Final formal languages
 
Setswana Tokenisation and Computational Verb Morphology: Facing the Challenge...
Setswana Tokenisation and Computational Verb Morphology: Facing the Challenge...Setswana Tokenisation and Computational Verb Morphology: Facing the Challenge...
Setswana Tokenisation and Computational Verb Morphology: Facing the Challenge...
 
Unit i
Unit iUnit i
Unit i
 
Unit ii
Unit iiUnit ii
Unit ii
 
NLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological ParsingNLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological Parsing
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Formal language
Formal languageFormal language
Formal language
 
Class7
 Class7 Class7
Class7
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of Automata
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Unit v
Unit vUnit v
Unit v
 
Ldml - public
Ldml - publicLdml - public
Ldml - public
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of Language
 
Mba ebooks ! Edhole
Mba ebooks ! EdholeMba ebooks ! Edhole
Mba ebooks ! Edhole
 
Ldml presentation
Ldml presentationLdml presentation
Ldml presentation
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
 
Logic
LogicLogic
Logic
 

Similar to Lecture 7: Definite Clause Grammars

Stemming algorithms
Stemming algorithmsStemming algorithms
Stemming algorithms
Raghu nath
 
Segmenting dna sequence into words
Segmenting dna sequence into wordsSegmenting dna sequence into words
Segmenting dna sequence into words
Liang Wang
 
ACL読み会2014@PFI "Less Grammar, More Features"
ACL読み会2014@PFI "Less Grammar, More Features"ACL読み会2014@PFI "Less Grammar, More Features"
ACL読み会2014@PFI "Less Grammar, More Features"
nozyh
 
Definite Clause Grammars For Language Analysis
Definite Clause Grammars For Language AnalysisDefinite Clause Grammars For Language Analysis
Definite Clause Grammars For Language Analysis
RePierre
 
Natural Language Processing made easy
Natural Language Processing made easyNatural Language Processing made easy
Natural Language Processing made easy
Gopi Krishnan Nambiar
 

Similar to Lecture 7: Definite Clause Grammars (20)

PROLOG: Clauses Grammer In Prolog
PROLOG: Clauses Grammer In PrologPROLOG: Clauses Grammer In Prolog
PROLOG: Clauses Grammer In Prolog
 
PROLOG: Clauses Grammer In Prolog
PROLOG: Clauses Grammer In PrologPROLOG: Clauses Grammer In Prolog
PROLOG: Clauses Grammer In Prolog
 
natural language processing
natural language processing natural language processing
natural language processing
 
ToC_M1L3_Grammar and Derivation.pdf
ToC_M1L3_Grammar and Derivation.pdfToC_M1L3_Grammar and Derivation.pdf
ToC_M1L3_Grammar and Derivation.pdf
 
Inteligencia artificial
Inteligencia artificialInteligencia artificial
Inteligencia artificial
 
Natural Language processing Parts of speech tagging, its classes, and how to ...
Natural Language processing Parts of speech tagging, its classes, and how to ...Natural Language processing Parts of speech tagging, its classes, and how to ...
Natural Language processing Parts of speech tagging, its classes, and how to ...
 
NLP-my-lecture (3).ppt
NLP-my-lecture (3).pptNLP-my-lecture (3).ppt
NLP-my-lecture (3).ppt
 
Natural Language parsing.pptx
Natural Language parsing.pptxNatural Language parsing.pptx
Natural Language parsing.pptx
 
Stemming algorithms
Stemming algorithmsStemming algorithms
Stemming algorithms
 
Grammar Syntax(1).pptx
Grammar Syntax(1).pptxGrammar Syntax(1).pptx
Grammar Syntax(1).pptx
 
Segmenting dna sequence into words
Segmenting dna sequence into wordsSegmenting dna sequence into words
Segmenting dna sequence into words
 
sentence patterns
sentence patternssentence patterns
sentence patterns
 
NLP
NLPNLP
NLP
 
NLP
NLPNLP
NLP
 
Computational model language and grammar bnf
Computational model language and grammar bnfComputational model language and grammar bnf
Computational model language and grammar bnf
 
ACL読み会2014@PFI "Less Grammar, More Features"
ACL読み会2014@PFI "Less Grammar, More Features"ACL読み会2014@PFI "Less Grammar, More Features"
ACL読み会2014@PFI "Less Grammar, More Features"
 
crypto_graphy_PPTs.pdf
crypto_graphy_PPTs.pdfcrypto_graphy_PPTs.pdf
crypto_graphy_PPTs.pdf
 
Definite Clause Grammars For Language Analysis
Definite Clause Grammars For Language AnalysisDefinite Clause Grammars For Language Analysis
Definite Clause Grammars For Language Analysis
 
INFO-2950-Languages-and-Grammars.ppt
INFO-2950-Languages-and-Grammars.pptINFO-2950-Languages-and-Grammars.ppt
INFO-2950-Languages-and-Grammars.ppt
 
Natural Language Processing made easy
Natural Language Processing made easyNatural Language Processing made easy
Natural Language Processing made easy
 

More from CS, NcState

Lexisnexis june9
Lexisnexis june9Lexisnexis june9
Lexisnexis june9
CS, NcState
 
Ai4se lab template
Ai4se lab templateAi4se lab template
Ai4se lab template
CS, NcState
 
Automated Software Enging, Fall 2015, NCSU
Automated Software Enging, Fall 2015, NCSUAutomated Software Enging, Fall 2015, NCSU
Automated Software Enging, Fall 2015, NCSU
CS, NcState
 
Dagstuhl14 intro-v1
Dagstuhl14 intro-v1Dagstuhl14 intro-v1
Dagstuhl14 intro-v1
CS, NcState
 

More from CS, NcState (20)

Talks2015 novdec
Talks2015 novdecTalks2015 novdec
Talks2015 novdec
 
Future se oct15
Future se oct15Future se oct15
Future se oct15
 
GALE: Geometric active learning for Search-Based Software Engineering
GALE: Geometric active learning for Search-Based Software EngineeringGALE: Geometric active learning for Search-Based Software Engineering
GALE: Geometric active learning for Search-Based Software Engineering
 
Big Data: the weakest link
Big Data: the weakest linkBig Data: the weakest link
Big Data: the weakest link
 
Three Laws of Trusted Data Sharing: (Building a Better Business Case for Dat...
Three Laws of Trusted Data Sharing:(Building a Better Business Case for Dat...Three Laws of Trusted Data Sharing:(Building a Better Business Case for Dat...
Three Laws of Trusted Data Sharing: (Building a Better Business Case for Dat...
 
Lexisnexis june9
Lexisnexis june9Lexisnexis june9
Lexisnexis june9
 
Welcome to ICSE NIER’15 (new ideas and emerging results).
Welcome to ICSE NIER’15 (new ideas and emerging results).Welcome to ICSE NIER’15 (new ideas and emerging results).
Welcome to ICSE NIER’15 (new ideas and emerging results).
 
Icse15 Tech-briefing Data Science
Icse15 Tech-briefing Data ScienceIcse15 Tech-briefing Data Science
Icse15 Tech-briefing Data Science
 
Kits to Find the Bits that Fits
Kits to Find  the Bits that Fits Kits to Find  the Bits that Fits
Kits to Find the Bits that Fits
 
Ai4se lab template
Ai4se lab templateAi4se lab template
Ai4se lab template
 
Automated Software Enging, Fall 2015, NCSU
Automated Software Enging, Fall 2015, NCSUAutomated Software Enging, Fall 2015, NCSU
Automated Software Enging, Fall 2015, NCSU
 
Requirements Engineering
Requirements EngineeringRequirements Engineering
Requirements Engineering
 
172529main ken and_tim_software_assurance_research_at_west_virginia
172529main ken and_tim_software_assurance_research_at_west_virginia172529main ken and_tim_software_assurance_research_at_west_virginia
172529main ken and_tim_software_assurance_research_at_west_virginia
 
Automated Software Engineering
Automated Software EngineeringAutomated Software Engineering
Automated Software Engineering
 
Next Generation “Treatment Learning” (finding the diamonds in the dust)
Next Generation “Treatment Learning” (finding the diamonds in the dust)Next Generation “Treatment Learning” (finding the diamonds in the dust)
Next Generation “Treatment Learning” (finding the diamonds in the dust)
 
Tim Menzies, directions in Data Science
Tim Menzies, directions in Data ScienceTim Menzies, directions in Data Science
Tim Menzies, directions in Data Science
 
Goldrush
GoldrushGoldrush
Goldrush
 
Dagstuhl14 intro-v1
Dagstuhl14 intro-v1Dagstuhl14 intro-v1
Dagstuhl14 intro-v1
 
Know thy tools
Know thy toolsKnow thy tools
Know thy tools
 
The Art and Science of Analyzing Software Data
The Art and Science of Analyzing Software DataThe Art and Science of Analyzing Software Data
The Art and Science of Analyzing Software Data
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

Lecture 7: Definite Clause Grammars

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19. CFG recognition using append/3 s (C):- np(A), vp(B), append(A,B,C). np (C):- det(A), n(B), append(A,B,C). vp (C):- v(A), np(B), append(A,B,C). vp (C):- v(C). det([the]). det([a]). n([man]). n([woman]). v([shoots]).
  • 20. CFG recognition using append/3 ?- s ([the,woman,shoots,a,man]). yes ?- s (C):- np(A), vp(B), append(A,B,C). np (C):- det(A), n(B), append(A,B,C). vp (C):- v(A), np(B), append(A,B,C). vp (C):- v(C). det([the]). det([a]). n([man]). n([woman]). v([shoots]).
  • 21. CFG recognition using append/3 ?- s (S). S = [the,man,shoots,the,man]; S = [the,man,shoots,the,woman]; S = [the,woman,shoots,a,man] … s (C):- np(A), vp(B), append(A,B,C). np (C):- det(A), n(B), append(A,B,C). vp (C):- v(A), np(B), append(A,B,C). vp (C):- v(C). det([the]). det([a]). n([man]). n([woman]). v([shoots]).
  • 22. CFG recognition using append/3 ?- np ([the,woman]). yes ?- np (X). X = [the,man]; X = [the,woman] s (C):- np(A), vp(B), append(A,B,C). np (C):- det(A), n(B), append(A,B,C). vp (C):- v(A), np(B), append(A,B,C). vp (C):- v(C). det([the]). det([a]). n([man]). n([woman]). v([shoots]).
  • 23.
  • 24.
  • 25. CFG recognition using difference lists s (A-C):- np(A-B), vp(B-C). np (A-C):- det(A-B), n(B-C). vp (A-C):- v(A-B), np(B-C). vp (A-C):- v(A-C). det([the|W]-W). det([a|W]-W). n([man|W]-W). n([woman|W]-W). v([shoots|W]-W).
  • 26. CFG recognition using difference lists ?- s ([the,man,shoots,a,man]-[ ]). yes ?- s (A-C):- np(A-B), vp(B-C). np (A-C):- det(A-B), n(B-C). vp (A-C):- v(A-B), np(B-C). vp (A-C):- v(A-C). det([the|W]-W). det([a|W]-W). n([man|W]-W). n([woman|W]-W). v([shoots|W]-W).
  • 27. CFG recognition using difference lists ?- s (X-[ ]). S = [the,man,shoots,the,man]; S = [the,man,shoots,a,man]; … . s (A-C):- np(A-B), vp(B-C). np (A-C):- det(A-B), n(B-C). vp (A-C):- v(A-B), np(B-C). vp (A-C):- v(A-C). det([the|W]-W). det([a|W]-W). n([man|W]-W). n([woman|W]-W). v([shoots|W]-W).
  • 28.
  • 29.
  • 30. DCGs: first example s --> np, vp. np --> det, n. vp --> v, np. vp --> v. det --> [the]. det --> [a]. n --> [man]. n --> [woman]. v --> [shoots].
  • 31. DCGs: first example ?- s ([a,man,shoots,a,woman],[ ]). yes ?- s --> np, vp. np --> det, n. vp --> v, np. vp --> v. det --> [the]. det --> [a]. n --> [man]. n --> [woman]. v --> [shoots].
  • 32. DCGs: first example ?- s (X,[ ]). S = [the,man,shoots,the,man]; S = [the,man,shoots,a,man]; … . s --> np, vp. np --> det, n. vp --> v, np. vp --> v. det --> [the]. det --> [a]. n --> [man]. n --> [woman]. v --> [shoots].
  • 33.
  • 34. DCG without left-recursive rules s --> simple _ s, conj, s. s --> simple _ s. simple _ s --> np, vp. np --> det, n. vp --> v, np. vp --> v. det --> [the]. det --> [a]. n --> [man]. n --> [woman]. v --> [shoots]. conj --> [and]. conj --> [or]. conj --> [but].
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.