示例#1
0
        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());
        }
示例#2
0
        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");
        }
示例#3
0
 private Result <string[]> GetNormalizeWords(WordList dictionary, string pathToFile)
 {
     return(reader.ReadStrings(pathToFile)
            .Then(lines => NormalizeWords(lines, dictionary)));
 }