Linguistic basics are the grammatical categories that syntax notation assumes you already know. Symbols such as S, NP, VP and Det are not new machine learning ideas, they are ordinary school grammar written in shorthand. This note defines them once so the parsing and grammar notes stay readable.

There are 2 levels of structure, and mixing them up is the usual reason the notation feels foreign:

  1. word classes, which label a single word
  2. phrases, which label a group of words acting as one unit

Level 1: word classes

A word class is the grammatical role of one word on its own. These are the same categories produced by POS tagging, so the labels below are the coarse pos_ tags from spaCy.

ClassspaCy tagWhat it doesExamples
NounNOUNnames a thing, person, place or ideadog, flight, course
Proper nounPROPNnames 1 specific entitySingapore, Supraja
PronounPRONstands in for a noun already knownI, it, she
VerbVERBnames an action or a statechased, want, sleep
AuxiliaryAUXhelper verb that supports the main verbis, was, have, will
DeterminerDETfixes which noun you mean, and sits before that nounthe, a, this, my
AdjectiveADJdescribes a nounmorning, red, early
AdverbADVdescribes a verbquickly, yesterday
PrepositionADPshows a relation in place, time or directionin, from, on
ConjunctionCCONJjoins 2 parts of equal weightand, or, but
  • the determiner is the class that trips people up, because English forces "the dog" or "a dog" rather than "dog" on its own
  • a determiner is not an adjective, since "the big dog" is valid while "big the dog" is not, so the determiner holds a fixed slot at the front

Level 2: phrases and heads

A phrase is a group of words that behaves as 1 unit. Every phrase is named after its most important word, which is called the head.

PhraseFull nameHead wordExample
NPnoun phrasea nounthe angry dog
VPverb phrasea verbchased the cat
PPprepositional phrasea prepositionin the morning
Ssentencethe whole unitthe dog slept
  • the letter before the P names the head, so the naming scheme carries no hidden meaning
  • S is the sentence, and in a grammar it is also the start symbol that every derivation begins from

The substitution test

Deciding what counts as a phrase does not need intuition, because there is a mechanical test. If a group of words can be replaced by 1 single word and the sentence still works, that group is a real phrase, also called a constituent.

SentenceReplacementVerdict
the angry dog chased the catit chased the cat"the angry dog" is an NP
the dog chased the catthe dog slept"chased the cat" is a VP
the flight left in the morningthe flight left then"in the morning" is a PP
the dog chased the catno single word for "dog chased"not a constituent

Why the test matters

The grammar splits a sentence as NP VP and never as NP N V plus NP, because only the first split produces groups that survive substitution. The rules of a grammar are built out of constituents.

Why a sentence splits into NP and VP

An English sentence names something, then says something about it. The part that names is the NP and is called the subject. The part that comments is the VP. That single fact is the whole meaning of the rule S -> NP VP.

the dog        chased the cat
[  NP  ]       [      VP     ]
who?           what about him?

A VP can hold another NP inside it, because a verb such as "chased" needs something to chase. That inner NP is the object, which is what the rule VP -> V NP describes.

NP against Nominal

Nominal is an extra layer used in this grammar, and it is the noun plus its modifiers without the determiner.

a        early morning flight
[Det]    [      Nominal      ]
[             NP             ]
  • NP -> Det Nominal attaches the determiner exactly once, at the outside
  • Nominal -> Nominal Noun is recursive, so it stacks "morning flight" then "early morning flight" without repeating the determiner
  • without the separate Nominal layer, a recursive rule on NP would allow the illegal string "a a morning flight"

One sentence drawn out

graph TD
    S["S"] --> NP1["NP"]
    S --> VP["VP"]
    NP1 --> D1["Det: the"]
    NP1 --> N1["N: dog"]
    VP --> V1["V: chased"]
    VP --> NP2["NP"]
    NP2 --> D2["Det: the"]
    NP2 --> N2["N: cat"]
  • reading the tree downward from S is generation, which is what a grammar defines
  • reading the tree upward from the words is parsing, which is what a shift-reduce parser performs

Cheat sheet

SymbolRead it asMade of
SsentenceNP VP
NPnoun phraseDet N, Det Nominal, Pronoun
Nominalnoun with modifiersNoun, Nominal Noun
VPverb phraseV, V NP, V NP PP, V PP
PPprepositional phrasePreposition NP
Detdeterminerthe words the, a, this
N, Vsingle noun, verbthe words themselves
  • capitalised category names are non-terminals, so each one must expand further
  • actual words are terminals, so they are the leaves and nothing expands out of them