SECTION 12 / 24

Collect nouns immediately after adjectives

1 min read
delicious–freedom is an immediate adjective–noun pair. In dismal–yellow–building, only yellow–building is immediately adjacent.
delicious–freedom is an immediate adjective–noun pair. In dismal–yellow–building, only yellow–building is immediately adjacent.
REAL COURSE DATA · BUILD AND UNPACK LISTS

Collect nouns immediately after adjectives

Follow one occurrence at a time. Choose another input to test empty lists, repeated IDs and different parameters.

Ready

CURRENT RECORD / VALUE

Ready to begin

No records have been processed. Start with Next step.

What we remember

Processed
0

Predict the next change, then step through the list. The original course records remain unchanged.

Keep the word-card order. Let X = first(L) and Y = first(rest(L)). Select this neighbour pair only if X.PartOfSpeech is Adjective AND Y.PartOfSpeech is Noun. Append positions or a structured pair so you remember which occurrences matched.

Pairs = []
L = WordRecords
while length(L) >= 2:
    X = first(L)
    Y = first(rest(L))
    if X.PartOfSpeech == "Adjective" AND Y.PartOfSpeech == "Noun":
        Pairs = Pairs ++ [[X.SerialNumber,Y.SerialNumber]]
    L = rest(L)
PositionsAdjacent words
[21,22]delicious freedom
[50,51]yellow building;
[53,54]fire-eyed Vedanayagam,
[63,64]long cane...

The tags are given on the cards; this procedure does not solve English grammar in general. “Reluctant to” has an adjective followed by a preposition, so fails this specific test. “Dismal yellow building” has two adjectives before a noun, but dismal is not IMMEDIATELY before building. The lecture discusses that wider phrase pattern without changing the adjacent-pair rule.

Try it yourself

Should “thin” and “cane” be counted as an immediate pair in “thin long cane”?

Show explained answer

No. Long lies between them. Long–cane is the immediate adjective–noun pair.

Try it yourself

How many adjacent word pairs are tested in the 65-card paragraph?

Show explained answer

64 when all neighbours are inspected once.

Try it yourself

Why preserve SerialNumber rather than only the word spelling?

Show explained answer

The same word can occur more than once. Positions identify the actual occurrences and preserve the text sequence.

YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