コード例 #1
0
        public static void Process(string delimeters, string otherDelimeters,
                                   string article, string[] words, string abbreviations,
                                   string basePath, string outputFilename)
        {
            var wordHunter = new WordHunter
            {
                Article         = article,
                Words           = words,
                Delimeters      = delimeters,
                Abbreviations   = abbreviations.Split(","),
                OtherDelimeters = otherDelimeters
            };

            var   sentences = wordHunter.GetSentences();
            short result    = wordHunter.FindAndCount(sentences);

            if (result < 0)
            {
                SetPreProcessingException(result);
                Console.WriteLine("There was a problem in word finder processing.");
            }

            try
            {
                var outputWriter = new OutputWriter(wordHunter.FoundWords, outputFilename);

                outputWriter.FilePath = basePath;
                outputWriter.GenerateResult();
                if (outputWriter.Results.Length > 0)
                {
                    outputWriter.Write();
                    Console.WriteLine("Word Finder Processing Completed..");
                    return;
                }

                FindOrAddError("Err6", "There was no results generated.");
            }
            catch (Exception)
            {
                FindOrAddError("Err7", "Writing output file failed.");
            }
        }