!752 !include #1004972 // Text AI Include concepts. concept Question extends Interpretation {} concept HowManyMonthsInYear extends Question { int year; } concept NumberOfMonthsInYear { new Ref question; int year, months; } static Concept answerQuestion(Question q) { if (q instanceof HowManyMonthsInYear) { sleepSeconds(1); new NumberOfMonthsInYear a; a.question.set(q); copyFields(q, a, "year"); a.months = 12; // The answer! change(); ret a; } null; // unknown question } static S renderAnswer(Concept a) { if (a instanceof NumberOfMonthsInYear) { NumberOfMonthsInYear aa = cast a; ret "There are " + n(aa.months, "month") + " in the year " + aa.year + "."; } null; } static S dbName; p { dbName = fsI(programID()); loadAndAutoSaveConcepts(); makeBot("Calendar AI 1."); methodsBot(dbName, listPlus(exposedDBMethods, "xfindLine")); initConsole(); print("AI ready to rock. Go \"Admin\" to see my commands."); //kevin("Hello"); print(); } static S answerInterpreted(S s, Interpretation ip) { if (ip instanceof Question) { Concept a = answerQuestion((Question) ip); if (a == null) ret "No idea"; else { S text = renderAnswer(a); if (nempty(text)) ret text; ret "I have an answer, but don't know how to tell you unfortunately"; } } null; } svoid admin {}