Warning: session_start(): open(/var/lib/php/sessions/sess_i6o1u83qglkdclbm94vjn8t1se, 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
!752
concepts.
concept WithTime {
new Ref sentence;
new Ref time;
}
concept Possession {
new Ref x; // e.g. "your"
new Ref y; // e.g. "car"
}
// e.g. someone's girl
concept Possession2 {
new Ref x; // e.g. "someone"
new Ref y; // e.g. "girl"
}
concept Sentence {}
Sentence > SPO {
new Ref s; // subject
new Ref p; // predicate
new Ref o; // object
static S _fieldOrder = "s p o";
*() {}
*(Concept s, Concept p, Concept o) {
this.s.set(s);
this.p.set(p);
this.o.set(o);
}
}
p {
testParse("I've been here today");
testParse("I've been your friend today");
testParse("I've been his bimbo today");
testParse("I've been this dude's girl today");
}
svoid testParse(S s) {
print("** \* s */ **");
print();
new L l;
parse(s, listCollector(l));
for i over l:
print((i+1) + ". " + structureConcept(l.get(i)));
for (Concept c : iterateOptions(l)) {
if (properSentence(c)) {
print("First proper sentence: " + structureConcept(c));
break;
}
}
print();
}
static Concept parseToOptions(S s) {
new L l;
parse(s, listCollector(l));
ret options(l);
}
static L poss = splitAtSpace("my your his her their our");
static void parse(S s, Collector out) {
new Matches m;
if (flexMatchIC("* today", s, m))
ret if out.add(cnew(WithTime,
sentence := parseToOptions($1),
time := concept("today")));
if (flexMatchStartIC(poss, s, m))
ret if out.add(cnew(Possession,
x := cstr($1),
y := parseToOptions($2)));
L tok = javaTok(s);
int i = indexOfEndsWith(tok, "'s");
if (i >= 0) {
S left = join(subList(tok, 0, i)) + dropSuffix("'s", tok.get(i));
S right = join(subList(tok, i+2));
ret if out.add(cnew(Possession2,
x := parseToOptions(left), y := parseToOptions(right)));
}
if (flexMatchIC("I've been *", s, m))
ret if out.add(
new SPO(cstr("I"),
cstr("have been"),
parseToOptions($1)));
out.add(cstr(s)); // default
}
static Concept firstOfFirst(Concept c) {
ret conceptGraphMap_aggressive(c, func(Concept c) {
c << Options ? first(c/Options) : c
});
}
sbool properSentence(Concept c) {
ret c << Sentence
|| c << WithTime && properSentence(c/WithTime.sentence!);
}
static Iterable iterateOptions(L l) {
ret mapI(l, func(Concept c) { firstOfFirst(c) });
}