static void Main(string[] args) { // Usage: iengine method filename // Methods: TT / FC / BC // New Usage: // iengine method filename (Any triggers GUI) bool guiEnabled = false; if (args.Length < 1) { throw new Exception("Not enough arguments! Usage: iengine [Method] [Filename] [GUI: Yes/No]"); } if (args.Length > 2) { guiEnabled = true; } // Create modules and assign connections TextParser parser = new TextParser(args[1]); Console.WriteLine($"ASK: {parser.Ask} | TELL: {parser.Tell}"); KnowledgeBase KB; switch (args[0].ToLower()) { case "bc": KB = new BackwardChaining(parser.Ask, parser.Tell); break; case "fc": KB = new ForwardChaining(parser.Ask, parser.Tell); break; default: KB = new TruthTable(parser.Ask, parser.Tell); break; } Console.WriteLine($"KB Output: {KB.Execute()}"); if (guiEnabled) { SFMLView _view = new SFMLView(ref KB); while (!_view.IsFinished) { _view.Draw(); } _view.Close(); } }
static void Main(string[] args) { //Get Arguments from Command Line String[] arguments = Environment.GetCommandLineArgs(); string method = arguments[1]; //Name of the method to be used string filename = arguments[2]; //Name of the file to be used //FOR TESTING PURPOSES //string method = "TT"; //string filename = "test8.txt"; InferenceEngine IE; //InferenceEngine object to be used //Initiate the correct Inference Engine according to input paramaters switch (method) { //Truth Table checking case "TT": IE = new TruthTable(filename); break; //Forward Chaining case "FC": IE = new ForwardChaining(filename); break; //Backward Chaining case "BC": IE = new BackwardChaining(filename); break; default: IE = null; break; } //If Inference Engine Initiated, get results if (IE != null) { //If Inference Engine returns a result, print it out if (IE.getInference() == true) { Console.WriteLine("YES: " + IE.getResult()); } //If Inference engine doesn't return a result, print "NO" else { Console.WriteLine("NO"); } } }
public static void Main(string[] args) { // Main Input Arguments // // args[0] inference method // // args[1] filename // String fileName = "default"; String inference = "default"; Boolean Debug = false; if (args.Length < 2) { Console.WriteLine("ERROR: NOT ENOUGH INPUT PARAMETERS"); return; } else if (args.Length == 2) { inference = args [0]; fileName = args [1]; } else if (args.Length == 3) { inference = args [0]; fileName = args [1]; if (args[2] == "DEBUG") { Debug = true; } } else { Console.WriteLine("ERROR: TOO MANY INPUT PARAMETERS"); return; } if (Debug) { Console.WriteLine("Program begin"); } //String inference = args[0]; //String fileName = args [1]; // debugging stuff for 3rd argument, error checking in input? Parser P = new Parser(); InferenceType iEngine; List <HornClauseClass> parsedKB = P.GetKB(fileName); QueryClass parsedQuery = new QueryClass(P.GetQuery(fileName)); switch (inference) { case "TT": iEngine = new TruthTableClass(parsedKB, parsedQuery); break; case "FC": iEngine = new ForwardChaining(parsedKB); break; case "BC": iEngine = new BackwardChaining(parsedKB); break; default: Console.WriteLine("Inference Type code invalid"); return; } String Result = iEngine.EvaluateQuery(parsedQuery, Debug); Console.WriteLine(Result); }
static int Main(string[] args) { if (args.Count() != 2) { Console.WriteLine("ERROR: incorrect arguments"); #if DEBUG Console.ReadLine(); //stops the console from closing #endif return(1); } string method = args[0]; string filename = args[1]; KnowledgeBase knowledgeBase = new KnowledgeBase(); string query = ""; try { if (!ParseFile(filename, ref knowledgeBase, ref query)) { Console.WriteLine("ERROR: incorrect file format"); #if DEBUG Console.ReadLine(); //stops the console from closing #endif return(2); } } catch (Exception ex) { Console.WriteLine("ERROR: {0}", ex.Message); #if DEBUG Console.ReadLine(); //stops the console from closing #endif return(3); } Result result; try { switch (method) { case "TT": result = TruthTableChecking.TT(knowledgeBase, query); break; case "FC": result = ForwardChaining.FC(knowledgeBase, query); break; case "BC": result = BackwardChaining.BC(knowledgeBase, query); break; default: Console.WriteLine("ERROR: invalid method provided"); #if DEBUG Console.ReadLine(); //stops the console from closing #endif return(4); } } catch (System.Exception ex) { Console.WriteLine("ERROR: {0}", ex.Message); #if DEBUG Console.ReadLine(); //stops the console from closing #endif return(5); } if (result.Success) { string second; if (result.Symbols is null) { second = result.Count.ToString(); } else { second = string.Join(", ", result.Symbols); } Console.WriteLine("YES: {0}", second); } else { Console.WriteLine("NO"); } #if DEBUG Console.ReadLine(); //stops the console from closing #endif return(0); }