← Back to list

Teaching a Computer to Read: The Eight Things Humans Do Without Thinking

Based on Part 1 of the original series — completely new examples, deeper explanations

Krishnapiriyan · 2026-06-07 18:47 · 0 claps · 4.4 min read
#nlp #python #spacy #named-entity-recognition #tokenization
Open on Medium ↗
Wiki topics: GEN · Genomics & Sequencing EDU · Education & Learning

Teaching a Computer to Read:

The Eight Things Humans Do Without Thinking

Based on Part 1 of the original series — completely new examples, deeper explanations

Your five-year-old nephew reads his first sentence out loud. “The dog bit the man.” He laughs. He understands it instantly. He knows there is a dog, a man, and a painful event. He knows who did the biting and who suffered it. He might even feel a bit sorry for the man.

Now imagine handing that same sentence to a computer and asking it to “understand” it. Where do you even begin?

This is the central puzzle of Natural Language Processing (NLP) — the branch of Artificial Intelligence devoted to making computers understand human language. And the surprising answer is: you do not try to solve it all at once. You solve it in eight separate steps, chain those steps together like train cars, and let each car carry a piece of the meaning.

The Dirty Secret About Language

Language is astoundingly messy. It breaks its own rules constantly. Words change their meaning based on position, tone, and a million invisible cues. Consider these three headlines that have actually appeared in real newspapers:

The good news: researchers solved this by refusing to treat it as one big problem. Instead, they broke it into eight small problems. Solve each one with a statistical model. Chain them together. Suddenly you have a system that extracts meaningful, structured knowledge from wild, unstructured text.

Let’s walk through each step using a single example — a made-up police report:

“Detective Maria Rossi arrested James Walker in downtown Chicago on Tuesday. She charged him with three counts of fraud. He had been evading police for six months.”

Step 1 — Sentence Segmentation: “Where Do Thoughts End?”

Before anything else, we need to figure out where one sentence ends and the next begins. A sentence is (roughly) one complete thought. Shorter thoughts are easier to analyze.

You might think: just split on periods! But try that on: “Dr. J.R. Ewing Jr. of Dallas, Texas called at 9 a.m. on Nov. 3rd.” You’d get nine “sentences” from one. Modern NLP sentence segmenters use ML models trained on millions of documents to tell the difference.

Step 2 — Word Tokenization: “What Are the Atoms?”

We break each sentence into individual units called tokens. The period at the end becomes its own token because punctuation carries meaning. A period is different from a question mark, and both are different from a comma.

Edge cases everywhere: “can’t” → one token or two? “$4.50” → one or two? “New York” → one concept, two tokens. spaCy has thought through thousands of these for dozens of languages.

Step 3 — Part-of-Speech Tagging: “What Job Does Each Word Do?”

A POS tag tells us the grammatical role of each word. This is done by a model trained on millions of hand-tagged sentences — purely statistical pattern matching.

Step 4 — Lemmatization: “What Is the Base Form?”

English inflects words constantly. “Arrest”, “arrested”, “arresting”, “arrests” — all the same concept. To a computer looking at character strings, they look like four different words. Lemmatization finds the root form (the “lemma”) of each word.

Without lemmatization, a search for “arrest” would miss “arrested.” That’s catastrophic for a legal or news search system.

Step 5 — Stop Word Removal: “What Words Carry No Meaning?”

Words like “the”, “a”, “in”, “on”, “was”, “he”, “she”, “it” appear equally in sentences about cooking, law, astronomy, and sports. They are pure noise in statistical analysis. We call them stop words and filter them out.

Step 6 — Dependency Parsing: “How Do Words Relate to Each Other?”

Dependency parsing builds a tree showing how every word connects grammatically to every other word. The main verb is the root. This is where language becomes structured knowledge.

Step 7 — Named Entity Recognition: “What Are the Real-World Things?”

NER finds proper nouns and classifies them into real-world categories: people, places, organizations, dates, monetary values. This is where structured knowledge is extracted from raw text at scale.

Step 8 — Coreference Resolution: “What Do Pronouns Refer To?”

Sentences 2 and 3 use pronouns: “She,” “Him,” “He.” Who is “She”? Rossi. Who is “He”? Walker. Coreference resolution tracks these pronouns and maps them back to the full entity names — making every sentence independently understandable.

The Complete Python Code

# pip install spacy
# python -m spacy download en_core_web_sm

import spacy

nlp = spacy.load("en_core_web_sm")

text = """Detective Maria Rossi arrested James Walker in downtown Chicago
on Tuesday. She charged him with three counts of fraud. He had been
evading police for six months."""

doc = nlp(text)

# Step 1: Sentences
for i, sent in enumerate(doc.sents, 1):
    print(f"Sentence {i}: {sent.text.strip()}")

# Steps 2-5: Token analysis
for token in doc:
    if not token.is_space:
        print(f"{token.text:15} lemma={token.lemma_:12} pos={token.pos_:8} stop={token.is_stop}")

# Step 7: Named entities
for ent in doc.ents:
    print(f"[{ent.label_}] {ent.text}")

# OUTPUT:
# [PERSON]  Maria Rossi
# [PERSON]  James Walker
# [GPE]     Chicago
# [DATE]    Tuesday
# [CARDINAL] three
# [DATE]    six months

메타데이터
post_id
5616f29bb4ef
slug
teaching-a-computer-to-read-the-eight-things-humans-do-without-thinking-5616f29bb4ef
url
https://medium.com/@krishnapiriyan2003/teaching-a-computer-to-read-the-eight-things-humans-do-without-thinking-5616f29bb4ef
canonical_url
https://medium.com/@krishnapiriyan2003/teaching-a-computer-to-read-the-eight-things-humans-do-without-thinking-5616f29bb4ef
author_url
https://medium.com/@krishnapiriyan2003
status
ok
fetched_at
2026-07-10 04:31:59