Computational linguistics fundamentals
Use me when:
┌─────────────────────────────────────────────┐
│ Discourse │
│ (context, coherence) │
├─────────────────────────────────────────────┤
│ Semantics │
│ (meaning, representation) │
├─────────────────────────────────────────────┤
│ Pragmatics │
│ (intent, context, speech acts) │
├─────────────────────────────────────────────┤
│ Syntax │
│ (grammar, structure rules) │
├─────────────────────────────────────────────┤
│ Morphology │
│ (word formation, inflections) │
├─────────────────────────────────────────────┤
│ Phonology/Orthography │
│ (sounds, written form) │
└─────────────────────────────────────────────┘
import spacy
nlp = spacy.load("en_core_web_sm")
doc = nlp("The cat sat on the mat.")
# Part-of-speech tags
for token in doc:
print(token.text, token.pos_, token.tag_)
# Dependency parsing
for token in doc:
print(token.text, token.dep_, token.head.text)
# Named entities
for ent in doc.ents:
print(ent.text, ent.label_)