The NLP Problem and Linguistic Structure

Imagine a machine that must decide whether "I saw her duck" describes an act of vision or an act of ownership. A human resolves this instantly using context. Yet a computer sees only a string of characters. This puzzle — turning raw text into something a machine can reason about — is the founding problem of Natural Language Processing (NLP). It sits at the intersection of computer science, linguistics, and statistics. It underlies everything from spell-checkers to conversational assistants. Language is the primary way humans store and transmit knowledge. So any system that reads email, answers questions, or translates documents must confront the same obstacles: ambiguity, variation, and context-dependence. Unlike a programming language, natural language has no fixed grammar that every speaker obeys. It has no unique parse for every sentence, and no single correct way to express an idea. A word can be a noun in one sentence and a verb in the next. A pronoun can refer to something mentioned three sentences earlier, or to nothing at all. The big picture of NLP is that language is structured at multiple levels simultaneously — sounds, word-parts, words, sentence structure, meaning, and conversational purpose. A working system must model these levels together, not in isolation. Classical and statistical NLP built this understanding by treating each level as a distinct layer. Each layer had its own representations and algorithms, later stitched together into pipelines. Modern large language models blur these boundaries by learning distributed representations. But the linguistic levels remain the map by which we diagnose what a model gets right or wrong. This article gives the vocabulary and conceptual scaffolding for everything that follows in NLP. It covers what the levels of linguistic structure are, and why each one introduces its own kind of ambiguity. It also shows how these layers combine into the "NLP problem" that engineering pipelines must solve. It sets up later material on Tokenization, Morphology, and statistical modeling of language.

Key takeaways
  • NLP is the field of building systems that process, understand, or generate human language.
  • Language is hard because it is ambiguous, compositional, context-dependent, and constantly evolving.
  • Linguistic structure has recognized levels: phonetics/phonology, morphology, syntax, semantics, discourse, and pragmatics.
  • Each level introduces a distinct type of ambiguity (phonetic, lexical, syntactic, semantic, referential, pragmatic).
  • Classical NLP systems were organized as pipelines that process text level by level, from tokens up to meaning.
  • Understanding these levels is the prerequisite for tokenization, morphology, parsing, and every modern language model.
The core insight

Human language is a layered code — sound, structure, and meaning stacked on top of each other — and NLP is the engineering discipline of making machines decode each layer despite pervasive ambiguity.

The idea — 2-3 paragraphs defining the concept precisely, with the right terminology introduced cleanly

Natural Language Processing (NLP) is the subfield of computer science and artificial intelligence concerned with enabling computers to process, analyze, and generate human language — whether written text or transcribed speech. The word "natural" distinguishes human languages like English, Mandarin, or Swahili from formal languages such as programming languages, which are engineered to be unambiguous. NLP tasks span a spectrum: low-level tasks like splitting text into words, mid-level tasks like identifying the grammatical role of each word, and high-level tasks like answering a question or summarizing a document. What unifies all these tasks is that they require some model of linguistic structure — the systematic organization that language imposes on otherwise unstructured strings of symbols. Linguists traditionally decompose language into a hierarchy of levels, each studied by its own subdiscipline. Phonetics and phonology concern the sounds of speech and how they pattern into a language's sound system. Morphology studies how words are built from smaller meaningful units called morphemes (for example, "unhappiness" decomposes into un-, happy, -ness). Syntax governs how words combine into phrases and sentences according to grammatical rules. Semantics is the study of literal meaning — what words and sentences denote. Pragmatics studies meaning in context: what a speaker intends to convey given the situation, beyond the literal words. A related notion, discourse, concerns how sentences connect to each other across a text or conversation, including reference and coherence. These levels are usually presented in increasing order of context-dependence, from the physical signal (sound) to the social act (intention). The central engineering insight is that ambiguity compounds across levels. A speech signal may be consistent with multiple phoneme sequences; a word form may have multiple morphological analyses; a sentence may have multiple syntactic parses; a parse may support multiple semantic readings; and a sentence's pragmatic force may depend on who is speaking to whom. Classical NLP responded to this by building pipelines: a sequence of processing stages, each resolving ambiguity at one level before passing a cleaner representation to the next stage. This pipeline view is the historical backbone of the field and remains the clearest way to teach why NLP is hard, even as modern systems increasingly learn end-to-end representations that implicitly span several levels at once.

