Exemplo n.º 1
0
        public void FileParsingTest()
        {
            var currentLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;
            var currentPath     = System.IO.Path.GetDirectoryName(currentLocation);
            var testFile        = System.IO.Path.Combine(currentPath, "TestArtifacts\\test.txt");


            var output = BigramParsing.ParseFile(testFile).GetAwaiter().GetResult();

            var correct = @"sit amet: 61
aliquam erat: 8
erat volutpat: 8";

            Assert.IsTrue(output.StartsWith(correct));
        }
Exemplo n.º 2
0
        private async void Parse_button_click(object sender, EventArgs e)
        {
            var fileInput = FileInput_radio.Checked;
            var textInput = TextInput_radio.Checked;
            var input     = Input_text.Text;

            var output = "";

            if (string.IsNullOrWhiteSpace(input))
            {
                output = "Please provide input before attempting to parse";
            }
            else if (fileInput)
            {
                try
                {
                    if (!System.IO.File.Exists(input))//consider moving file handling to it's own service
                    {
                        output = "File could not be found.";
                    }
                    //possibly check file permissions
                    //if this was a public job I'd want to put in file sniffing functionality to respond to that in a more controlled fashion
                    else
                    {
                        output = await BigramParsing.ParseFile(input);
                    }
                }
                catch (Exception ex)
                {
                    output = "Could not process the file.\r\nSee error message below.\r\n" + ex.Message;
                }
            }
            else if (textInput)
            {
                output = await ParsingService.Services.BigramParsing.ParseText(input);
            }

            Output_text.Text = output;
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            if (!args.Any())
            {
                Console.WriteLine("No input provided.");
                Console.ReadLine();
                return;
            }
            if (args.Count() > 1)
            {
                Console.WriteLine("Please use quotes to contain input.");
                Console.ReadLine();
                return;
            }

            var input = args.First();

            var output = "";

            try {
                if (!System.IO.File.Exists(input)) //consider moving file handling to it's own service
                {
                    output = BigramParsing.ParseText(input).GetAwaiter().GetResult();
                }
                ////possibly check file permissions
                else
                {
                    output = BigramParsing.ParseFile(input).GetAwaiter().GetResult();
                }
            }
            catch (Exception ex)
            {
                output = "Could not process the file.\r\nSee error message below.\r\n" + ex.Message;
            }

            Console.WriteLine(output);
            Console.ReadLine();
        }