Warning: session_start(): open(/var/lib/php/sessions/sess_ak7uu7e0jqg294vb2jvsgdodr8, 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
p {
callAnswerFunctionVerbose("tell me what time it is");
callAnswerFunctionVerbose("Can you tell me what time it is?");
botSleep();
}
sclass TokConsumer {
L l;
int i;
*(L *l) {}
S peek() { ret get(l, i); }
S next() { ret get(l, i++); }
L remainingTokens() { ret subList(l, i); }
}
sS answer(S s) {
ret group(s);
}
sS group(S s) {
s = groupStep(s);
L tok = joinBrackets(javaTok(s));
for (int i = 1; i < l(tok); i += 2) {
S t = tok.get(i);
if (isRoundBracketed(t))
tok.set(i, "(" + group(dropFirstAndLast(t)) + ")");
}
ret join(tok);
}
sS groupStep(S s) {
L tok = codeTokens(dropPunctuation(javaTok(s)));
TokConsumer c = new(tok);
S verb = consumeVerb(c);
if (verb != null) {
S noun = consumeNoun(c);
if (noun != null)
ret group(verb, noun, rest(c));
}
ret joinWithSpace(tok);
}
static Set verbs = asSet(splitAtSpace("can does will tell would were do"));
static Set nouns = asSet(splitAtSpace("i you he she it we someone me"));
static S consumeVerb(TokConsumer c) {
ret consumeFromList(verbs, c);
}
static S consumeNoun(TokConsumer c) {
ret consumeFromList(nouns, c);
}
static S consumeFromList(Set set, TokConsumer c) {
if (set.contains(toLower(c.peek())))
ret c.next();
null;
}
sS group(S... parts) {
new L l;
for (S part : parts) {
L tok = javaTokC(part);
if (l(tok) > 1)
l.add("(" + joinWithSpace(tok) + ")");
else
l.addAll(tok);
}
ret joinWithSpace(l);
}
sS rest(TokConsumer c) {
ret joinWithSpace(c.remainingTokens());
}