How it works — the algorithm / mechanism, step by step

There is no single "algorithm" for NLP as a whole; rather, the field is organized as a layered pipeline of interpretation, where each stage takes a representation from the previous stage and refines it using level-specific tools. Below is the classical pipeline architecture, presented as pseudocode that any concrete NLP system — from a 1990s tagger to a modern chatbot's preprocessing stage — can be seen as instantiating. ``` function CLASSICAL_NLP_PIPELINE(input_signal):

# Stage 0: Acoustic / orthographic input if input_signal is speech: phonemes = PHONETIC_ANALYSIS(input_signal) # sound -> phoneme sequence text = PHONOLOGICAL_DECODE(phonemes) # phoneme sequence -> word hypotheses else: text = input_signal # already written text

# Stage 1: Tokenization (segment text into words/punctuation) tokens = TOKENIZE(text)

# Stage 2: Morphological analysis (decompose words into morphemes, tags) morph_analyses = [] for token in tokens: morph_analyses.append(ANALYZE_MORPHOLOGY(token)) # e.g. "running" -> run + -ing (VERB, GER)

# Stage 3: Syntactic analysis (assign part-of-speech, build parse tree) pos_tags = TAG_PARTS_OF_SPEECH(tokens, morph_analyses) parse_tree = PARSE(tokens, pos_tags) # resolve structural ambiguity

# Stage 4: Semantic analysis (map structure to meaning representation) logical_form = SEMANTIC_INTERPRET(parse_tree) # resolve word-sense, compose meaning

# Stage 5: Discourse and coreference (link across sentences) discourse_repr = RESOLVE_COREFERENCE(logical_form, prior_context)

# Stage 6: Pragmatic interpretation (infer speaker intent, given context) intent = INFER_PRAGMATICS(discourse_repr, situational_context) return intent ``` Each stage in this pipeline exists precisely because a level of linguistic structure introduces a specific ambiguity that must be resolved before the next stage can operate reliably.

Step 1 — Tokenization. Raw text is split into words, punctuation, and other units. Even this first step is nontrivial: "don't" may become one token or two ("do" + "n't"); "New York" may be one unit or two words; a period may end a sentence or mark an abbreviation ("Dr."). This step is elaborated in the article on Text Preprocessing and Tokenization.

Step 2 — Morphological analysis. Each token is decomposed into a stem (or lemma) and affixes, and tagged with grammatical features such as tense, number, or case. "Ran" is analyzed as the past tense of "run"; "geese" as the plural of "goose." Languages differ enormously in how much information morphology carries — Turkish and Finnish pack many grammatical features into a single word, while English relies more on separate function words. This step feeds into Morphology and Stemming.

Step 3 — Syntactic analysis. Part-of-speech tags are assigned (noun, verb, adjective, ...), and a parser builds a tree representing how words group into phrases and how phrases relate (subject, object, modifier). Syntax resolves structural ambiguity: "I saw the man with the telescope" can attach "with the telescope" to "saw" (I used a telescope) or to "the man" (the man had a telescope). A parser must choose — or represent both — analyses.

Step 4 — Semantic analysis. The syntactic tree is mapped onto a meaning representation: who did what to whom, what entities are referenced, what logical relations hold. This step resolves lexical ambiguity (word senses: "bank" as a financial institution versus a riverbank) and composes word meanings according to sentence structure.

Step 5 — Discourse and coreference. Sentences are linked across a passage. Pronouns and definite descriptions are resolved to their antecedents: in "Maria took her badge to the office. She showed it to the guard," a discourse module infers that "she" is Maria and "it" is the badge.

Step 6 — Pragmatics. Finally, the system infers what the speaker actually means given context, tone, or convention. "Can you pass the salt?" is syntactically a yes/no question, but pragmatically a request for action. This is the level at which sarcasm, indirect speech acts, and implicature live. The following figure lays out this pipeline as a layered architecture, showing how ambiguity is introduced and progressively narrowed at each stage.

