From ee8dcb95192669bac45fb39efe16926b0f1857a8 Mon Sep 17 00:00:00 2001 From: brian <bjuradotorres2@huskers.unl.edu> Date: Sun, 16 Mar 2025 20:50:06 -0500 Subject: [PATCH] Coverage report and related files finalized --- test_main.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test_main.py b/test_main.py index e57595a..0772244 100644 --- a/test_main.py +++ b/test_main.py @@ -3,6 +3,7 @@ import sentiment from sentiment import get_tokens, score_compute, save_stop_words import os + class TestGetTokens(unittest.TestCase): # creates file path to sentiment.txt file @@ -47,8 +48,10 @@ class TestGetTokens(unittest.TestCase): manual_count = sum(1 for token in self.review_tokens_list if token == target_token) - self.assertEqual(manual_count, expected_count, f"Expected {expected_count} occurrences of '{target_token}', but got {manual_count}.") - print(f"""\nTest 2 - Word Frequencies: \nThe training data contains {manual_count} appearances of the token "too".""") + self.assertEqual(manual_count, expected_count, + f"Expected {expected_count} occurrences of '{target_token}', but got {manual_count}.") + print( + f"""\nTest 2 - Word Frequencies: \nThe training data contains {manual_count} appearances of the token "too".""") def test_03_token_statistics(self): target_token = "too" @@ -162,7 +165,8 @@ class TestGetTokens(unittest.TestCase): avg_score = total_score / valid_tokens if valid_tokens > 0 else 0 self.assertAlmostEqual(avg_score, expected_score, places=10, msg="Incorrect average tf-idf score for sentence.") - print(f'\nTest 7 - Sentence Statistics Score: \nThe sentence "{target_sentence}" has an average tf-idf score of {avg_score}.') + print( + f'\nTest 7 - Sentence Statistics Score: \nThe sentence "{target_sentence}" has an average tf-idf score of {avg_score}.') def test_08_save_stop_words(self): save_stop_words(self.negative_reviews_list, self.neutral_reviews_list, self.positive_reviews_list) @@ -263,8 +267,8 @@ class TestGetTokens(unittest.TestCase): self.assertAlmostEqual(avg_score, expected_avg_tfidf, places=5, msg="Incorrect adjusted average tf-idf score.") - print(f'\nTest 10 - Non-Stop-Words Statistics Score: \nThe sentence "{target_sentence}" has an adjusted average tf-idf score of {avg_score}.') - + print( + f'\nTest 10 - Non-Stop-Words Statistics Score: \nThe sentence "{target_sentence}" has an adjusted average tf-idf score of {avg_score}.') if __name__ == '__main__': -- GitLab