SlideShare a Scribd company logo
1 of 15
Clause Grammars in Prolog
OVERVIEW Context free grammars CFG recognition using append CFG recognition using difference lists Definite clause grammars Adding Recursive Rules A DCG for a simple formal language
Context Free Grammars Definite Clauses Grammars(DCGs) are a special notation for defining grammars. context free grammar are a finite collection of rules which tell us that certain sentences are grammatical (that is, syntactically correct) and what their grammatical structure actually is.
CFG Consider the following examples: s -> np vp np -> det n vp -> v np vp -> v det -> a det -> the n -> woman n -> man v -> shoots ,[object Object]
The symbols: a, the, woman, man, and shootsare called terminal symbolsA context free rule consists of a single non-terminal symbol, followed by ->, followed by a finite sequence made up of terminal and/or nonterminal symbols.
CFG recognition using append we can simply `turn the grammar into Prolog'. Ex: the string a woman shoots a man will be represented by the list [a,woman,shoots,a,man]. the rule s -> np vp can be thought of as saying: a list of words is an s list if it is the result of concatenating an np list with a vp list. We can make use of append to turn these kinds of rules into Prolog. s(Z) :- np(X), vp(Y), append(X,Y,Z). np(Z) :- det(X), n(Y), append(X,Y,Z). vp(Z) :- v(X), np(Y), append(X,Y,Z). vp(Z) :- v(Z). v([shoots]).
det([the]). det([a]). n([woman]). n([man]). So, on posing the query s([a,woman,shoots,a,man]). ,[object Object],In fact, our little grammar generates 20 sentences. Here are the first five: s(X). X = [the,woman,shoots,the,woman] ; X = [the,woman,shoots,the,man] ; X = [the,woman,shoots,a,woman] ; X = [the,woman,shoots,a,man] ; X = [the,woman,shoots]
CFG recognition using difference lists A more efficient implementation can be obtained by making use of difference lists. The key idea underlying difference lists is to represent the information about grammatical categories not as a single list, but as the difference between two lists.  For example, instead of representing a woman shoots a man as [a,woman,shoots,a,man] we might represent it as the pair of lists [a,woman,shoots,a,man] []. represents the sentence a woman shoots a man because it says: If I consume all the symbols on the left, and leave behind the symbols on the right, I have the sentence I am interested in. That is: the sentence we are interested in is the difference between the contents of these two lists.
Definite clause grammars DCGs, quite simply is a nice notation for writing grammars that hides the underlying difference list variables. Ex: The previous grammar written as a DCG: s --> np,vp. np --> det,n. vp --> v,np. vp --> v. det --> [the]. det --> [a]. n --> [woman]. n --> [man]. v --> [shoots].
Definite clause grammars To find out whether a woman shoots a man is a sentence, we pose the query: s([a,woman,shoots,a,man],[]). That is, just as in the difference list recognizer, we ask whether we can get an s by consuming the symbols in [a,woman,shoots,a,man], leaving nothing behind. Similarly, to generate all the sentences in the grammar, we pose the query: s(X,[]).
Adding Recursive Rules Our original context free grammar generated only 20 sentences. However it is easy to write context free grammars that generate infinitely many sentences:  we need simply use recursive rules. EX: Let's add the following rules to our grammar: s -> s conj s conj -> and conj -> or conj -> but This rule allows us to join as many sentences together as we like using the words and, but and or.
Adding Recursive Rules Turning this grammar into DCG rules.  s --> s,conj,s. conj --> [and]. conj --> [or]. conj --> [but]. First, let's add the rules at the beginning of the knowledge base before the rule s --> np,vp. If now, we pose the query s([a,woman,shoots],[])?  Prolog gets into an infinite loop.
So, by just reordering clauses or goals, we won't solve the problem.  The only possible solution is to introduce a new nonterminal symbol. We could for example use the category simple_s for sentences without embedded sentences.  Our grammar would then look like this: s --> simple_s. s --> simple_s conj s. simple_s --> np,vp. np --> det,n. vp --> v,np. vp --> v. det --> [the]. det --> [a]. n --> [woman]. n --> [man]. v --> [shoots]. conj --> [and]. conj --> [or]. conj --> [but].
A DCG for a simple formal language we shall define a DCG for the formal language a^nb^n. There are only two `words' in this language: The symbol a and the symbol b. The language consist of all strings made up from these two symbols that have the following form: the string must consist of an unbroken block of as of length n, followed by an unbroken block of bs of length n, and nothing else.  So the strings ab, aabb, aaabbb and aaaabbbb all belong to a^nb^n.
CFG to generate this language: s -> epsilon s -> l s r l -> a r -> b Turning this grammar into DCG. s --> []. s --> l,s,r. l --> [a]. r --> [b]. And this DCG works exactly as we would hope. For example, to the query s([a,a,a,b,b,b],[]). we get the answer `yes',

More Related Content

What's hot

Spread spectrum technologies
Spread spectrum technologiesSpread spectrum technologies
Spread spectrum technologiesDr. Ghanshyam Singh
 
Beam forming- New Technology
Beam forming- New TechnologyBeam forming- New Technology
Beam forming- New TechnologyPARNIKA GUPTA
 
Wave guide tees
Wave guide teesWave guide tees
Wave guide teesKeval Patel
 
SEQUENTIAL LOGIC CIRCUITS (FLIP FLOPS AND LATCHES)
SEQUENTIAL LOGIC CIRCUITS (FLIP FLOPS AND LATCHES)SEQUENTIAL LOGIC CIRCUITS (FLIP FLOPS AND LATCHES)
SEQUENTIAL LOGIC CIRCUITS (FLIP FLOPS AND LATCHES)Sairam Adithya
 
Channel coding
Channel codingChannel coding
Channel codingPiyush Mittal
 
Mw lecture 3
Mw lecture 3Mw lecture 3
Mw lecture 3Sadaf Ayesha
 
Channel estimation - F. Ling
Channel estimation - F. LingChannel estimation - F. Ling
Channel estimation - F. LingFuyun Ling
 
Noise and interference
Noise and interferenceNoise and interference
Noise and interferenceRohit vijay
 
Matched filter
Matched filterMatched filter
Matched filtersrkrishna341
 
Even odd parity
Even odd parityEven odd parity
Even odd parityOscar Alegria
 
Digital Communication 4
Digital Communication 4Digital Communication 4
Digital Communication 4admercano101
 
Sequential circuits in Digital Electronics
Sequential circuits in Digital ElectronicsSequential circuits in Digital Electronics
Sequential circuits in Digital ElectronicsVinoth Loganathan
 
HANDOFF
HANDOFFHANDOFF
HANDOFFAJAL A J
 
Equalisation, diversity, coding.
Equalisation, diversity, coding.Equalisation, diversity, coding.
Equalisation, diversity, coding.Vrince Vimal
 
Generation of AM-DSB-SC using Balanced FET Modulator.pptx
Generation of AM-DSB-SC using Balanced FET Modulator.pptxGeneration of AM-DSB-SC using Balanced FET Modulator.pptx
Generation of AM-DSB-SC using Balanced FET Modulator.pptxArunChokkalingam
 
microwave-engineering
microwave-engineeringmicrowave-engineering
microwave-engineeringATTO RATHORE
 
Comparative Study and Performance Analysis of different Modulation Techniques...
Comparative Study and Performance Analysis of different Modulation Techniques...Comparative Study and Performance Analysis of different Modulation Techniques...
Comparative Study and Performance Analysis of different Modulation Techniques...Souvik Das
 

What's hot (20)

Final ppt
Final pptFinal ppt
Final ppt
 
Spread spectrum technologies
Spread spectrum technologiesSpread spectrum technologies
Spread spectrum technologies
 
Beam forming- New Technology
Beam forming- New TechnologyBeam forming- New Technology
Beam forming- New Technology
 
Receivers
ReceiversReceivers
Receivers
 
Wave guide tees
Wave guide teesWave guide tees
Wave guide tees
 
SEQUENTIAL LOGIC CIRCUITS (FLIP FLOPS AND LATCHES)
SEQUENTIAL LOGIC CIRCUITS (FLIP FLOPS AND LATCHES)SEQUENTIAL LOGIC CIRCUITS (FLIP FLOPS AND LATCHES)
SEQUENTIAL LOGIC CIRCUITS (FLIP FLOPS AND LATCHES)
 
Channel coding
Channel codingChannel coding
Channel coding
 
Mw lecture 3
Mw lecture 3Mw lecture 3
Mw lecture 3
 
Channel estimation - F. Ling
Channel estimation - F. LingChannel estimation - F. Ling
Channel estimation - F. Ling
 
Noise and interference
Noise and interferenceNoise and interference
Noise and interference
 
Matched filter
Matched filterMatched filter
Matched filter
 
Even odd parity
Even odd parityEven odd parity
Even odd parity
 
Impedance in transmission line
Impedance in transmission lineImpedance in transmission line
Impedance in transmission line
 
Digital Communication 4
Digital Communication 4Digital Communication 4
Digital Communication 4
 
Sequential circuits in Digital Electronics
Sequential circuits in Digital ElectronicsSequential circuits in Digital Electronics
Sequential circuits in Digital Electronics
 
HANDOFF
HANDOFFHANDOFF
HANDOFF
 
Equalisation, diversity, coding.
Equalisation, diversity, coding.Equalisation, diversity, coding.
Equalisation, diversity, coding.
 
Generation of AM-DSB-SC using Balanced FET Modulator.pptx
Generation of AM-DSB-SC using Balanced FET Modulator.pptxGeneration of AM-DSB-SC using Balanced FET Modulator.pptx
Generation of AM-DSB-SC using Balanced FET Modulator.pptx
 
microwave-engineering
microwave-engineeringmicrowave-engineering
microwave-engineering
 
Comparative Study and Performance Analysis of different Modulation Techniques...
Comparative Study and Performance Analysis of different Modulation Techniques...Comparative Study and Performance Analysis of different Modulation Techniques...
Comparative Study and Performance Analysis of different Modulation Techniques...
 

Viewers also liked

Seminar on Language Teaching : THE USE OF TOTAL PHYSICAL RESPONSE STORYTELLIN...
Seminar on Language Teaching : THE USE OF TOTAL PHYSICAL RESPONSE STORYTELLIN...Seminar on Language Teaching : THE USE OF TOTAL PHYSICAL RESPONSE STORYTELLIN...
Seminar on Language Teaching : THE USE OF TOTAL PHYSICAL RESPONSE STORYTELLIN...Yulia Eolia
 
Total Physical Response (TPR) Method
Total Physical Response (TPR) MethodTotal Physical Response (TPR) Method
Total Physical Response (TPR) MethodCesar Augusto
 
Eugene SRTS Program
Eugene SRTS ProgramEugene SRTS Program
Eugene SRTS ProgramEugene SRTS
 
Matlab: Saving And Publishing
Matlab: Saving And PublishingMatlab: Saving And Publishing
Matlab: Saving And PublishingDataminingTools Inc
 
WEKA: Credibility Evaluating Whats Been Learned
WEKA: Credibility Evaluating Whats Been LearnedWEKA: Credibility Evaluating Whats Been Learned
WEKA: Credibility Evaluating Whats Been LearnedDataminingTools Inc
 
LISP: Scope and extent in lisp
LISP: Scope and extent in lispLISP: Scope and extent in lisp
LISP: Scope and extent in lispDataminingTools Inc
 
RapidMiner: Nested Subprocesses
RapidMiner:   Nested SubprocessesRapidMiner:   Nested Subprocesses
RapidMiner: Nested SubprocessesDataminingTools Inc
 
Excel Datamining Addin Intermediate
Excel Datamining Addin IntermediateExcel Datamining Addin Intermediate
Excel Datamining Addin IntermediateDataminingTools Inc
 
MS Sql Server: Manipulating Database
MS Sql Server: Manipulating DatabaseMS Sql Server: Manipulating Database
MS Sql Server: Manipulating DatabaseDataminingTools Inc
 
Ireland Apo University Fy 10 Tibbs Slideshare
Ireland Apo University Fy 10 Tibbs SlideshareIreland Apo University Fy 10 Tibbs Slideshare
Ireland Apo University Fy 10 Tibbs SlideshareTibbs Pereira
 
Txomin Hartz Txikia
Txomin Hartz TxikiaTxomin Hartz Txikia
Txomin Hartz Txikiairantzugoitia86
 
Oratoria E RetĂłRica Latinas
Oratoria E RetĂłRica LatinasOratoria E RetĂłRica Latinas
Oratoria E RetĂłRica Latinaslara
 

Viewers also liked (20)

Seminar on Language Teaching : THE USE OF TOTAL PHYSICAL RESPONSE STORYTELLIN...
Seminar on Language Teaching : THE USE OF TOTAL PHYSICAL RESPONSE STORYTELLIN...Seminar on Language Teaching : THE USE OF TOTAL PHYSICAL RESPONSE STORYTELLIN...
Seminar on Language Teaching : THE USE OF TOTAL PHYSICAL RESPONSE STORYTELLIN...
 
Total Physical Response (TPR) Method
Total Physical Response (TPR) MethodTotal Physical Response (TPR) Method
Total Physical Response (TPR) Method
 
Eugene SRTS Program
Eugene SRTS ProgramEugene SRTS Program
Eugene SRTS Program
 
Matlab: Saving And Publishing
Matlab: Saving And PublishingMatlab: Saving And Publishing
Matlab: Saving And Publishing
 
WEKA: Credibility Evaluating Whats Been Learned
WEKA: Credibility Evaluating Whats Been LearnedWEKA: Credibility Evaluating Whats Been Learned
WEKA: Credibility Evaluating Whats Been Learned
 
Data Mining The Sky
Data Mining The SkyData Mining The Sky
Data Mining The Sky
 
LISP: Errors In Lisp
LISP: Errors In LispLISP: Errors In Lisp
LISP: Errors In Lisp
 
InfoChimps.Org
InfoChimps.OrgInfoChimps.Org
InfoChimps.Org
 
Welcome
WelcomeWelcome
Welcome
 
LISP: Scope and extent in lisp
LISP: Scope and extent in lispLISP: Scope and extent in lisp
LISP: Scope and extent in lisp
 
SPSS: Data Editor
SPSS: Data EditorSPSS: Data Editor
SPSS: Data Editor
 
RapidMiner: Nested Subprocesses
RapidMiner:   Nested SubprocessesRapidMiner:   Nested Subprocesses
RapidMiner: Nested Subprocesses
 
Excel Datamining Addin Intermediate
Excel Datamining Addin IntermediateExcel Datamining Addin Intermediate
Excel Datamining Addin Intermediate
 
MS Sql Server: Manipulating Database
MS Sql Server: Manipulating DatabaseMS Sql Server: Manipulating Database
MS Sql Server: Manipulating Database
 
Ireland Apo University Fy 10 Tibbs Slideshare
Ireland Apo University Fy 10 Tibbs SlideshareIreland Apo University Fy 10 Tibbs Slideshare
Ireland Apo University Fy 10 Tibbs Slideshare
 
Txomin Hartz Txikia
Txomin Hartz TxikiaTxomin Hartz Txikia
Txomin Hartz Txikia
 
Oratoria E RetĂłRica Latinas
Oratoria E RetĂłRica LatinasOratoria E RetĂłRica Latinas
Oratoria E RetĂłRica Latinas
 
Quick Look At Clustering
Quick Look At ClusteringQuick Look At Clustering
Quick Look At Clustering
 
Graph Plots in Matlab
Graph Plots in MatlabGraph Plots in Matlab
Graph Plots in Matlab
 
R: Apply Functions
R: Apply FunctionsR: Apply Functions
R: Apply Functions
 

Similar to PROLOG: Clauses Grammer In Prolog

Lecture 7: Definite Clause Grammars
Lecture 7: Definite Clause GrammarsLecture 7: Definite Clause Grammars
Lecture 7: Definite Clause GrammarsCS, NcState
 
ToC_M1L3_Grammar and Derivation.pdf
ToC_M1L3_Grammar and Derivation.pdfToC_M1L3_Grammar and Derivation.pdf
ToC_M1L3_Grammar and Derivation.pdfjaishreemane73
 
Mikhail Khristophorov "Introduction to Regular Expressions"
Mikhail Khristophorov "Introduction to Regular Expressions"Mikhail Khristophorov "Introduction to Regular Expressions"
Mikhail Khristophorov "Introduction to Regular Expressions"LogeekNightUkraine
 
Pl vol1
Pl vol1Pl vol1
Pl vol1Aarsh Ps
 
natural language processing
natural language processing natural language processing
natural language processing sunanthakrishnan
 
Pl vol1
Pl vol1Pl vol1
Pl vol1Aarsh Ps
 
Inteligencia artificial
Inteligencia artificialInteligencia artificial
Inteligencia artificialroxana24conamor
 
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...Philip Schwarz
 
Computational model language and grammar bnf
Computational model language and grammar bnfComputational model language and grammar bnf
Computational model language and grammar bnfTaha Shakeel
 
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdfFUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdfBryan Alejos
 
Regular expression
Regular expressionRegular expression
Regular expressionRajon
 
INFO-2950-Languages-and-Grammars.ppt
INFO-2950-Languages-and-Grammars.pptINFO-2950-Languages-and-Grammars.ppt
INFO-2950-Languages-and-Grammars.pptLamhotNaibaho3
 
String interpolation
String interpolationString interpolation
String interpolationKnoldus Inc.
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsEelco Visser
 
Regular Expressions and You
Regular Expressions and YouRegular Expressions and You
Regular Expressions and YouJames Armes
 
Ldml presentation
Ldml presentationLdml presentation
Ldml presentationSean Con
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular ExpressionsSatya Narayana
 
Python - Regular Expressions
Python - Regular ExpressionsPython - Regular Expressions
Python - Regular ExpressionsMukesh Tekwani
 

Similar to PROLOG: Clauses Grammer In Prolog (20)

Lecture 7: Definite Clause Grammars
Lecture 7: Definite Clause GrammarsLecture 7: Definite Clause Grammars
Lecture 7: Definite Clause Grammars
 
ToC_M1L3_Grammar and Derivation.pdf
ToC_M1L3_Grammar and Derivation.pdfToC_M1L3_Grammar and Derivation.pdf
ToC_M1L3_Grammar and Derivation.pdf
 
Mikhail Khristophorov "Introduction to Regular Expressions"
Mikhail Khristophorov "Introduction to Regular Expressions"Mikhail Khristophorov "Introduction to Regular Expressions"
Mikhail Khristophorov "Introduction to Regular Expressions"
 
Pl vol1
Pl vol1Pl vol1
Pl vol1
 
natural language processing
natural language processing natural language processing
natural language processing
 
Pl vol1
Pl vol1Pl vol1
Pl vol1
 
Inteligencia artificial
Inteligencia artificialInteligencia artificial
Inteligencia artificial
 
Lda2vec text by the bay 2016 with notes
Lda2vec text by the bay 2016 with notesLda2vec text by the bay 2016 with notes
Lda2vec text by the bay 2016 with notes
 
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
 
Computational model language and grammar bnf
Computational model language and grammar bnfComputational model language and grammar bnf
Computational model language and grammar bnf
 
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdfFUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
 
Regular expression
Regular expressionRegular expression
Regular expression
 
INFO-2950-Languages-and-Grammars.ppt
INFO-2950-Languages-and-Grammars.pptINFO-2950-Languages-and-Grammars.ppt
INFO-2950-Languages-and-Grammars.ppt
 
String interpolation
String interpolationString interpolation
String interpolation
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type Constraints
 
Regular Expressions and You
Regular Expressions and YouRegular Expressions and You
Regular Expressions and You
 
Ldml presentation
Ldml presentationLdml presentation
Ldml presentation
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
NLP-my-lecture (3).ppt
NLP-my-lecture (3).pptNLP-my-lecture (3).ppt
NLP-my-lecture (3).ppt
 
Python - Regular Expressions
Python - Regular ExpressionsPython - Regular Expressions
Python - Regular Expressions
 

More from DataminingTools Inc

Terminology Machine Learning
Terminology Machine LearningTerminology Machine Learning
Terminology Machine LearningDataminingTools Inc
 
Techniques Machine Learning
Techniques Machine LearningTechniques Machine Learning
Techniques Machine LearningDataminingTools Inc
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning IntroductionDataminingTools Inc
 
AI: Introduction to artificial intelligence
AI: Introduction to artificial intelligenceAI: Introduction to artificial intelligence
AI: Introduction to artificial intelligenceDataminingTools Inc
 
Data Mining: Text and web mining
Data Mining: Text and web miningData Mining: Text and web mining
Data Mining: Text and web miningDataminingTools Inc
 
Data Mining: Outlier analysis
Data Mining: Outlier analysisData Mining: Outlier analysis
Data Mining: Outlier analysisDataminingTools Inc
 
Data Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence dataData Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence dataDataminingTools Inc
 
Data Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlationsData Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlationsDataminingTools Inc
 
Data Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysisData Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysisDataminingTools Inc
 
Data warehouse and olap technology
Data warehouse and olap technologyData warehouse and olap technology
Data warehouse and olap technologyDataminingTools Inc
 
Data Mining: Data processing
Data Mining: Data processingData Mining: Data processing
Data Mining: Data processingDataminingTools Inc
 

More from DataminingTools Inc (20)

Terminology Machine Learning
Terminology Machine LearningTerminology Machine Learning
Terminology Machine Learning
 
Techniques Machine Learning
Techniques Machine LearningTechniques Machine Learning
Techniques Machine Learning
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
 
Areas of machine leanring
Areas of machine leanringAreas of machine leanring
Areas of machine leanring
 
AI: Planning and AI
AI: Planning and AIAI: Planning and AI
AI: Planning and AI
 
AI: Logic in AI 2
AI: Logic in AI 2AI: Logic in AI 2
AI: Logic in AI 2
 
AI: Logic in AI
AI: Logic in AIAI: Logic in AI
AI: Logic in AI
 
AI: Learning in AI 2
AI: Learning in AI 2AI: Learning in AI 2
AI: Learning in AI 2
 
AI: Learning in AI
AI: Learning in AI AI: Learning in AI
AI: Learning in AI
 
AI: Introduction to artificial intelligence
AI: Introduction to artificial intelligenceAI: Introduction to artificial intelligence
AI: Introduction to artificial intelligence
 
AI: Belief Networks
AI: Belief NetworksAI: Belief Networks
AI: Belief Networks
 
AI: AI & Searching
AI: AI & SearchingAI: AI & Searching
AI: AI & Searching
 
AI: AI & Problem Solving
AI: AI & Problem SolvingAI: AI & Problem Solving
AI: AI & Problem Solving
 
Data Mining: Text and web mining
Data Mining: Text and web miningData Mining: Text and web mining
Data Mining: Text and web mining
 
Data Mining: Outlier analysis
Data Mining: Outlier analysisData Mining: Outlier analysis
Data Mining: Outlier analysis
 
Data Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence dataData Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence data
 
Data Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlationsData Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlations
 
Data Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysisData Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysis
 
Data warehouse and olap technology
Data warehouse and olap technologyData warehouse and olap technology
Data warehouse and olap technology
 
Data Mining: Data processing
Data Mining: Data processingData Mining: Data processing
Data Mining: Data processing
 

Recently uploaded

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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 Takeoffsammart93
 
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 DevelopmentsTrustArc
 
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 RobisonAnna Loughnan Colquhoun
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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 - 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
 

PROLOG: Clauses Grammer In Prolog

  • 2. OVERVIEW Context free grammars CFG recognition using append CFG recognition using difference lists Definite clause grammars Adding Recursive Rules A DCG for a simple formal language
  • 3. Context Free Grammars Definite Clauses Grammars(DCGs) are a special notation for defining grammars. context free grammar are a finite collection of rules which tell us that certain sentences are grammatical (that is, syntactically correct) and what their grammatical structure actually is.
  • 4.
  • 5. The symbols: a, the, woman, man, and shootsare called terminal symbolsA context free rule consists of a single non-terminal symbol, followed by ->, followed by a finite sequence made up of terminal and/or nonterminal symbols.
  • 6. CFG recognition using append we can simply `turn the grammar into Prolog'. Ex: the string a woman shoots a man will be represented by the list [a,woman,shoots,a,man]. the rule s -> np vp can be thought of as saying: a list of words is an s list if it is the result of concatenating an np list with a vp list. We can make use of append to turn these kinds of rules into Prolog. s(Z) :- np(X), vp(Y), append(X,Y,Z). np(Z) :- det(X), n(Y), append(X,Y,Z). vp(Z) :- v(X), np(Y), append(X,Y,Z). vp(Z) :- v(Z). v([shoots]).
  • 7.
  • 8. CFG recognition using difference lists A more efficient implementation can be obtained by making use of difference lists. The key idea underlying difference lists is to represent the information about grammatical categories not as a single list, but as the difference between two lists. For example, instead of representing a woman shoots a man as [a,woman,shoots,a,man] we might represent it as the pair of lists [a,woman,shoots,a,man] []. represents the sentence a woman shoots a man because it says: If I consume all the symbols on the left, and leave behind the symbols on the right, I have the sentence I am interested in. That is: the sentence we are interested in is the difference between the contents of these two lists.
  • 9. Definite clause grammars DCGs, quite simply is a nice notation for writing grammars that hides the underlying difference list variables. Ex: The previous grammar written as a DCG: s --> np,vp. np --> det,n. vp --> v,np. vp --> v. det --> [the]. det --> [a]. n --> [woman]. n --> [man]. v --> [shoots].
  • 10. Definite clause grammars To find out whether a woman shoots a man is a sentence, we pose the query: s([a,woman,shoots,a,man],[]). That is, just as in the difference list recognizer, we ask whether we can get an s by consuming the symbols in [a,woman,shoots,a,man], leaving nothing behind. Similarly, to generate all the sentences in the grammar, we pose the query: s(X,[]).
  • 11. Adding Recursive Rules Our original context free grammar generated only 20 sentences. However it is easy to write context free grammars that generate infinitely many sentences: we need simply use recursive rules. EX: Let's add the following rules to our grammar: s -> s conj s conj -> and conj -> or conj -> but This rule allows us to join as many sentences together as we like using the words and, but and or.
  • 12. Adding Recursive Rules Turning this grammar into DCG rules. s --> s,conj,s. conj --> [and]. conj --> [or]. conj --> [but]. First, let's add the rules at the beginning of the knowledge base before the rule s --> np,vp. If now, we pose the query s([a,woman,shoots],[])? Prolog gets into an infinite loop.
  • 13. So, by just reordering clauses or goals, we won't solve the problem. The only possible solution is to introduce a new nonterminal symbol. We could for example use the category simple_s for sentences without embedded sentences. Our grammar would then look like this: s --> simple_s. s --> simple_s conj s. simple_s --> np,vp. np --> det,n. vp --> v,np. vp --> v. det --> [the]. det --> [a]. n --> [woman]. n --> [man]. v --> [shoots]. conj --> [and]. conj --> [or]. conj --> [but].
  • 14. A DCG for a simple formal language we shall define a DCG for the formal language a^nb^n. There are only two `words' in this language: The symbol a and the symbol b. The language consist of all strings made up from these two symbols that have the following form: the string must consist of an unbroken block of as of length n, followed by an unbroken block of bs of length n, and nothing else. So the strings ab, aabb, aaabbb and aaaabbbb all belong to a^nb^n.
  • 15. CFG to generate this language: s -> epsilon s -> l s r l -> a r -> b Turning this grammar into DCG. s --> []. s --> l,s,r. l --> [a]. r --> [b]. And this DCG works exactly as we would hope. For example, to the query s([a,a,a,b,b,b],[]). we get the answer `yes',
  • 16. Visit more self help tutorials Pick a tutorial of your choice and browse through it at your own pace. The tutorials section is free, self-guiding and will not involve any additional support. Visit us at www.dataminingtools.net