Figure
The classical NLP pipeline: linguistic levels from sound to intent, with the ambiguity resolved at each stage
Phonetics / Phonology raw acoustic signal → phoneme sequence ambiguity: which sounds? Morphology word → stem + affixes + grammatical features ambiguity: which word-parts? Syntax tokens + tags → parse tree (phrase structure) ambiguity: which structure? Semantics parse tree → literal meaning representation ambiguity: which sense/meaning? Discourse sentence meanings → linked, coreferent text ambiguity: which referent? Pragmatics discourse + context → speaker intent ambiguity: which intent? Example: "I saw her duck" syntax: [duck = noun] vs [duck = verb] — resolved (or left open) only with context

Complexity & correctness — the time and space complexity, and a correctness argument

Because "NLP" names a problem area rather than a single algorithm, complexity must be discussed per stage, and correctness must be discussed as a modeling claim rather than a proof in the traditional algorithmic sense.

Tokenization. A simple whitespace/punctuation tokenizer is a single linear scan: O(n)O(n) time and O(n)O(n) space for a string of length nn, since each character is visited a constant number of times and each token is stored once. Rule-based tokenizers using regular expressions preserve this linear bound as long as the regular expressions are compiled into finite automata (matching is linear in input length for a fixed-size automaton).

Morphological analysis. Dictionary-lookup morphological analyzers run in O(1)O(1) expected time per word given a hash-table lexicon, so O(n)O(n) overall for nn words. Rule-based analyzers using finite-state transducers (composing phonological and morphological rules) also run in time linear in word length, because finite-state transducers process input symbol by symbol with bounded states — a consequence of the Kleene/Myhill–Nerode theory underlying finite automata: any regular relation can be recognized in time proportional to input length.

Syntactic parsing. This is where complexity becomes serious. Context-free parsing with the CYK algorithm runs in O(n3∣G∣)O(n^3 |G|) time and O(n2)O(n^2) space for a sentence of nn words and grammar size ∣G∣|G|, because CYK fills a triangular chart of O(n2)O(n^2) spans, each requiring O(n)O(n) work to consider all split points, combined with grammar rule lookups. This cubic bound is a worst-case guarantee: it holds regardless of how ambiguous the sentence is, because the chart-based dynamic program shares subcomputations across all parses (the same insight that makes edit-distance and other DP algorithms sub-exponential despite exponentially many possible solutions). Without dynamic programming, naively enumerating all parse trees of an ambiguous sentence takes time exponential in nn, since the number of binary bracketings of nn items grows as the Catalan numbers, Cn−1=(2n−2n−1)/nC_{n-1} = \binom{2n-2}{n-1}/n.

Semantic and pragmatic interpretation. These stages are not generally decidable to "solve" in a formal sense, because pragmatic inference depends on open-ended world knowledge and speaker intention, which cannot be fully enumerated. Classical systems bound this by restricting to narrow domains (e.g., a fixed set of intents in a dialogue system), reducing an otherwise unbounded inference problem to a finite classification problem solvable in time linear in the size of a fixed intent inventory.

Correctness — what "correct" even means here. Unlike sorting or shortest paths, there is rarely a unique correct output for an NLP task, because human language licenses genuine ambiguity that even people resolve differently. The appropriate correctness criterion is therefore agreement with human judgment, operationalized via:

  • Coverage: does the pipeline produce some analysis for every valid input? (An analyzer with a closed lexicon fails to reach 100% coverage on new words — the classical out-of-vocabulary problem.)
  • Precision/Recall against a gold standard: does the system's chosen analysis match a linguist-annotated corpus?
  • Inter-annotator agreement as an upper bound: since even expert human annotators disagree on parses or word senses some fraction of the time (agreement rates well below 100% are typical for hard semantic tasks), no algorithm can be "more correct" than the ambiguity intrinsic to the data — this is the theoretical ceiling on achievable accuracy, often called the Bayes error of the task.

