sclass AI_WhatIsBot > AttractorBot { IDefinitions definitionsModule; public void run { say("I can learn and tell you what things are"); } // CONFIG class WhatIsAttractor > Attractor { S term; public bool matches(S s) { new Matches m; if "what is ..." ret true with term = $1; false; } public void run { if (definitionsModule != null) { Collection defs = definitionsModule.getDefinitions(term); if (nempty(defs)) { say(term + " is " + random(defs)); // TODO: attractors ret; } } say("I don't know. What is " + quote(term) + "?"); lowPrioAttractor(new DefinitionAttractor(term)); } } record DefinitionAttractor(S term) extends Attractor { S value; public bool matches(S s) { new Matches m; if "it's ...|it is...|he is...|she is..." ret true with value = $1; false; } public void run { say("OK. " + term + " is " + value + "."); if (definitionsModule != null) definitionsModule.addDefinition(term, value); } } *() { standardAttractors(new WhatIsAttractor); } }