SECTION 12 / 17

Remember a name instead of searching again

1 min read
LastName stores a candidate while the paragraph is read forwards. Update it when a new recognized person name appears.
LastName stores a candidate while the paragraph is read forwards. Update it when a new recognized person name appears.

Repeatedly searching backwards for Swaminathan seems wasteful. Keep a variable LastName. Start it as empty. Read forwards; when a recognized person name appears, update LastName. At a relevant pronoun, use the remembered name as a candidate. This replaces repeated scans with remembered information.

REAL COURSE DATA · THINK BEFORE EACH STEP

Remember the last person name

Trace the records, compare the methods and watch what changes. Back and Reset let you try again.

Ready

CURRENT RECORD X

Ready to begin

Choose Next step to follow the actual course records.

What we remember

Processed
0

Start with Next step. Predict what changes before reading the explanation.

LastName = empty
for each word card X in paragraph order:
    if X is a recognized person name:
        LastName = X.Word
    if X is a relevant personal pronoun:
        if LastName is empty:
            report "Unresolved"
        else:
            report LastName as a candidate, not guaranteed meaning

For “his eyes” at position 9 and “He shuddered” at position 40, the candidate is Swaminathan. A single forward pass can generate these candidates without repeated backward scans. The rule must still be checked against what the sentence means.

The lecture discusses keeping more than one remembered person or object. That may help, but categories alone cannot resolve every sentence. Do not infer a person’s identity or pronoun use from a name. We use explicit passage context, and we leave the opening “It” and impersonal “it” outside this person-name demonstration.

Try it yourself

Should seeing Monday overwrite LastName?

Show explained answer

No. Monday is a noun but not a person name. Updating on every noun would break even these simple examples.

Try it yourself

What does LastName contain immediately before the first person name?

Show explained answer

Empty or unresolved. It must be initialized; there is no earlier recognized person to remember.

Try it yourself

Why can remembering a value make an algorithm faster?

Show explained answer

Later steps can reuse information from earlier visits instead of rescanning the same records. But the remembered value must still contain enough information for the actual task.

YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