Exemplo n.º 1
0
            protected static IEnumerable <SuggestionTestSet> GetSuggestionTestFileSets()
            {
                var suggestionFilePaths = GetAllDataFilePaths("*.sug")
                                          .Where(p => !ExcludedSuggestionFiles.Contains(Path.GetFileNameWithoutExtension(p)));

                foreach (var suggestionFilePath in suggestionFilePaths)
                {
                    var wrongFilePath = Path.ChangeExtension(suggestionFilePath, "wrong");
                    if (!File.Exists(wrongFilePath))
                    {
                        throw new InvalidOperationException();
                    }

                    var dictionaryFilePath = Path.ChangeExtension(wrongFilePath, "dic");
                    var affix           = AffixReader.ReadFile(Path.ChangeExtension(dictionaryFilePath, "aff"));
                    var wrongLines      = ExtractLinesFromWordFile(wrongFilePath, affix.Encoding).ToList();
                    var suggestionLines = ExtractLinesFromWordFile(suggestionFilePath, affix.Encoding).ToList();

                    yield return(new SuggestionTestSet
                    {
                        DictionaryFilePath = dictionaryFilePath,
                        WrongFilePath = wrongFilePath,
                        SuggestionFilePath = suggestionFilePath,
                        WrongLines = wrongLines,
                        SuggestionLines = suggestionLines
                    });
                }
            }
Exemplo n.º 2
0
 public void Benchmark(BenchmarkContext context)
 {
     Task.WhenAll(AffixFilePaths.Select(async filePath =>
     {
         await AffixReader.ReadFileAsync(filePath).ConfigureAwait(false);
         AffixFilesLoaded.Increment();
     })).Wait();
 }
Exemplo n.º 3
0
 public void Benchmark(BenchmarkContext context)
 {
     foreach (var filePath in AffixFilePaths)
     {
         AffixReader.ReadFile(filePath);
         AffixFilesLoaded.Increment();
     }
 }
Exemplo n.º 4
0
        protected static IEnumerable <object[]> ToDictionaryWordTestData(string wordFilePath)
        {
            var dictionaryPath = Path.ChangeExtension(wordFilePath, "dic");
            var affix          = AffixReader.ReadFile(Path.ChangeExtension(wordFilePath, "aff"));

            return(ExtractMultipleWordsFromWordFile(wordFilePath, affix.Encoding)
                   .Distinct()
                   .OrderBy(w => w, StringComparer.Ordinal)
                   .Select(line => new object[] { dictionaryPath, line }));
        }
        public void Setup(BenchmarkContext context)
        {
            var testAssemblyPath    = Path.GetFullPath(GetType().Assembly.Location);
            var filesDirectory      = Path.Combine(Path.GetDirectoryName(testAssemblyPath), "files/");
            var dictionaryFilePaths = Directory.GetFiles(filesDirectory, "*.dic")
                                      .OrderBy(p => p);

            DictionaryLoadArguments = dictionaryFilePaths
                                      .Select(dicFilePath =>
                                              new DictionaryLoadData
            {
                DictionaryFilePath = dicFilePath,
                Affix = AffixReader.ReadFile(Path.ChangeExtension(dicFilePath, "aff"))
            })
                                      .ToArray();

            DictionaryFilesLoaded = context.GetCounter(nameof(DictionaryFilesLoaded));
        }
Exemplo n.º 6
0
        public void Setup(BenchmarkContext context)
        {
            var testAssemblyPath    = Path.GetFullPath(GetType().Assembly.Location);
            var filesDirectory      = Path.Combine(Path.GetDirectoryName(testAssemblyPath), "files/");
            var dictionaryFilePaths = Directory.GetFiles(filesDirectory, "*.dic")
                                      .OrderBy(p => p);

            DictionaryLoadArguments = Task.WhenAll(
                dictionaryFilePaths
                .Select(async dicFilePath =>
            {
                return(new DictionaryLoadData
                {
                    DictionaryFilePath = dicFilePath,
                    Affix = await Task.Run(() => AffixReader.ReadFileAsync(Path.ChangeExtension(dicFilePath, "aff"))).ConfigureAwait(false)
                });
            }))
                                      .Result;

            DictionaryFilesLoaded = context.GetCounter(nameof(DictionaryFilesLoaded));
        }