This reframes the "proof of correctness" question: a pipeline stage is correct not in the sense of matching a mathematical specification, but in the sense that its error rate approaches the irreducible disagreement rate among competent human speakers. This is a genuinely different notion of correctness from classical algorithms, and it is the reason NLP historically moved from hand-written rules (which are brittle against real language variation) toward statistical and later learned models (which fit the empirical distribution of human-produced language).

Tradeoffs. Pipelines have the advantage that each stage is inspectable and errors are localizable — you can look at the parse tree and see the parser was wrong. Their disadvantage is error propagation: a mistake at the morphology stage compounds through syntax, semantics, and pragmatics, and there is no mechanism for a later stage's evidence to correct an earlier stage's mistake. This is one of the central motivations for later end-to-end and joint models that let signal flow both ways across levels, at the cost of interpretability.

Worked example — a concrete trace

Consider the sentence: > "The old man the boats." This is a classic linguistic garden-path sentence — a sentence that is grammatically valid but leads most readers to an incorrect first parse. Tracing it through the pipeline exposes exactly where and why each linguistic level matters.

StageInputProcessingOutput / ambiguity
Tokenization`"The old man the boats."`split on whitespace/punctuation`[The, old, man, the, boats, .]`
Morphologyeach tokenlook up stems + possible tags`man`: {NOUN "man"} or {VERB "to man" (staff/operate)}; `old`: {ADJ}; `boats`: {NOUN-plural}
Syntax (first attempt)tokens + tagsgreedy parser assumes most frequent tag for "man" (NOUN)parses `The old man` as a noun phrase (subject) — then fails, because `the boats` cannot attach as a verb phrase with no verb
Syntax (correct parse)tokens + tagsreanalysis: "man" tagged VERB, "old" modifies "the" as a nominalized adjective ("the old" = old people)`[The old]NP [man]VERB [the boats]NP` → "The elderly [people] operate the boats."
Semanticscorrect parsecompose meaning: subject = "the old (people)", predicate = "man (verb, to crew/operate)", object = "the boats"Logical form: `man(the_old, the_boats)`
Discourse—no prior context, no pronounsno coreference needed
Pragmaticsfull sentence, context = neutralinterpret as a literal assertion"Elderly people are the ones operating the boats."

The trace shows precisely why NLP is hard even for a single, short, fully grammatical sentence: the most frequent part-of-speech tag for "man" is noun, so any tagger relying on unigram frequency alone will mis-tag it, causing the syntactic parser to fail or mis-parse, which in turn produces an incoherent semantic representation. Only a model that considers the whole-sentence context — that "the boats" needs a verb before it, and no other verb candidate exists — recovers the correct analysis. This is exactly the kind of cross-level interaction (morphology feeding syntax, syntax constraining word-sense choice) that motivated statistical part-of-speech tagging and parsing using sequence models, which weigh tag sequences rather than single-word frequencies. A second short example makes the semantic/pragmatic distinction concrete. Consider a customer support chatbot receiving: > "This is the third time my package hasn't arrived." Syntactically and semantically, this sentence is a simple factual statement. Pragmatically, in the context of a support chat, it functions as a complaint carrying an implicit request ("please fix this" or "please refund me") — an instance of an indirect speech act. A pipeline that stops at the semantic level will output a true-but-useless representation ("the package has not arrived, and this has happened three times"); only pragmatic inference, conditioned on the discourse context (a support chat), recovers the actionable intent. This is why production dialogue systems add an explicit intent-classification or dialogue-act stage on top of syntactic and semantic parsing.

Common pitfalls & traps

