!752 static new Map map; static S chatName = "Assoc Bot"; p { readLocally("map"); makeAndroid3("Simplest Assoc Bot at " + getComputerID() + "."); if (chatName != null) toChat(); } static void toChat() { while (true) { pcall { for (ChatLine l : suckHumans(chatName)) sayInWebChat(chatName, answer(l.text)); } sleep(1000); } } static S lookup(S s) { ret map.get(simplify(s)); } // should simplify a sentence neatly static S simplify(S s) { S result = join(" ", codeTokensOnly(tokensToLowerCase(nlTok(s)))); print(s); print("=> " + result); ret result; } static synchronized S answer(S input) { L tok = nlTok(input); int idx = tok.indexOf("="); if (idx >= 0) { S l = join(tok.subList(0, idx)).trim(); S r = join(tok.subList(idx+1, l(tok))).trim(); l = simplify(l); S prev = map.get(l); if (prev != null && eq(simplify(prev), simplify(r))) ret "yup, i know"; map.put(l, r); saveLocally("map"); ret prev == null ? "ok, new" : "ok, changed from: " + quote(prev); } ret lookup(input); }