public string[] GetWords(string inputFileName) { var path = creater.GetCurrentPath(); var dictionary = GetDictionary(path); var lines = reader.ReadStrings(path + inputFileName); return(lines .SelectMany(line => line.Split(separators, StringSplitOptions.RemoveEmptyEntries)) .Select(word => word.ToLower()) .Select(word => GetRootForWord(word, dictionary)) .Where(word => !(word is null)) .Where(word => word.Length > minWordLength) .Where(word => !unneccesaryWords.Contains(word)) .ToArray()); }
public void GetWords_ReturnFail_OnUncorrectPatCreator() { var pathCreater = A.Fake <IPathCreator>(); A.CallTo(() => pathCreater.GetCurrentPath()).Returns("Incorrect path"); A.CallTo(() => textReader.ReadStrings(null)) .WithAnyArguments().Returns(new string[] { "asdf" }); parser = new TextProcessing.LiteratureTextParser(pathCreater, textReader); var parseResult = parser.GetWords(null); parseResult.IsSuccess.Should().BeFalse(); parseResult.Error.Should().Contain("Not found dictionaries"); }
private Result <string[]> GetNormalizeWords(WordList dictionary, string pathToFile) { return(reader.ReadStrings(pathToFile) .Then(lines => NormalizeWords(lines, dictionary))); }