Skip to content
Snippets Groups Projects
Commit ee8dcb95 authored by bjuradotorres2's avatar bjuradotorres2
Browse files

Coverage report and related files finalized

parent 09f4b8a3
No related branches found
No related tags found
No related merge requests found
......@@ -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__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment