|
using MultiRegexSearcher;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
namespace RegexTester
{
class Program
{
static void Main(string[] args)
{
FSM NFA = GetOredRegexes();
string syt = NFA.GetDotRepresentation() + "\n";
FSM DFA = NFAToDFA.ConvertNFAToDFA(NFA);
DrawWithGraphviz(NFA, "NFA");
DrawWithGraphviz(DFA, "DFA");
}
private static void DrawWithGraphviz(FSM FSA, string fileName)
{
ProcessStartInfo info = new ProcessStartInfo();
info.Arguments = string.Format(@"-Tjpg -o C:\GraphvizOutput\{0}.jpg", fileName);
info.FileName = @"c:\Program Files (x86)\Graphviz2.34\bin\dot.exe";
info.UseShellExecute = false;
info.RedirectStandardInput = true;
using (Process proc = Process.Start(info))
{
StreamWriter sw = proc.StandardInput;
string syt = FSA.GetDotRepresentation() + "\n";
sw.Write(syt);
sw.Close();
}
}
private static FSM GetOredRegexes()
{
List<Regex> regexes = new List<Regex>();
regexes.Add(new Regex("ab*(cd|g)?"));
regexes.Add(new Regex("ab(bas|u)"));
regexes.Add(new Regex("abc(de)*"));
regexes.Add(new Regex("ab(cd|de)h*"));
regexes.Add(new Regex("a(cd)?g"));
regexes.Add(new Regex("a*b"));
FSM oredNFA = new FSM();
regexes.ForEach(regex => oredNFA |= FSM.Parse(regex.ToString()));
return oredNFA;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm a recent Msc Computer Science graduate with an interest in all things Machine Learning. I am in love with C# and having an affair with Python. My main interests in machine learning is NLP hence the Python affair. I enjoy classical music and for some reason am constantly fighting my body's call for exercise.