A sentence isn't just a flat string of words β it's built, like a little machine, out of nested parts. A handful of rules ("a sentence is a noun phrase plus a verb phraseβ¦") snap words into phrases, phrases into bigger phrases, and finally into a whole sentence. That hidden tree is what tells you who did what to whom β and when a sentence has two trees, it has two meanings. Scroll through to watch the structure assemble itself.
Pick a sentence and press Build. A tiny grammar groups the words into constituents β a Noun Phrase (NP), a Verb Phrase (VP), a Prepositional Phrase (PP) β which combine into the sentence node S at the top. The last example is recursive: a relative clause embeds another whole sentence, so the same rules can keep nesting forever.
Some sentences can be drawn two different ways from the very same words β and the structure, not the vocabulary, decides what they mean. Toggle the two parses of "I saw the man with the telescope": does the telescope attach to the seeing (it's your instrument) or to the man (he's holding it)? Then try the garden-path sentence, where your brain commits to the wrong tree halfway through.
Underneath every sentence is a phrase-structure grammar: a short list of rewrite rules that say how big things are made of smaller things. The grammar driving scene 1 is essentially this:
A constituent is a chunk that behaves as a unit β you can move it, replace it with a single word, or answer a question with it. "The cat" is a constituent (swap in "it"); "cat sat on" is not. The tree is just a map of which words clump together, and at what level.
Notice that NP β Det N RelClause and RelClause β "that" VP let a rule
ultimately refer back to itself: a noun phrase can contain a clause that contains another noun
phrase, and so on β "the cat that chased the dog that bit the rat thatβ¦". A finite set of rules
therefore licenses an infinite set of sentences. That self-embedding is widely held to be the
hallmark of human language.
When one string of words admits more than one tree, it is structurally ambiguous β and the different trees mean different things. The words "I saw the man with the telescope" never change; only whether the prepositional phrase hangs off the verb or off the noun does. Meaning lives in the structure, not just the dictionary.
A classical parser searches for tree(s) consistent with the grammar; faced with ambiguity it may return several and then rank them by likelihood (a probabilistic grammar). Language models don't draw trees explicitly, but to predict the next word well they must implicitly track this same hierarchical structure β which is why they usually resolve "with the telescope" the way a human reader would, and why they, too, can be led down a garden path.