Ejemplo n.º 1
0
 public static IEnumerable <string> GetRandomStringsWithoutSpaces(int n, int minLength, int maxLength, FastRandom rand)
 {
     for (int i = 0; i < n; i++)
     {
         yield return(StringValueGenerator.GetRandomStringWithoutSpaces(rand.Next(minLength, maxLength + 1), rand)); // +1 , because rand.Next is exclusive upperBound
     }
 }
 private IEnumerable <List <string> > GetRepeatedString(int n, FastRandom rand)
 {
     for (int i = 0; i < n; i++)
     {
         yield return(Enumerable.Repeat(StringValueGenerator.GetRandomString(rand.Next(1, 50), rand), 3).ToList());
     }
 }
Ejemplo n.º 3
0
        protected override IEnumerable <string> GenerateTraining()
        {
            List <string> strings = GetHardcodedTrainingSamples();

            strings.AddRange(StringValueGenerator.GetRandomStrings(68, 0, 20, rand));
            return(strings);
        }
Ejemplo n.º 4
0
        protected override IEnumerable <string> GenerateTest()
        {
            List <string> strings = StringValueGenerator.GetRandomStrings(500, 2, 2, rand).ToList(); // Random length-2 inputs

            strings.AddRange(StringValueGenerator.GetRandomStrings(500, 3, 3, rand));                // Random length-3 inputs
            strings.AddRange(StringValueGenerator.GetRandomStrings(1000, 2, 50, rand));              // Random >= 2 length inputs
            return(strings);
        }
Ejemplo n.º 5
0
 private IEnumerable <List <string> > GetRandomStringsOfStrings(int n, FastRandom rand)
 {
     for (int i = 0; i < n; i++)
     {
         int count = rand.Next(1, 50 + 1);
         yield return(StringValueGenerator.GetRandomStrings(count, 0, 50, rand).ToList());
     }
 }
Ejemplo n.º 6
0
        protected override IEnumerable <string> GenerateTraining()
        {
            List <string> strings = GetHardcodedTrainingSamples();

            strings.AddRange(GetAllLowerCaseLetters());
            strings.AddRange(GetAllUpperCaseLetters());
            strings.AddRange(StringValueGenerator.GetRandomStrings(150, 2, 20, rand));
            return(strings);
        }
Ejemplo n.º 7
0
 protected override IEnumerable <List <string> > GenerateTest()
 {
     return(StringValueGenerator.GetRandomStringsWithoutSpaces(2000, 0, 10, rand)
            .Zip(StringValueGenerator.GetRandomStringsWithoutSpaces(2000, 0, 10, rand),
                 (x, y) => new List <string>(2)
     {
         x, y
     }).ToList());
 }
Ejemplo n.º 8
0
        protected override IEnumerable <string> GenerateTraining()
        {
            List <string> strings = GetHardcodedTrainingSamples();

            strings.AddRange(StringValueGenerator.GetRandomStrings(55, 2, 2, rand));  // Random length-2 inputs
            strings.AddRange(StringValueGenerator.GetRandomStrings(50, 3, 3, rand));  // Random length-3 inputs
            strings.AddRange(StringValueGenerator.GetRandomStrings(89, 2, 50, rand)); // Random >= 2 length inputs
            return(strings);
        }
Ejemplo n.º 9
0
        protected override IEnumerable <List <string> > GenerateTraining()
        {
            List <List <string> > strings = GetHardcodedTrainingSamples();

            strings.AddRange(StringValueGenerator.GetRandomStringsWithoutSpaces(170, 2, 10, rand)
                             .Zip(StringValueGenerator.GetRandomStringsWithoutSpaces(170, 2, 10, rand),
                                  (x, y) => new List <string>(2)
            {
                x, y
            }));
            return(strings);
        }
        private List <List <string> > GetPermutationsWithTwoEmptyStrings(int n, FastRandom rand)
        {
            List <List <string> > strings = new List <List <string> >();

            for (int i = 0; i < n; i++)
            {
                int    length = rand.Next(1, 50);
                string value  = StringValueGenerator.GetRandomString(length, rand);
                strings.AddRange(GetDistinctPermutations(new string[] { String.Empty, String.Empty, value }));
            }
            return(strings);
        }
        private IEnumerable <List <string> > GetStringsInSortedLengthOrder(int n, FastRandom rand)
        {
            for (int i = 0; i < n; i++)
            {
                List <string> strings = new List <string>(3)
                {
                    StringValueGenerator.GetRandomString(rand.Next(0, 50), rand),
                    StringValueGenerator.GetRandomString(rand.Next(0, 50), rand),
                    StringValueGenerator.GetRandomString(rand.Next(0, 50), rand)
                };

                yield return(strings.OrderBy(x => x.Length).ToList());
            }
        }
        private IEnumerable <List <string> > GetStrings(int n, FastRandom rand)
        {
            for (int i = 0; i < n; i++)
            {
                List <string> strings = new List <string>(3)
                {
                    StringValueGenerator.GetRandomString(rand.Next(0, 50), rand),
                    StringValueGenerator.GetRandomString(rand.Next(0, 50), rand),
                    StringValueGenerator.GetRandomString(rand.Next(0, 50), rand)
                };

                yield return(strings);
            }
        }
