private static void Main(string[] args)
        {
            const string path  = @"D:\PWr\magisterskie\magisterka\Teksty\";
            const string pathR = @"D:\PWr\magisterskie\magisterka\Raporty\";
            var          path1 = "";
            var          path2 = "";
            var          path3 = "";

            for (var index = 0; index < args.Length; index++)
            {
                var argument = args[index];
                switch (argument)
                {
                case "-i":
                    if (index + 1 < args.Length)
                    {
                        index++;
                        path1 = args[index] + ".txt";
                    }
                    break;

                case "-o":
                    if (index + 1 < args.Length)
                    {
                        index++;
                        path2 = args[index];
                    }
                    break;

                case "-io":
                    if (index + 1 < args.Length)
                    {
                        index++;
                        path3 = args[index] + ".txt";
                    }
                    break;

                case "-n1":
                    Settings.Type = NgramType.Unigram;
                    break;

                case "-n2":
                    Settings.Type = NgramType.Bigram;
                    break;

                case "-n3":
                    Settings.Type = NgramType.Trigram;
                    break;

                case "-n4":
                    Settings.Type = NgramType.Quadrigram;
                    break;

                case "-udt":
                    Settings.UseDictionary = true;
                    break;

                case "-udf":
                    Settings.UseDictionary = false;
                    break;

                case "-att":
                    Settings.AlphabeticalTables = true;
                    break;

                case "-atf":
                    Settings.AlphabeticalTables = false;
                    break;

                case "-sst":
                    Settings.SentenceSpliterOn = true;
                    break;

                case "-ssf":
                    Settings.SentenceSpliterOn = false;
                    break;

                case "-ipt":
                    Settings.IgnorePunctationMarks = true;
                    break;

                case "-ipf":
                    Settings.IgnorePunctationMarks = false;
                    break;

                case "-m1":
                    Settings.NoOfMethod = 0;
                    break;

                case "-m2":
                    Settings.NoOfMethod = 1;
                    break;

                case "-db":
                    if (index + 1 < args.Length)
                    {
                        index++;
                        Settings.DbName = args[index];
                    }
                    break;

                case "-tab":
                    if (index + 4 < args.Length)
                    {
                        index++;
                        Settings.TableNames[0] = args[index];
                        index++;
                        Settings.TableNames[1] = args[index];
                        index++;
                        Settings.TableNames[2] = args[index];
                        index++;
                        Settings.TableNames[3] = args[index];
                    }
                    break;
                }
            }

            Initialize();

            if (path1 == "" || path2 == "")
            {
                Console.Write($"Podaj ścieżkę do tekstu: {path}");
                path1 = Console.ReadLine() + ".txt";
                Console.Write($"Podaj ścieżkę zapisu raportu: {pathR}");
                path2 = Console.ReadLine();
            }

            var pathRep = $"{path2}-report.txt";
            var pathOut = $"{path2}-output.txt";

            try
            {
                string   text;
                string[] reports;

                File.WriteAllText(pathR + pathRep, GenerateDescription());

                using (var sr = new StreamReader(path + path1))
                {
                    text = sr.ReadToEnd();
                }

                _originalText = TextSpliter.Split(text).ToList();
                text          = text.RemoveDiacritics();
                _inputText    = TextSpliter.Split(text).ToList();

                if (path3 != "")
                {
                    using (var sr = new StreamReader(path + path3))
                    {
                        var outputText = sr.ReadToEnd();
                        _outputText = TextSpliter.Split(outputText).ToList();
                        var result = TextSpliter.SplitAndKeep(outputText).ToList();
                        var times  = new List <TimeSpan>();
                        for (var i = 0; i < 10; ++i)
                        {
                            _start = _stop = DateTime.Now;
                            times.Add(_stop - _start);
                        }
                        var counts = new List <int> {
                            0, 0, 0, 0, 0, 0, 0, 0, 0
                        };
                        reports = Research(times, counts, result);
                    }
                }
                else
                {
                    var result = Analyze(text, out var times, out var counts);
                    reports = Research(times, counts, result);
                }

                //Console.Write($"\r\n{reports[0]}\r\n Tekst wynikowy:\r\n{reports[1]}");
                File.AppendAllText(pathR + pathRep, reports[0]);
                File.WriteAllText(pathR + pathOut, reports[1]);
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("Brak pliku z danymi");
            }


            Console.Write("\r\n");
            //Console.Read();
        }
示例#2
0
 public int SetWords(string text)
 {
     Input = TextSpliter.Split(text).ToList();
     InputWithWhiteMarks = TextSpliter.SplitAndKeep(text).ToList();
     return(Input.Count());
 }