Пример #1
0
        public void Test11()
        {
            //Arrange
            String[] param = { /*"-q"*/ };  // suppressing informational and banner messages
            Core.AdeSystem.Initialize(param);

            Core.AdeSystem.Initialize(param);
            Core.AdeSystem.LoadDomain(LighbulbsProblem);
            Core.AdeSystem.ConstructSystemDomain();
            //Act
            var query  = new AlwaysInvolvedQuery("always involved Mietus in TURNTWO, TURNONE by epsilon,epsilon");
            var result = query.ToProlog();

            //Assert
            Assert.AreEqual(result, FalseString);

            PlEngine.PlCleanup();
        }
        public void Test17()
        {
            //Arrange
            String[] param = { /*"-q"*/ };  // suppressing informational and banner messages
            Core.AdeSystem.Initialize(param);

            Core.AdeSystem.Initialize(param);
            Core.AdeSystem.LoadDomain(YaleProblem);
            Core.AdeSystem.ConstructSystemDomain();

            //Act
            var query  = new AlwaysInvolvedQuery("always involved Hador in SHOOT,SHOOT,ENTICE by Hador,Mietus,Hador");
            var result = query.ToProlog();

            //Assert
            Assert.AreEqual(result, FalseString);

            PlEngine.PlCleanup();
        }
Пример #3
0
        public static string ParseQuery(string query)
        {
            query = query.ToLower();
            Query q = null;

            try
            {
                if (query.Contains("always accessible"))
                {
                    q = new AlwaysAccessibleQuery(query);
                }
                else if (query.Contains("always") && query.Contains("after"))
                {
                    q = new AlwaysAfterQuery(query);
                }
                else if (query.Contains("always executable"))
                {
                    q = new AlwaysExecutableQuery(query);
                }
                else if (query.Contains("always involved"))
                {
                    q = new AlwaysInvolvedQuery(query);
                }
                else if (query.Contains("possibly accessible"))
                {
                    q = new PossiblyAccessibleQuery(query);
                }
                else if (query.Contains("possibly") && query.Contains("after"))
                {
                    q = new PossiblyAfterQuery(query);
                }
                else if (query.Contains("possibly executable"))
                {
                    q = new PossiblyExecutableQuery(query);
                }
                else if (query.Contains("possibly involved"))
                {
                    q = new PossiblyInvolvedQuery(query);
                }
                else if (query.Contains("typically accessible"))
                {
                    q = new TypicallyAccessibleQuery(query);
                }
                else if (query.Contains("typically") && query.Contains("after"))
                {
                    q = new TypicallyAfterQuery(query);
                }
                else if (query.Contains("typically involved"))
                {
                    q = new TypicallyInvolvedQuery(query);
                }
            }
            catch (ArgumentOutOfRangeException e)
            {
                return("Error parsing  in query - " + query);
            }
            try
            {
                if (q != null)
                {
                    return(q.ToProlog());
                }
            }
            catch (Exception)
            {
                throw new Exception("Error in executing query - " + query);
            }
            return("Query not recognized");
        }