!7 static Map> theSet; sclass Expectation { } sclass Word { S text; // or null if unknown Word prev, next; new Set expectations; new Set classes; void update { // Add direct word classes if (text != null) classes.addAll(reverseLookupInMapToSets(theSet, text)); } } sclass The extends Word { } p-exp { S sentence = "In the movies Dracula always wears a cape"; L rawWords = printStruct(words(sentence)); theSet = ai_englishWordCategoriesWithElements(); new L words; for (S w : rawWords) words.add(nu(eqic(w, "the") ? The : Word, text := w)); for (int i = 0; i < l(words)-1; i++) linkWords(words.get(i), words.get(i+1)); //printStruct(first(words)); for (Word w : words) w.update(); for (Word w : words) printStruct(cloneWithoutFields(w, 'prev, 'next)); } svoid linkWords(Word a, Word b) { a.next = b; b.prev = a; }