Ejemplo n.º 1
0
 protected ValidatorBase(InputSettings inputSettings,
                         IEnumerable<VocabularyItem> vocabulary,
                         IEnumerable<string> prefixes)
 {
     _inputSettings = inputSettings;
     _vocabulary = vocabulary;
     _prefixes = prefixes;
 }
        public static IList<string> GeneratePrefixes(InputSettings settings)
        {
            var prefixes = new List<string>(settings.PrefixesNumber);

            for (int i=0; i < settings.PrefixesNumber; i++)
                prefixes.Add(GenerateOneWord(settings.PrefixMaxLength));

            return prefixes;
        }
        public static IEnumerable<VocabularyItem> GenerateVocabulary(InputSettings settings)
        {
            var words = new HashSet<string>();
            while (words.Count < settings.VocabularySize)
                words.Add(GenerateOneWord(settings.WordMaxLength));

            Func<int> genOccurrence = () => _st_random.Next(settings.WordMaxOccurrences + 1);
            return words
                   .Select(word => new VocabularyItem(word, genOccurrence()))
                   .ToArray();
        }
        public void MaxLoadAveragePrefixesTest()
        {
            var settings = new InputSettings()
            {
                VocabularySize = 100000,
                WordMaxLength = 15,
                WordMaxOccurrences = 1000000,
                PrefixesNumber = 15000,
                PrefixMaxLength = 6
            };

            TestOneSettings(settings);
        }
        public void LowLoadSeveralRelevantWordsTest()
        {
            var settings = new InputSettings()
            {
                VocabularySize = 10000,
                WordMaxLength = 4,
                WordMaxOccurrences = 1000000,
                PrefixesNumber = 1500,
                PrefixMaxLength = 15
            };

            TestOneSettings(settings);
        }
 public PerformanceValidator(InputSettings inputSettings,
                              IEnumerable<VocabularyItem> vocabulary,
                              IEnumerable<string> prefixes)
     : base(inputSettings, vocabulary, prefixes)
 {
 }
 public CorrectnessValidator(InputSettings inputSettings,
                              IEnumerable<VocabularyItem> vocabulary,
                              IEnumerable<string> prefixes)
     : base(inputSettings, vocabulary, prefixes)
 {
 }
        private void TestOneSettings(InputSettings settings = null)
        {
            if (settings == null)
                settings = InputSettings.GetFromAppSettings();

            var vocabulary = CorrectInputGenerator.GenerateVocabulary(settings);
            var prefixes = CorrectInputGenerator.GeneratePrefixes(settings);

            if (TestSettings.Default.ValidateCorrectness)
                (new CorrectnessValidator(settings, vocabulary, prefixes)).Validate();

            if (TestSettings.Default.ValidatePerformance)
                (new PerformanceValidator(settings, vocabulary, prefixes)).Validate();
        }