Related Natural Language Processing Links
Learn Cfg Natural Language Processing Tutorial, validate concepts with Cfg Natural Language Processing MCQ Questions, and prepare interviews through Cfg Natural Language Processing Interview Questions and Answers.
Context-Free Grammar
Learn the mathematical rules of Context-Free Grammars used to define and evaluate Constituency structure in language.
Context-Free Grammars (CFG)
A Context-Free Grammar (CFG) is a mathematical system of strict rewriting rules used to generate syntactically valid sentences in a language. It forms the backbone of Constituency Parsing.
It is called "context-free" because the left-hand side of every rule consists of a single non-terminal symbol, meaning the rule can be applied regardless of the surrounding context.
Anatomy of a CFG
A simple CFG for English contains rules written as A → B C (meaning "A consists of B and C").
Noun → "dog" | "cat"
Verb → "chased" | "saw"
Prep → "with" | "in"
NP → Det Noun
VP → Verb NP
Generating a Sentence
Starting from the ROOT state S (Sentence), we apply the substitution rules from top to bottom: