Ejemplo n.º 1
0
        private string Munge(string source)
        {
            // split by LINES
            // go through each line, random offset

            var result = Regex.Split(source, "\r\n|\r|\n");
            var sb     = new StringBuilder();

            foreach (var line in result)
            {
                if (line.Length > 0) // don't waste energy on empty lines. but do preserve them
                {
                    var op = TransformerTools.GetPercentage();
                    if (op <= ProbabilityOffset)
                    {
                        // TODO: add to TransformerTools ???
                        var variance = _rnd.Next(-OffsetVariance, OffsetVariance);
                        var spaceNbr = Offset + variance;
                        var spaces   = new string(' ', spaceNbr);
                        sb.Append(spaces);
                    }
                }
                sb.Append(line).Append(Environment.NewLine); // invariant
            }

            return(sb.ToString());
        }
Ejemplo n.º 2
0
        private string Munge(string source)
        {
            var words = new TextTokenizer(Granularity.Word, source).Tokens;
            var sb    = new StringBuilder();

            foreach (var word in words)
            {
                sb.Append(word);
                var newline = TransformerTools.GetPercentage();
                if (newline <= ProbabilityNewLine)
                {
                    var lines = 1;
                    var mult  = TransformerTools.GetPercentage();
                    if (mult <= ProbabilityMultiple)
                    {
                        lines += _rnd.Next(0, MultipleRange);
                    }

                    for (int i = 0; i < lines; i++)
                    {
                        sb.Append(Environment.NewLine);
                    }
                }
                else
                {
                    // random number of spaces ?
                    sb.Append(" ");
                }
            }

            return(sb.ToString());
        }
Ejemplo n.º 3
0
        private string Munge(string source)
        {
            var c = source.ToLower().ToCharArray();

            for (var i = 0; i < c.Length; ++i)
            {
                if (TransformerTools.GetPercentage() > 50)
                {
                    c[i] = c[i].ToString().ToUpper().ToCharArray()[0];
                }
            }

            return(new string(c));
        }