Beispiel #1
0
        public static string InsertRandomTypo(string s)
        {
            List <char> list = s.ToList <char>();

            if (LexiconClass.rand.Next(0, 5) == 0 && list.Count > 0)
            {
                int index = LexiconClass.rand.Next(0, s.Length);
                switch (LexiconClass.rand.Next(0, 3))
                {
                case 0:
                    list.RemoveAt(index);
                    break;

                case 1:
                    list.Insert(index, LexiconClass.RandChar());
                    s = new string(list.ToArray());
                    break;

                case 2:
                    list[index] = LexiconClass.RandChar();
                    s           = new string(list.ToArray());
                    break;
                }
            }
            return(new string(list.ToArray()));
        }