A concise guide to the core structures of linguistics and Python examples.
Linguistics is the study of how language is built, understood, and used. Computational linguistics represents sounds, words, sentences, meaning, and context as structured data that can be modeled, analyzed, and transformed. Many of these concepts can be represented with trees and other data structures.
01. Phonology: sound systems
Phonology studies the abstract sound categories a language uses. It distinguishes phonemes from allophones, describes contrastive features, and models how sounds alternate in context through distinctive features, syllable structure, stress patterns, and neutralization. The syllable itself is a small tree: an onset and a rime, the rime splitting into nucleus and coda.
Python concepts
- Unicode strings, normalization, and IPA tokenization
- regular expressions for phonotactic patterns
- dictionaries for feature sets and segment inventories
- finite-state transducers for alternations and phonological rules
02. Morphology: word structure
Morphology covers morphemes, roots, affixes, and the difference between inflection and derivation. It explains how words are composed, how paradigms work, and how productive processes generate new forms. Morphophonology links this word structure back to phonology.
Python concepts
- tokenization into morpheme sequences
- rule-based segmentation and finite-state morphology
- feature bundles to represent tense, number, case, and agreement
- lexicon lookups with dictionaries and nested maps
03. Syntax: sentence architecture
Syntax is the grammar of sentence structure. It distinguishes constituency from dependency, models movement and agreement, and explains how arguments relate to predicates through phrase-structure rules, X-bar theory, and Minimalist derivations. The parse tree is the canonical structure here.
Python concepts
- tree structures and recursive traversal
- context-free grammars for constituency parsing
- dependency graphs for head-dependent relations
- parsing algorithms like CKY and Earley
04. Semantics: meaning and inference
Semantics asks how meaning is composed from words and structures. It covers lexical meaning, compositional semantics, quantification, entailment, and reference, connecting predicate logic to natural-language meaning through scope, presupposition, and modality. Composition itself is a bottom-up tree.
Python concepts
- symbolic representations with tuples, dicts, and lambda expressions
- typed feature structures for semantic roles
- vector embeddings for lexical semantics
- logic-style evaluation over structured data
05. Pragmatics and discourse
Pragmatics studies language in context: speaker intent, implicature, deixis, and conversational structure. Discourse analysis looks at cohesion, coherence, information structure, and how language unfolds across turns. Context changes interpretation, allowing one utterance to carry several layers of meaning.
Python concepts
- stateful context windows for dialogue
- coreference chains and entity tracking
- annotated corpora for discourse relations
- feature extraction for pragmatics signals
06. Typology, variation, and modeling
Typology compares language structures across systems: word order, morphological type, case alignment, and markedness. Variation studies dialects, register, and social meaning, revealing how universals emerge from data and where exceptions matter. The field is a classification hierarchy.
The Rosetta Stone
One decree carved in three scripts: Egyptian hieroglyphic, Demotic, and Ancient Greek. Because the Greek was still readable, it became the key that let Champollion decipher hieroglyphs in 1822: the original parallel corpus, and a founding artifact of comparative and typological linguistics.
British Museum · via Wikimedia CommonsPython concepts
- dataset filtering by language and typological features
- statistics on frequency and distribution
- corpus analysis for variation and register
- modeling language as structured, probabilistic data
07. Python patterns for linguistics
Linguistics concepts can be represented with computational abstractions. Sounds can use tokens and feature matrices, words can use segmented sequences and morphological state machines, syntax can use trees and graphs, and meaning can use structured logic or dense vectors.
from collections import defaultdict
def tokenize(text):
return text.lower().split()
def build_lexicon(tokens):
lexicon = defaultdict(int)
for token in tokens:
lexicon[token] += 1
return lexicon
text = "The quick brown fox jumps over the lazy dog"
print(build_lexicon(tokenize(text)))
The example represents language with code before applying rules, models, or statistical inference to the resulting data.