Ejemplo n.º 13
0
 private IEnumerable <string> GetStringsWithSomeVowels(int n, FastRandom rand)
 {
     for (int i = 0; i < n; i++)
     {
         var value = StringValueGenerator.GetRandomStringWithOnlyPrintableCharactersWithoutUpperCaseCharacters(rand.Next(0, 20 + 1), rand).ToCharArray();
         for (int j = 0; j < value.Length; j++) // randomly add spaces with 20% probability at each position
         {
             if (rand.NextDouble() < 0.2)
             {
                 value[j] = StringValueGenerator.vowel[rand.Next(0, StringValueGenerator.vowel.Length)];
             }
         }
         yield return(new String(value));
     }
 }
Ejemplo n.º 14
0
 private IEnumerable <string> GetLetterStrings(int n, FastRandom rand)
 {
     for (int i = 0; i < n; i++)
     {
         var value = StringValueGenerator.GetRandomLowerCaseString(rand.Next(3, 50 + 1), rand).ToCharArray();
         for (int j = 0; j < value.Length; j++) // randomly add spaces with 20% probability at each position
         {
             if (rand.NextDouble() < 0.2)
             {
                 value[j] = ' ';
             }
         }
         string valueString = new String(value);
         yield return(String.Join(" ", valueString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))); // remove double spaces and spaces in the beginnig and the end of the string
     }
 }
Ejemplo n.º 15
0
        private IEnumerable <string> GetStringWithSpaces(int n, FastRandom rand)
        {
            for (int i = 0; i < n; i++)
            {
                var value = StringValueGenerator.GetRandomStringWithoutSpaces(rand.Next(2, 20 + 1), rand).ToCharArray();

                // add 20% spaces
                for (int j = 0; j < value.Length; j++)
                {
                    if (rand.NextDouble() < 0.2)
                    {
                        value[j] = ' ';
                    }
                }
                yield return(new string(value));
            }
        }
Ejemplo n.º 16
0
        private string ReplaceDropCharsAndShuffle(string original, FastRandom rand)
        {
            if (String.IsNullOrEmpty(original))
            {
                return(original);
            }

            // Replace
            var result = original.Select(x => rand.NextDouble() < 0.1 ? StringValueGenerator.GetRandomLowerCaseChar(rand) : x).ToList(); //Each char has 10% chance of being replaced

            // Shuffle
            result = result.Shuffle(rand).ToList();
            // Drop
            int drop = rand.Next(0, result.Count);

            result = result.SampleRandomWithoutRepetition(rand, result.Count - drop).ToList();
            return(new String(result.ToArray()));
        }
Ejemplo n.º 17
0
 private IEnumerable <List <string> > GetCloseOrSuperAnagrams(int n, FastRandom rand)
 {
     // string with only letters! no other symbols
     for (int i = 0; i < n; i++)
     {
         int    length = rand.Next(1, 20 + 1);
         string value0 = StringValueGenerator.GetRandomLowerCaseString(length, rand);
         string value1 = ReplaceDropCharsAndShuffle(value0, rand);
         yield return(rand.NextDouble() < 0.2 // bias towards value1 first, since value0.Length >= value1.Length
           ? new List <string>()
         {
             value0, value1
         }
           : new List <string>()
         {
             value1, value0
         });
     }
 }
Ejemplo n.º 18
0
 protected override IEnumerable <string> GenerateTest()
 {
     return(StringValueGenerator.GetRandomStrings(1000, 0, 20, rand).ToList());
 }