public void BuildSummary_SentenceList_SummaryContainsOnlyFinalSentences() { string[] rawSentences = { "test", "trial" }; string[] finalSentences = { "test" }; var result = ArticleSummarizer.BuildSummary(rawSentences, finalSentences); Assert.That(result, Is.EqualTo(finalSentences[0] + ". \n\n")); }
public void SortWords_DictionaryOfWordCounts_ReturnsProperCount() { var wordCounts = new Dictionary <string, int> { { "test", 2 }, { "challenge", 5 }, { "trial", 1 } }; string[] expectedOrder = { "challenge", "test" }; var result = ArticleSummarizer.SortWords(wordCounts); Assert.That(result, Is.EqualTo(expectedOrder)); }
public void CountWords_ListContainsStopWords_ReturnsProperCountExcludingStopWords() { ArticleSummarizer.LoadStopWords(); var words = new List <string>(new string[] { "test", "test", "trial", "a", "an", "the" }); var expectedWordCounts = new Dictionary <string, int> { { "test", 2 }, { "trial", 1 } }; var result = ArticleSummarizer.CountWords(words); Assert.That(result, Is.EqualTo(expectedWordCounts)); }
public void CountWords_ListOfNonStopWords_ReturnsProperCount() { ArticleSummarizer.LoadStopWords(); var words = new List <string>(new string[] { "test", "test", "trial" }); var expectedWordCounts = new Dictionary <string, int> { { "test", 2 }, { "trial", 1 } }; var wordCounts = ArticleSummarizer.CountWords(words); Assert.That(wordCounts, Is.EqualTo(expectedWordCounts)); }
public void SortSentences_ScoredSentences_ResultsAreSortedAndContainProperAmountOfSentences(double input, string[] expectedResult) { var sentenceScores = new Dictionary <string, int> { { "test", 1 }, { "scores", 2 }, { "match", 3 }, { "results", 4 }, { "correct", 5 } }; var result = ArticleSummarizer.SortSentences(sentenceScores, input); Assert.That(result, Is.EqualTo(expectedResult)); }
public void ScoreSentences_WordScores_SentenceScoreMatchesSumOfWordScores(string input, int expectedResult) { string[] sentences = { "This is a test.", "The scores must match.", "Is a this that the." }; var wordScores = new Dictionary <string, int> { { "test", 5 }, { "scores", 4 }, { "match", 3 } }; var sentenceScores = ArticleSummarizer.ScoreSentences(sentences, wordScores); Assert.That(sentenceScores[input], Is.EqualTo(expectedResult)); }
private void ButtonSubmit_Click(object sender, RoutedEventArgs e) { if (TextboxUrlInput.Text.Length > 0) { // Grab URLs entered by user var rawUrls = TextboxUrlInput.Text; string[] urls = rawUrls.Split('\n'); var obj = App.Current as App; // Generate a summary for each URL given and add to queue foreach (var url in urls) { ArticleSummary tempArticle = ArticleSummarizer.Generate(url.Trim('\r')); obj.Articles.Enqueue(tempArticle); } // Launch the first summary window OpenNewWindow(); } }
public void ScoreWords_ArrayOfWords_WordsHaveProperScores(string input, int expectedResult) { string[] sortedWords = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t" }; var wordScores = ArticleSummarizer.ScoreWords(sortedWords); int result; if (wordScores.ContainsKey(input)) { result = wordScores[input]; } else { result = 0; } Assert.That(result, Is.EqualTo(expectedResult)); }
public void CleanText_TextWithPuncuation_ReturnsTextWithoutPunctuation(string input, string expectedResult) { var result = ArticleSummarizer.CleanText(input); Assert.That(result, Is.EqualTo(expectedResult)); }
public void CleanText_TextWithUpperCase_ReturnsLowerCaseText(string input, string expectedResult) { var result = ArticleSummarizer.CleanText(input); Assert.That(result, Is.EqualTo(expectedResult)); }
public void ValidateUrl_Url_ReturnsBool(string url, bool expectedResult) { var result = ArticleSummarizer.ValidateUrl(url); Assert.That(result, Is.EqualTo(expectedResult)); }