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 }); } }
public void Benchmark(BenchmarkContext context) { foreach (var filePath in AffixFilePaths) { AffixReader.ReadFile(filePath); AffixFilesLoaded.Increment(); } }
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)); }