public bool AddMemory(string x) { var nearChat = Chatbot.SingletonClassify(memory, x, gram); string near = (nearChat != null ? nearChat.text : ""); if (Chatbot.Similarity(near, x, gram) > nearEPS) //记忆体已经有相似的东西 { return(false); } ChatData t = new ChatData(x, DateTime.Now); memory.Add(t); return(true); }
public void handleInput(string text) { text = Regex.Replace(text, @"[\n\r]+", ""); messageRecord.Add(text); string ans = ""; textBox2.AppendText(text + Environment.NewLine); int cnt = 0; do { if (cnt > 0) { text = text + "<NEXT>"; } ans = bot.BotInput(text) + Environment.NewLine; textBox2.AppendText(ans); cnt++; if (cnt > 5) { break; } } while (Chatbot.GetToken(ans, "<NEXT>").CompareTo("<NOTFOUND>") != 0); }
private void Form1_Load(object sender, EventArgs e) { bot = new Chatbot(); ActiveControl = textBox1; }