PitfallWhy it happensConsequence
Treating tokenization as trivial whitespace splittingIgnoring contractions, clitics, hyphenation, multi-word expressionsDownstream stages see wrong "words" (e.g. "n't" glued to "don"), corrupting all later analysis
Assuming one tag/sense per wordUsing unigram-frequency shortcuts (most frequent POS or sense)Fails on ambiguous but common structures, e.g. garden-path sentences like "The old man the boats"
Confusing syntax with semanticsBelieving a valid parse tree guarantees a sensible meaning"Colorless green ideas sleep furiously" parses fine syntactically but is semantically anomalous
Ignoring pragmatics/context entirelyTreating language understanding as sentence-level onlyMissing indirect requests, sarcasm, or discourse-dependent reference resolution
Assuming ambiguity is rareAnecdotal intuition ("most sentences are obvious to me")Underestimating error propagation risk in pipelines; real corpora show pervasive lexical and structural ambiguity
Treating all languages as English-likeMorphology-light assumption baked into tokenizer/parser designSystems break on morphologically rich languages (Turkish, Finnish, Arabic) or languages without whitespace word boundaries (Chinese, Japanese)

Pioneers & history

The recognition that language has distinct, analyzable levels predates computing by millennia, but the formalization relevant to NLP emerged through 20th-century linguistics and information theory converging with early computer science.

Origins · 1 minFerdinand de Saussure and how this was discovered
FD
Ferdinand de Saussure
1857-1913 · Founder of structural linguistics, whose posthumously published lectures established language as a system of interrelated signs — the conceptual root of treating language in discrete, analyzable levels

CS
Claude Shannon
1916-2001 · Electrical engineer and mathematician whose 1948 information theory paper modeled language statistically as a stochastic source, providing the mathematical foundation for later statistical NLP

NC
Noam Chomsky
1928- · Linguist whose formal grammar hierarchy gave syntax a precise, algorithmically tractable definition, directly enabling parsing algorithms in computational linguistics

History
1948
— Claude Shannon publishes "A Mathematical Theory of Communication," modeling language as a probabilistic sequence of symbols.
1957
— Noam Chomsky publishes "Syntactic Structures," formalizing phrase-structure grammar and the levels of syntactic analysis.
1966
— The ALPAC report concludes that rule-based machine translation has stalled, redirecting funding toward more linguistically grounded and later statistical approaches.
1980
s — Probabilistic part-of-speech tagging and statistical parsing emerge, treating ambiguity resolution as a problem of estimating likelihoods from corpora.
1990
s — Large annotated treebanks (e.g., the Penn Treebank) enable data-driven parsers to be trained and evaluated on the classical linguistic-level pipeline described here.

Where this matters

Every production NLP system, however modern, is still organized around the linguistic levels described here, even when a single neural network appears to "do it all." Search engines must tokenize and normalize morphological variants ("running" and "run") so that a query matches relevant documents. Machine translation systems must resolve syntactic ambiguity (which phrase attaches to which) before they can correctly reorder words across languages with different syntax. Speech assistants must resolve phonetic ambiguity ("recognize speech" versus "wreck a nice beach") using downstream syntactic and semantic context. Grammar-checking tools rely explicitly on morphological and syntactic analysis to flag subject-verb agreement errors. Customer-service chatbots depend on pragmatic/intent-level modeling to distinguish a literal statement from an implied request. Even large language models, which are trained without explicit linguistic-level supervision, are evaluated and debugged using this same vocabulary: researchers diagnose failures as "the model mis-resolved coreference" (a discourse-level failure) or "the model missed the sarcasm" (a pragmatic-level failure), because the levels remain the clearest diagnostic frame humans have for language understanding. Anyone building or evaluating an NLP system — from a spell-checker to a chat assistant — reasons in these terms, which is why this layered view remains foundational before studying Tokenization, Morphology, or statistical language modeling in depth.

Ask the tutor: How would this pipeline need to change for a language with no whitespace between words, like Chinese?

What is the difference between NLP and computational linguistics?

The two fields overlap heavily but have different emphases. Computational linguistics traditionally emphasizes using computational methods to test and refine linguistic theories — for example, formalizing a grammar and checking whether it generates exactly the sentences a language allows. NLP emphasizes building working systems: parsers, translators, chatbots, and search engines that must work robustly on real, messy text regardless of whether the underlying model is linguistically elegant. In practice, most modern researchers move fluidly between the two: statistical and neural NLP borrowed its levels of analysis (phonology, morphology, syntax, semantics, pragmatics) directly from linguistics, while linguistic theories increasingly get tested at scale using NLP tools and corpora.

