public void AddExpression(string[] keywords, string[] responses, string[] contexts, ExpressionLocation location, ExpressionType type) { Expression newKey = new Expression(keywords, location, type, responses, contexts); AddExpression(newKey); }
private void AddNewExpression() { io.WriteLine("PLEASE WRITE THE NEW EXPRESION FOLLOWING THE"); io.WriteLine("THE DATABASE RULES :"); io.WriteLine("Ok. So what is the keywords that match this expression ?\nSeparate them with comas and write upper-case."); io.Write("> "); string[] keywords = io.ReadLine().Split(','); io.WriteLine("And what should I respond to that ?\nSeparate them with comas and write upper-case."); io.Write("> "); string[] resps = io.ReadLine().Split(','); io.WriteLine("In what contexts should I respond this ?\nSeparate them with comas and write upper-case."); io.Write("> "); string[] contexts = io.ReadLine().Split(','); io.WriteLine("What is this expression's type ? (1-knowledge, 2-comm.)"); ExpressionType type = io.ReadLine() == "1" ? ExpressionType.Knowledge : ExpressionType.Communication; io.WriteLine("What is this expression's location ?\nbegmid, alone, midend or irr ?"); io.Write("> "); string input = io.ReadLine(); ExpressionLocation location = input == "alone" ? ExpressionLocation.Alone : input == "begmid" ? ExpressionLocation.BeginOrMiddle : input == "medend" ? ExpressionLocation.MiddleOrEnd : ExpressionLocation.IsIrrelevant; Expression expr = new Expression(keywords, location, type, resps, contexts); database.AddExpression(expr, true); }
public void AddExpression(string[] keywords, string[] responses, string[] contexts, ExpressionType type, ExpressionLocation location, bool changer = false) { Expression newExpression = new Expression(keywords, location, type, responses, contexts); AddExpression(newExpression, changer); }
public ExpressionLocationRange( ExpressionLocation start, ExpressionLocation end) { this.Start = start; this.End = end; }
public Expression(string[] keywords, ExpressionLocation location, ExpressionType type, string[] responses, string[] contexts) { this.Type = type; this.Keywords = keywords; this.Location = location; this.Responses = responses; this.Contexts = contexts; }
private bool WrongLocation(string keyword, ExpressionLocation exprLocation, int pos) { if (exprLocation == ExpressionLocation.IsIrrelevant) { return(false); } bool isNotAlone = exprLocation == ExpressionLocation.Alone && userInput != keyword; bool isNotMiddle = exprLocation == ExpressionLocation.MiddleOrEnd && pos != userInput.Length; bool isNotBegin = exprLocation == ExpressionLocation.BeginOrMiddle && pos == userInput.Length; return(isNotAlone || isNotMiddle || isNotBegin); }
public void AddExpression(string[] keywords, string[] responses, string[] contexts, ExpressionType type, ExpressionLocation location) { dataBase.AddExpression(keywords, responses, contexts, type, location); }
private bool WrongLocation(string keyword, ExpressionLocation exprLocation, int pos) { if (exprLocation == ExpressionLocation.IsIrrelevant) return false; bool isNotAlone = exprLocation == ExpressionLocation.Alone && userInput != keyword; bool isNotMiddle = exprLocation == ExpressionLocation.MiddleOrEnd && pos != userInput.Length; bool isNotBegin = exprLocation == ExpressionLocation.BeginOrMiddle && pos == userInput.Length; return isNotAlone || isNotMiddle || isNotBegin; }