Exemplo n.º 1
0
        public void AddExpression(string[] keywords, string[] responses, string[] contexts,
            ExpressionLocation location, ExpressionType type)
        {
            Expression newKey = new Expression(keywords, location, type, responses, contexts);

            AddExpression(newKey);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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;
 }
Exemplo n.º 6
0
        public void AddExpression(string[] keywords, string[] responses, string[] contexts,
                                  ExpressionLocation location, ExpressionType type)
        {
            Expression newKey = new Expression(keywords, location, type, responses, contexts);

            AddExpression(newKey);
        }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
 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;
 }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
 public void AddExpression(string[] keywords, string[] responses, string[] contexts,
                           ExpressionType type, ExpressionLocation location)
 {
     dataBase.AddExpression(keywords, responses, contexts, type, location);
 }
Exemplo n.º 11
0
 public void AddExpression(string[] keywords, string[] responses, string[] contexts,
     ExpressionType type, ExpressionLocation location)
 {
     dataBase.AddExpression(keywords, responses, contexts, type, location);
 }
Exemplo n.º 12
0
        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;
        }