Why do linguists separate syntax and semantics if we ultimately just want meaning?

Separating syntax and semantics lets each be modeled with the right tools and lets errors be localized. Syntax deals with structural well-formedness — which word sequences are grammatical and how they group into phrases — independent of whether the result is true, sensible, or meaningful. Semantics deals with what that structure denotes. Chomsky's famous example "Colorless green ideas sleep furiously" is syntactically perfect English but semantically anomalous, showing the levels are logically independent. Engineering-wise, this separation lets you build a parser using only grammatical rules or statistics over grammatical structure, then attach a separate semantic-interpretation module, rather than needing one monolithic system that jointly reasons about grammar and meaning from scratch.

Does every language have the same levels of linguistic structure?

Every known human language exhibits phonology, morphology, syntax, semantics, and pragmatics, which is itself a striking empirical fact used as evidence for universal properties of human language. However, languages differ enormously in how much "work" each level does. Isolating languages like Mandarin have very limited morphology (words rarely change form) and lean heavily on word order and function words for grammatical meaning. Agglutinative languages like Turkish or Finnish pack many grammatical features into a single word via chains of suffixes, so a single "word" can require substantial morphological analysis before any meaningful tokenization is possible. This variation means NLP pipelines built for English often transfer poorly to morphologically rich or non-whitespace-segmented languages like Chinese or Japanese.

What is the "garden-path sentence" phenomenon, and why does it matter for NLP?

A garden-path sentence is a grammatically valid sentence that strongly tends to mislead a reader (or a parser) into an incorrect initial interpretation, typically because an early, locally plausible analysis of a word turns out to be globally wrong. "The old man the boats" mis-leads because "man" is far more frequently a noun than a verb, causing frequency-based taggers to commit to the wrong tag before seeing enough context. These sentences matter because they are natural stress tests: any tagging or parsing method that relies purely on local, frequency-based decisions will fail on them, which is exactly why statistical parsers use whole-sentence context (via sequence models or global scoring) rather than committing to decisions token by token.

Is pragmatics really necessary for practical systems, or is it mostly a theoretical concern?

Pragmatics is essential for any deployed conversational system. A voice assistant that treats "Do you know what time it is?" as a literal yes/no question (correctly answerable with "yes") rather than as an indirect request for the current time would be unusable. Customer support systems, virtual assistants, and even search engines rely on pragmatic inference to map literal statements onto intended actions — recognizing complaints, requests, sarcasm, or politeness conventions. Ignoring pragmatics produces systems that are technically correct at the sentence level but practically useless, which is why intent classification and dialogue-act modeling are standard components of production dialogue systems, effectively operationalizing pragmatic inference as a learnable stage.

How do modern neural language models relate to this classical layered view?

Large neural language models are typically trained end-to-end on raw text without explicit stage-by-stage supervision for tokenization, morphology, syntax, or semantics — the levels are not built in as separate modules. Nonetheless, researchers use exactly this vocabulary to probe and explain model behavior: studies show that intermediate representations in transformer layers correlate with syntactic structure, and error analyses still describe failures as "coreference errors" or "pragmatic misunderstandings." The classical levels persist as the diagnostic and explanatory framework even though the engineering architecture no longer enforces them as discrete pipeline stages, which is why understanding them remains foundational before studying how modern models are built and evaluated.

Why is tokenization considered part of the "NLP problem" rather than a trivial preprocessing detail?

Tokenization looks trivial — split on spaces and punctuation — until real text is encountered. Contractions ("don't"), hyphenated compounds ("state-of-the-art"), multi-word named entities ("New York City"), abbreviations ("Dr.", "U.S.A."), and languages without whitespace word boundaries (Chinese, Japanese, Thai) all break naive rules. Because every later pipeline stage depends on having the "right" units to analyze, tokenization errors propagate through morphology, syntax, and semantics with no mechanism for later correction. This is precisely why tokenization is treated as a full topic in its own right — see Text Preprocessing and Tokenization — rather than a one-line preprocessing step.

Where this leads