AI Glossary / Natural language and speech / Intermediate

Phrase structure grammar

Definition

A phrase structure grammar describes how smaller linguistic units combine into larger constituents, such as noun phrases, verb phrases, and sentences. Rules specify permitted combinations, and a phrase-structure tree can show the resulting hierarchy. In an introductory example, a sentence may consist of a noun phrase followed by a verb phrase.

What it means

The key idea is grouping. A sentence is not just a row of words: some words form units that function together. Phrase structure represents those units and the ways they nest inside one another.

The term has several uses in linguistics and formal-language theory. This entry emphasizes the constituency-based NLP sense and illustrates it with a small context-free grammar. That example is one restricted type of grammar, not a definition that limits every historical use of “phrase structure grammar” to context-free rules. More elaborate frameworks can attach additional information and constraints to constituent structures.

How it works

A simple context-free rule has one category on the left and an ordered sequence on the right. S → NP VP says that a sentence constituent can be expanded into a noun phrase and a verb phrase in that order. Other rules expand those categories until the analysis reaches words.

Generation starts with a designated category and applies rules to produce a permitted sequence. Parsing approaches the problem from the other direction: given words, a parser searches for structures licensed by the grammar. The grammar specifies possibilities; the parsing algorithm determines how to search for them.

One word sequence may have more than one valid structure. For example, a phrase describing an instrument might attach to an action or instead help describe a noun. The grammar can preserve both analyses without deciding which interpretation the speaker intended. Additional evidence or a model that ranks analyses may be required to select among them.

Three practical examples

1. Sentence analysis: An educational tool displays how a noun phrase and verb phrase combine, letting learners inspect relationships that a flat list of word tags would hide.

2. Information extraction: A system uses constituent spans as candidate units when identifying descriptions, actions, or attachments in a document.

3. Controlled language: A small application defines a limited grammar for supported commands and checks whether input fits the intended structural patterns.

Think of it this way

Think of nested boxes: words fit into phrase boxes, and phrase boxes fit into larger boxes. The arrangement records which units belong together. The analogy is limited because grammar rules determine which groupings are allowed, and the same word sequence can support competing arrangements rather than a single obvious packing.

Worked example

Consider a toy grammar with these rules: S → NP VP; NP → Mina; NP → Ravi; VP → V NP; V → greets. It generates exactly four three-word strings: “Mina greets Mina,” “Mina greets Ravi,” “Ravi greets Mina,” and “Ravi greets Ravi.” There are two independent choices for the subject NP and two for the object NP, giving 2 × 2 = 4 strings.

For “Mina greets Ravi,” a leftmost derivation is S; NP VP; Mina VP; Mina V NP; Mina greets NP; Mina greets Ravi. That uses five rule applications. The corresponding tree groups greets Ravi as a VP while Mina is the subject NP.

The grammar does not generate “greets Mina Ravi,” because its start rule requires the initial NP. It also does not encode whether someone greeting themself is plausible or how natural self-reference would normally be expressed. The exercise concerns the exact language generated by the stipulated rules, not a complete account of English meaning or usage.

Illustrative case study

Fictional case: Willow Instructions builds a parser for a small set of warehouse commands. Its initial grammar recognizes “move the box” but rejects commands containing descriptive modifiers that staff commonly use.

The team collects representative examples, adds carefully limited noun-phrase rules, and checks both supported and unsupported combinations. It also inspects cases where a modifier could attach in more than one place. The case illustrates grammar coverage and ambiguity as separate concerns. Adding rules may expand coverage while also introducing unintended analyses, so success requires more than showing that one previously rejected sentence now parses.

Common misconceptions and mistakes

Do not confuse a grammar with a parser. One grammar can be processed by different algorithms, and changing the search procedure does not necessarily change the structures the grammar licenses.

Do not equate a constituency tree with a dependency tree. Both represent syntax, but they organize the representation differently: constituency emphasizes nested phrase units, while dependency emphasizes relations among words.

Avoid assuming that a parse proves a statement true or unambiguous. It shows compatibility with the model's structural rules. A grammar may also undergenerate, excluding intended inputs, or overgenerate, admitting combinations outside its intended coverage. Both problems deserve explicit examples during evaluation.

Business use

Phrase structure can make language-processing decisions easier to inspect when a product depends on identifiable grammatical units. It gives teams a vocabulary for discussing attachment, constituent boundaries, and coverage instead of describing every failure as generic misunderstanding.

The practical choice depends on the task. A constrained command system may benefit from a compact explicit grammar, while open-ended documents demand broader coverage and robust handling of ambiguity. Evaluation should separate whether the system finds an analysis from whether that analysis supports the correct downstream interpretation. Counting parsed sentences alone can conceal systematic attachment errors or unsupported structures.

People also ask

Is every phrase structure grammar context-free?

The term is used more broadly in some traditions. This article's worked example is specifically context-free.

Can one sentence have several phrase-structure trees?

Yes. Structural ambiguity can produce multiple analyses of the same words.

Does a phrase need several words?

Not necessarily. In a particular analysis, a phrase category can contain a single word, as the toy grammar's NP rules demonstrate.

Check your understanding

A grammar licenses two different trees for the same input. Has the parser necessarily malfunctioned?

Answer: No. The grammar may allow a genuine structural ambiguity. The application needs further evidence or a selection rule if it must choose one interpretation.

Related terms

  • Constituency
  • Context-free grammar
  • Parse tree
  • Dependency grammar
  • Syntactic ambiguity
  • constituent
  • production rule

Learn next

Build a tiny context-free grammar and enumerate its generated strings. Then add one modifier rule and inspect whether the added coverage also creates multiple parses. Compare a constituent tree with a dependency analysis of the same short sentence.

  • Context-free grammar

More in Natural language and speech

  • Phonotactics - Phonotactics concerns the patterns and constraints governing how speech sounds can combine in a language.
  • Phrasal template - A phrasal template is a reusable wording pattern containing fixed language and one or more slots that can be filled to produce particular expressions.
  • Phrasal verb - A phrasal verb is a construction in which a verb combines with a particle to function as a lexical unit, often with a meaning that cannot be predicted...
  • Pipe - In regular expressions, the pipe symbol, |, expresses alternation: a pattern can match one alternative or another.
  • Pitch - Pitch is the perceptual quality that makes a sound seem relatively high or low.
  • Pitch accent - A pitch accent, in intonational analysis, is a tonal event associated with a prominent syllable in an utterance.

Sources

Primary sources: Bird, Klein, and Loper, Natural Language Processing with Python, chapter 8: https://www.nltk.org/book/ch08.html ; Chomsky, Three Models for the Description of Language, original formal-language discussion: https://chomsky.info/wp-content/uploads/195609-.pdf . Relevant introductory material was opened and read. The entry distinguishes its constituency focus from broader historical terminology. The grammar, derivation counts, and Willow Instructions case are original teaching illustrations.

Previous: Phrase structure Next: Physical artificial intelligence

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer