public void TextSplitTests_Analyze_Stopword_a_Mary_has_a_little_lamb_with_Newlines_Expect_5_Words() { TextSplitResult actual = _systemUnderTest.Split( text: $"Mary had{Environment.NewLine}a little{Environment.NewLine}lamb"); Assert.Equal(expected: 5, actual: actual.Words.Count); }
public void TextSplitTests_Analyze_Text_a_with_dot_Expect_1_Word() { TextSplitResult actual = _systemUnderTest.Split(text: "a."); Assert.Single(collection: actual.Words); Assert.Equal(expected: "a", actual: actual.Words[0]); }
public void TextSplitTests_Analyze_Stopword_a_This_is_a_Text_Expect_4_Words() { TextSplitResult actual = _systemUnderTest.Split( text: "This is a Text"); Assert.Equal(expected: 4, actual: actual.Words.Count); }
public WordCountAnalyzerResult Analyze(string text) { TextSplitResult textSplitResult = TextSplit.Split(text: text); if (!textSplitResult.WordsAvailable) { return(new WordCountAnalyzerResult()); } StopwordRemoverResult stopwordRemoverResult = StopwordRemover.RemoveStopwords(words: textSplitResult.Words); List <string> words = stopwordRemoverResult.Words; List <string> distinctWords = words.Distinct().ToList(); int numberOfWords = words.Count; int numberOfUniqueWords = distinctWords.Count; double averageWordLength = words.Any() ? words.Average(selector: s => s.Length) : 0.0; int numberOfchapters = text.Split(separator: new[] { Environment.NewLine + Environment.NewLine }, options: StringSplitOptions.None).Count(); return(new WordCountAnalyzerResult { NumberOfWords = numberOfWords, NumberOfUniqueWords = numberOfUniqueWords, AverageWordLength = averageWordLength, DistinctWords = distinctWords, NumberOfChapters = numberOfchapters }); }
public void TextSplitTests_Humpty_Dumpty_Text_Expect_10_Words() { const string text = "Humpty-Dumpty sat on a wall. Humpty-Dumpty had a great fall."; TextSplitResult actual = _systemUnderTest.Split(text: text); Assert.Equal( expected: 10, actual: actual.Words.Count); }
public void TextSplitTests_Analyze_empty_strings_Expect_0_Words( string inputtext) { TextSplitResult actual = _systemUnderTest.Split(text: inputtext); Assert.NotNull(@object: actual); Assert.NotNull(@object: actual.Words); Assert.Empty(collection: actual.Words); }
public void TextSplitTests_Text_with_Unicode_Expect_2_Words() { const string text = "Hello André"; TextSplitResult actual = _systemUnderTest.Split(text: text); List <string> expected = new List <string> { "Hello", "André" }; Assert.Equal( expected: expected, actual: actual.Words); }
public void TextSplitTests_Words_with_Comma_expect_no_Comma() { const string text = "Longworth, however, in desperate need of money, killed the preacher with Hamlet's sword and stole the manuscript"; TextSplitResult actual = _systemUnderTest.Split(text: text); List <string> expected = new List <string>() { "Longworth", "however", "in", "desperate", "need", "of", "money", "killed", "the", "preacher", "with", "Hamlet's", "sword", "and", "stole", "the", "manuscript" }; Assert.Equal(expected: expected, actual: actual.Words); }
public void TextSplitTests_Text_with_Digit_Expect_without_Digit() { const string text = "Draußen ist es schön 1"; TextSplitResult actual = _systemUnderTest.Split(text: text); List <string> expected = new List <string> { "Draußen", "ist", "es", "schön" }; Assert.Equal( expected: expected, actual: actual.Words); }
public void TextSplitTests_Text_with_MinusAtEnd_Expect_word_Without_Minus() { const string text = "pre- pre-condition"; TextSplitResult actual = _systemUnderTest.Split(text: text); List <string> expected = new List <string> { "pre", "pre-condition" }; Assert.Equal( expected: expected, actual: actual.Words); }
public void TextSplitTests_empty_strings_Expect_ValuesAvailable_false(string inputtext) { TextSplitResult actual = _systemUnderTest.Split(text: inputtext); Assert.False(condition: actual.WordsAvailable); }
public void TextSplitTests_Analyze_Text_Bla_bla_Expect_2_Words() { TextSplitResult actual = _systemUnderTest.Split(text: "Bla bla"); Assert.Equal(expected: 2, actual: actual.Words.Count); }