public static ParseVataFile ( string pathFN ) : TreeTransducer | ||
pathFN | string | |
Результат | TreeTransducer |
public static void RunTest() { DirectoryInfo detDir = new DirectoryInfo(pathDet); FileInfo[] detFiles = detDir.GetFiles("*"); int numFiles = detFiles.Length; HashSet <int> detFileNames = new HashSet <int>(); foreach (var f in detFiles) { detFileNames.Add(int.Parse(f.Name)); } DirectoryInfo compDir = new DirectoryInfo(pathComp); FileInfo[] compFiles = compDir.GetFiles("*"); HashSet <int> compFileNames = new HashSet <int>(); foreach (var f in compFiles) { compFileNames.Add(int.Parse(f.Name)); } if (startFile == 1) { using (System.IO.StreamWriter outfile = new System.IO.StreamWriter(Program.path + Program.timbukFile)) { outfile.WriteLine("ID, StateCount, RuleCount, CompleteRuleCount, MinStateCount, MinRuleCount, Algo1, Algo2, SFABased"); } } for (int fileNum = startFile; fileNum <= maxFile; fileNum++) { Console.WriteLine(fileNum); TreeTransducer detAut = null; if (detFileNames.Contains(fileNum)) { detAut = VataParsing.ParseVataFile(pathDet + fileNum); } TreeTransducer compAut = null; if (compFileNames.Contains(fileNum)) { compAut = VataParsing.ParseVataFile(pathComp + fileNum); } Util.RunAllAlgorithms(detAut, compAut, fileNum.ToString(), Program.timbukFile); } }
public static void SanityCheck() { DirectoryInfo detDir = new DirectoryInfo(pathDet); FileInfo[] detFiles = detDir.GetFiles("*"); int numFiles = detFiles.Length; HashSet <int> detFileNames = new HashSet <int>(); foreach (var f in detFiles) { detFileNames.Add(int.Parse(f.Name)); } DirectoryInfo compDir = new DirectoryInfo(pathComp); FileInfo[] compFiles = compDir.GetFiles("*"); HashSet <int> compFileNames = new HashSet <int>(); foreach (var f in compFiles) { compFileNames.Add(int.Parse(f.Name)); } for (int fileNum = startFile; fileNum <= numFiles; fileNum++) { Console.WriteLine(fileNum); TreeTransducer detAut = null; if (detFileNames.Contains(fileNum)) { detAut = VataParsing.ParseVataFile(pathDet + fileNum); } var min1 = detAut.Minimize(); var min2 = detAut.MinimizeViaSFA(); Console.WriteLine("StatesMin:"); Console.WriteLine(detAut.StateCount + " " + min1.StateCount + " " + min2.StateCount); Console.WriteLine("TransMin:"); Console.WriteLine(detAut.RuleCount + " " + min1.RuleCount + " " + min2.RuleCount); //if (!min1.Complement().Intersect(min2).IsEmpty) // Console.WriteLine("Should be empty!"); //if (!min2.Complement().Intersect(min1).IsEmpty) // Console.WriteLine("Should be empty!"); } }
public static void GenerateTests() { HashSet <Tuple <int, int> > alreadyFound = new HashSet <Tuple <int, int> >(); DirectoryInfo detDir = new DirectoryInfo(pathDet); int fileName = detDir.GetFiles().Length + 1; foreach (var suff in suffs) { DirectoryInfo d = new DirectoryInfo(path + suff + @"\"); FileInfo[] Files = d.GetFiles("*"); foreach (FileInfo file in Files) { Console.WriteLine(suff + @"\" + file.Name); var aut = VataParsing.ParseVataFile(path + suff + @"\" + file.Name); if (aut != null) { Console.WriteLine(aut.StateCount + " " + aut.RuleCount); if (aut.StateCount < 301 || aut.RuleCount < 3407) { var stTr = new Tuple <int, int>(aut.StateCount, aut.RuleCount); if (!alreadyFound.Contains(stTr)) { alreadyFound.Add(stTr); var tokenSource = new CancellationTokenSource(); CancellationToken token = tokenSource.Token; TreeTransducer detAut = null; var task = Task.Factory.StartNew(() => { aut.IsDeterminstic(); detAut = aut.DeterminizeWithoutCompletion().RemoveUselessStates(); }, token); if (!task.Wait(Program.timeOut, token)) { Console.WriteLine("The determinization Task timed out!"); } else { var outstring = VataParsing.GetVataFormatString(detAut); VataParsing.ParseVataFormat(outstring); using (System.IO.StreamWriter outfile = new System.IO.StreamWriter(pathDet + fileName)) { outfile.Write(outstring); fileName++; } if (detAut.InputAlphabet.MaxRank < 6 && detAut.RuleCount < 4000) { TreeTransducer completeAut = null; CancellationToken token2 = tokenSource.Token; var task2 = Task.Factory.StartNew(() => { completeAut = aut.Determinize(); }, token2); if (!task2.Wait(Program.timeOut, token2)) { Console.WriteLine("The completion Task timed out!"); } else { outstring = VataParsing.GetVataFormatString(completeAut); VataParsing.ParseVataFormat(outstring); using (System.IO.StreamWriter outfile = new System.IO.StreamWriter(pathComp + (fileName - 1))) { outfile.Write(outstring); } } } else { Console.WriteLine(detAut.RuleCount + " rules, skip completion"); } } } } } } } }
public static string FromTimbukToDTAMIN(string pathFN) { var sta = VataParsing.ParseVataFile(pathFN); return(GetDTAMINFormatString(sta)); }