示例#1
0
        public List <string> GetStopwords()
        {
            StopwordListParameter stopwordListParameter = StopwordListParameterParser.ParseStopwordListParameter();
            LanguageParameter     languageParameter     = LanguageParameterParser.ParseLanguageParameter();

            bool isStopwordListParameterPresent = stopwordListParameter.IsPresent;

            string fileName = isStopwordListParameterPresent ?
                              stopwordListParameter.FileName :
                              $"stopwords.{languageParameter.Language}.txt";

            if (!FileSystem.File.Exists(path: fileName))
            {
                return(new List <string>());
            }

            if (isStopwordListParameterPresent)
            {
                DisplayOutput.WriteResourceLine(
                    resourceIdent: "USED_STOPWORDLIST",
                    placeholderValues: fileName);
            }

            return(FileSystem
                   .File
                   .ReadAllLines(path: fileName)
                   .ToList());
        }
        public void StopwordListParameterParserTests_Args_have_no_Dictionary_Parameter_Expect_IsPresent_False()
        {
            _mockEnvironment
            .Setup(expression: m => m.GetCommandLineArgs())
            .Returns(value: new[] { "bla.txt" });

            StopwordListParameter actual = _systemUnderTest
                                           .ParseStopwordListParameter();

            Assert.NotNull(@object: actual);
            Assert.False(condition: actual.IsPresent);
        }