public ContentProcessorResult Run(Command command, string content, IList<string> negativeWords)
        {
            content = content ?? "";
            negativeWords = negativeWords ?? new List<string>();

            var matches = GetNegativeWordMatches(content, negativeWords);

            var result = new ContentProcessorResult
            {
                NegativeWordsCount = matches.Count,
                Content = command.Equals(Command.FilterNegative) ? MaskNegativeWords(content, matches) : content
            };

            return DisplayResult(result.Content, result, command);
        }
Example #2
0
        public ContentProcessorResult Run(Command command, string content, IList <string> negativeWords)
        {
            content       = content ?? "";
            negativeWords = negativeWords ?? new List <string>();

            var matches = GetNegativeWordMatches(content, negativeWords);

            var result = new ContentProcessorResult
            {
                NegativeWordsCount = matches.Count,
                Content            = command.Equals(Command.FilterNegative) ? MaskNegativeWords(content, matches) : content
            };

            return(DisplayResult(result.Content, result, command));
        }
        private ContentProcessorResult DisplayResult(string content, ContentProcessorResult result, Command command)
        {
            if (command.Equals(Command.DisplayNegativeCount))
            {
                _inputOutput.WriteLine("Scanned the text:");
            }

            _inputOutput.WriteLine(content);

            if (command.Equals(Command.DisplayNegativeCount) || command.Equals(Command.DisplayOriginalContent))
            {
                _inputOutput.WriteLine("Total Number of negative words: " + result.NegativeWordsCount);
            }

            _inputOutput.WriteLine("Press ANY key to exit.");
            _inputOutput.ReadKey();
            return result;
        }
Example #4
0
        private ContentProcessorResult DisplayResult(string content, ContentProcessorResult result, Command command)
        {
            if (command.Equals(Command.DisplayNegativeCount))
            {
                _inputOutput.WriteLine("Scanned the text:");
            }

            _inputOutput.WriteLine(content);

            if (command.Equals(Command.DisplayNegativeCount) || command.Equals(Command.DisplayOriginalContent))
            {
                _inputOutput.WriteLine("Total Number of negative words: " + result.NegativeWordsCount);
            }

            _inputOutput.WriteLine("Press ANY key to exit.");
            _inputOutput.ReadKey();
            return(result);
        }