internal static void CalculateTimeOfRecognise(string filePath, Grammar grammar, List <String> inputList) { List <Result> results = new List <Result>(); MarpaParser recogniser = new MarpaParser(grammar); inputList.ForEach(input => { Stopwatch timePerParse = Stopwatch.StartNew(); RecogniseReport result = recogniser.CheckString(input); timePerParse.Stop(); long mstime = timePerParse.ElapsedTicks; if (result.isSuccessfull && result.isRecognised) { results.Add(new Result(input, mstime)); } }); FileWorker.WriteMultipleDataToCSVFile(filePath, results); }
internal static Grammar GetGrammarFromFile(string filePath) { Grammar grammar = new Grammar(); List <string> fileLines = FileWorker.GetLinesFromXMLFile(filePath); fileLines.ForEach(line => { if (line.Contains("->")) { grammar.AddRule(GetRuleFromTextLine(line)); } if (line.Contains("start:")) { grammar.SetStartSym(line.Replace("start:", "").Trim()); } if (line.Contains("null:")) { grammar.SetNullStringSymbol(line.Replace("null:", "").Trim()); } }); return(grammar); }
internal static List <String> GetListOfInputs(string filePath) { return(FileWorker.GetLinesFromXMLFile(filePath)); }