Warning: session_start(): open(/var/lib/php/sessions/sess_c3s75mlofsfagqidicceq78n8s, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
static Map> theSet;
static new HashSet allObjects;
sclass Updatable {
void update {}
}
sclass Expectation {
S ifClass;
Runnable action;
*() {}
*(S *ifClass, Runnable *action) {}
}
sclass Word extends Updatable {
S text; // or null if unknown
Word prev, next;
L constituents; // if group
new Set expectations;
new Set fulfilledExpectations;
new Set classes;
new Set groups; // I am part of
void update {
// Add direct word classes
if (text != null)
classes.addAll(reverseLookupInMapToSets(theSet, text));
}
void addExpectation(Expectation e) {
expectations.add(e);
}
}
static Word makeGroup(Word a, Word b) {
L list = ll(a, b);
// look for existing group
for (Word g : a.groups)
if (eq(g.constituents, list))
ret g;
// new group
new Word g;
allObjects.add(g);
g.constituents = list;
for (Word w : list)
w.groups.add(g);
ret g;
}
sclass The extends Word {
bool expectationSentToNext;
void update {
super.update();
if (next != null && !expectationSentToNext) {
final Word _next = next;
_next.addExpectation(Expectation("", r {
makeGroup(The.this, _next).classes.add("");
}));
set expectationSentToNext;
}
}
}
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));
addAll(allObjects, words);
S struct = struct(first(words));
do {
print("l(struct)=" + l(struct));
for (Word w : cloneList(allObjects))
w.update();
} while (eq(struct, struct(first(words))));
for (Word w : words)
printStruct(cloneWithoutFields(w, 'prev, 'next));
}
svoid linkWords(Word a, Word b) {
a.next = b;
b.prev = a;
}