コード例 #1
0
        public void MungeIt()
        {
            //TestDensity();

            SetUp();

            // TODO: a large part of my interest is in BUILDING the sourcefile
            // allowing it to be selectable, or semi-randomized, from a given set of inputs
            // these could be source-text, online sources (stripped of HTML, possibly), or.. something

            // TODO: construct function to get a list, and randomly select sources
            // TODO: also allow for other additions, like "." frequency, etc.
            //       add in other sources, but convert the whitespace, etc.
            // this is kind of boring, actually
            // it needs some other text, inter-cut
            // with lots of extra spaces jammed into it.
            // white-space converted to periods
            // random words disemvowelled
            // and other transformations applied

            //_textCache = mg.GetRandomContents(GetXrmlPages(), 60);

            _textCache = GetSource();

            //_textCache = "abcdefghijklmnop.abc.abcd.efgh";

            //_textCache = "Once upon a time there were three bears there, once.";

            var x = new ConsoleKeyInfo();

            while (x.KeyChar != (decimal)ConsoleKey.Escape)
            {
                Console.WriteLine("Generating....\r\n\r\n");

                _textGenerator.Source = _textCache;

                _textGenerator.LengthMin = 8000;
                _textGenerator.LengthMax = 10000;
                var gen = _textGenerator.Munge();

                // this should be private
                //var gen = _textGenerator.Write(minLength: 8000, maxLength: 10000);

                gen = ApplyGranularRules(gen);
                gen = ApplyGlobalRules(gen);

                Console.WriteLine(gen);

                Console.WriteLine("\r\n\r\nPress Any Key to ReGen; ESC to exit\r\n\r\n");

                x = Console.ReadKey(true);

                if (x.KeyChar == (decimal)ConsoleKey.S)
                {
                    var outfile = GetSaveName();
                    using (var sw = new StreamWriter(outfile))
                    {
                        sw.Write(gen);
                        sw.Close();
                    }
                    Console.WriteLine(string.Format("\r\n\r\nWritten to {0}", outfile));
                }
            }
        }