NLP Module 3
NLP Module 3
By
Dr. L. Lakshmi
Course Code: DS311
Module-3
Module-3 Contents
• "leaving on Thursday“
• S → VP
• → Verb PP
• → leaving PP
• → leaving Preposition NP
• → leaving on NP
• → leaving on Thursday
Context Free Grammars for English
• Example ATIS Corpus:
[S [NP [Pro I]] [VP [V prefer] [NP [Det a] [Nom [N morning] [Nom [N flight]]]]]]
Context Free Grammars for English
• Example ATIS Corpus:
Context Free Grammars for English
• Example ATIS Corpus:
Context Free Grammars for English
• Example ATIS Corpus:
Context Free Grammars for English
• Context-Free Grammars:
• Grammatical Sentences: Sentences derivable by the CFG rules are considered grammatical.
• Ungrammatical Sentences: Sentences not derivable by the grammar are ungrammatical.
• Generative Grammar: CFGs define a formal language by generating all possible grammatical
sentences.
• Formal definition of context-free grammar
• A context-free grammar G is defined by four parameters N, ∑, R, S ( technically “is a 4-tuple”):
• N a set of non-terminal symbols (or variables)
• ∑ a set of terminal symbols (disjoint from N)
• R a set of rules or productions, each of the form A → β , where A is a non-terminal, β is a string of
symbols from the infinite set of strings (∑ U N)
• S a designated start symbol
• The formal properties of context-free grammars
Top-down parsing is efficient in focusing on trees rooted in S, but may generate trees
incompatible with the input, wasting time on unnecessary branches.
Bottom-up parsing avoids generating trees that don’t match the input but can be
inefficient in creating subtrees that have no chance of leading to an S.
Grammar Rules for English
Optional Use of Augmentative
Machine Translation Spelling Correction
Determiners communication
•Definition: Helps in •Purpose: ranslating •Definition: Real words •Definition:
identifying words in noisy Chinese to English.. resulting from spelling •People who are unable to
and ambiguous input •Example: Consider a errors. use speech or sign
•Example: Woody Allen's "I Chinese sentence •Examples of Questions: language to communicate,
have a gub" misread •note that like the physicist Steven
scenario •potential rough English •“in about fifteen minuets“ Hawking.
•Solution: N-grams help translations. •Corrected to •Example:
avoid such errors by •he briefed to reporters on •“in about fifteen minutes” •Suggesting likely words
predicting more probable the chief contents of the for the menu.
word sequences. •Capabilities:
statement •Benefit:
•“I have a gun” •A spellchecker can use a
•he briefed reporters on the probability estimator both •Enhances the efficiency of
chief contents of the to detect these errors and to communication systems
statement suggest higher-probability
•he briefed to reporters on corrections.
the main contents of the
statement
•he briefed reporters on the
main contents of the
statement
•Choosing the Best
Translation:
Ngrams Models
Applications of N-gram Models
Augmentative
Speech Recognition Machine Translation Spelling Correction
communication
•Definition: Helps in •Purpose: ranslating •Definition: Real words •Definition:
identifying words in noisy Chinese to English.. resulting from spelling •People who are unable to
and ambiguous input •Example: Consider a errors. use speech or sign
•Example: Woody Allen's "I Chinese sentence •Examples of Questions: language to communicate,
have a gub" misread •note that like the physicist Steven
scenario •potential rough English •“in about fifteen minuets“ Hawking.
•Solution: N-grams help translations. •Corrected to •Example:
avoid such errors by •he briefed to reporters on •“in about fifteen minutes” •Suggesting likely words
predicting more probable the chief contents of the for the menu.
word sequences. •Capabilities:
statement •Benefit:
•“I have a gun” •A spellchecker can use a
•he briefed reporters on the probability estimator both •Enhances the efficiency of
chief contents of the to detect these errors and to communication systems
statement suggest higher-probability
•he briefed to reporters on corrections.
the main contents of the
statement
•he briefed reporters on the
main contents of the
statement
•Choosing the Best
Translation: