Пример #1
0
        public void Test05()
        {
            //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 PossiblyAfterQuery("possibly !sone&!stwo after TURNTWO,TURNONE by epsilon,epsilon from sone&stwo");
            var result = query.ToProlog();

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

            PlEngine.PlCleanup();
        }
Пример #2
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");
        }