Skip to content
Snippets Groups Projects
Commit fe5a3de2 authored by mlarson33's avatar mlarson33
Browse files

Reformated code to fit good coding style. Ran coverage again to see coverage results.

parent 3a70623c
Branches
No related tags found
No related merge requests found
.coverage 0 → 100644
File added
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<div class="content"> <div class="content">
<p> <p>
<a class="nav" href="https://coverage.readthedocs.io">coverage.py v5.1</a>, <a class="nav" href="https://coverage.readthedocs.io">coverage.py v5.1</a>,
created at 2021-03-16 18:01 created at 2021-03-16 20:38
</p> </p>
</div> </div>
</div> </div>
......
{"format":2,"version":"5.1","globals":"6f970bb3fd818c0086bb8745517713d8","files":{"sentiment_py":{"hash":"b80045c1e80c9b6b65165d4976b72548","index":{"nums":[1,269,0,85,104,9,43],"html_filename":"sentiment_py.html","relative_filename":"sentiment.py"}},"tests_py":{"hash":"9efee8c6f89bda3badab9e1807a6b3dd","index":{"nums":[1,95,0,1,2,1,1],"html_filename":"tests_py.html","relative_filename":"tests.py"}}}} {"format":2,"version":"5.1","globals":"6f970bb3fd818c0086bb8745517713d8","files":{"sentiment_py":{"hash":"b80045c1e80c9b6b65165d4976b72548","index":{"nums":[1,269,0,85,104,9,43],"html_filename":"sentiment_py.html","relative_filename":"sentiment.py"}},"tests_py":{"hash":"4b0cb5acfe4ac9eee3f1aa789b8d76ae","index":{"nums":[1,95,0,1,2,1,1],"html_filename":"tests_py.html","relative_filename":"tests.py"}}}}
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
...@@ -290,8 +290,6 @@ prompt_result = '' ...@@ -290,8 +290,6 @@ prompt_result = ''
def main(): def main():
# Comment for test commit
# Comment for second test commit
global prompt_result global prompt_result
options = tuple(MenuOption) options = tuple(MenuOption)
try: try:
......
...@@ -19,6 +19,7 @@ class TestComputeCollectionOfTokens(unittest.TestCase): ...@@ -19,6 +19,7 @@ class TestComputeCollectionOfTokens(unittest.TestCase):
unique_tokens = set(sentiment.get_all_tokens(list_reviews)) unique_tokens = set(sentiment.get_all_tokens(list_reviews))
self.assertEqual(75, len(unique_tokens)) self.assertEqual(75, len(unique_tokens))
class TestComputeDocumentFrequency(unittest.TestCase): class TestComputeDocumentFrequency(unittest.TestCase):
def test_frequency_of_three(self): def test_frequency_of_three(self):
list_reviews = ['+ absolutely detestable', '- bad bad bad'] list_reviews = ['+ absolutely detestable', '- bad bad bad']
...@@ -70,7 +71,8 @@ class TestCalculateTFIDFScore(unittest.TestCase): ...@@ -70,7 +71,8 @@ class TestCalculateTFIDFScore(unittest.TestCase):
all_tokens = sentiment.get_all_tokens(list_reviews) all_tokens = sentiment.get_all_tokens(list_reviews)
unique_tokens = set(all_tokens) unique_tokens = set(all_tokens)
token_map = sentiment.get_token_map(all_tokens, list_reviews) token_map = sentiment.get_token_map(all_tokens, list_reviews)
total_negative_review_tokens, total_positive_review_tokens = sentiment.calculate_total_positives_and_negatives(token_map) total_negative_review_tokens, total_positive_review_tokens = sentiment.calculate_total_positives_and_negatives(
token_map)
sentiment.set_tfidf_score(unique_tokens, token_map, total_negative_review_tokens, total_positive_review_tokens) sentiment.set_tfidf_score(unique_tokens, token_map, total_negative_review_tokens, total_positive_review_tokens)
self.assertEqual(1.4381194289844768, token_map['positively'].tfidf_score) self.assertEqual(1.4381194289844768, token_map['positively'].tfidf_score)
...@@ -96,6 +98,7 @@ class TestSetTFIDFClassification(unittest.TestCase): ...@@ -96,6 +98,7 @@ class TestSetTFIDFClassification(unittest.TestCase):
self.assertEqual(sentiment.TokenClassification.POSITIVE, token_map['positively'].token_classification) self.assertEqual(sentiment.TokenClassification.POSITIVE, token_map['positively'].token_classification)
self.assertEqual(sentiment.TokenClassification.POSITIVE, token_map['introspective'].token_classification) self.assertEqual(sentiment.TokenClassification.POSITIVE, token_map['introspective'].token_classification)
class TestSetTokenFrequencyOfSentiment(unittest.TestCase): class TestSetTokenFrequencyOfSentiment(unittest.TestCase):
def test_set_token_frequency_of_sentiment(self): def test_set_token_frequency_of_sentiment(self):
list_reviews = ['+ absolutely detestable ; would not watch again', list_reviews = ['+ absolutely detestable ; would not watch again',
...@@ -125,7 +128,8 @@ class TestShowSentenceStatistics(unittest.TestCase): ...@@ -125,7 +128,8 @@ class TestShowSentenceStatistics(unittest.TestCase):
list_reviews) list_reviews)
# correct_output = 'The sentence has 5 negative, 0 neutral, 1 positive, and 1 unknown token(s).\nThe sentence has an average tf-idf score of -0.18812093738509109' # correct_output = 'The sentence has 5 negative, 0 neutral, 1 positive, and 1 unknown token(s).\nThe sentence has an average tf-idf score of -0.18812093738509109'
negative, neutral, positive, unknown, total_tfidf_score = sentiment.prompt_for_sentence_statistics(False, negative, neutral, positive, unknown, total_tfidf_score = sentiment.prompt_for_sentence_statistics(False,
token_map, 'this quiet , introspective and entertaining independent is worth seeking .') token_map,
'this quiet , introspective and entertaining independent is worth seeking .')
self.assertEqual(0, negative) self.assertEqual(0, negative)
self.assertEqual(2, neutral) self.assertEqual(2, neutral)
self.assertEqual(9, positive) self.assertEqual(9, positive)
...@@ -150,8 +154,10 @@ class TestSaveStopWordList(unittest.TestCase): ...@@ -150,8 +154,10 @@ class TestSaveStopWordList(unittest.TestCase):
list_reviews = ['0 reeks of rot and hack work from start to finish .', list_reviews = ['0 reeks of rot and hack work from start to finish .',
'- plays like a series of vignettes -- clips of a film that are still looking for a common through-line .', '- plays like a series of vignettes -- clips of a film that are still looking for a common through-line .',
'+ it shows us a slice of life that \'s very different from our own and yet instantly recognizable .'] '+ it shows us a slice of life that \'s very different from our own and yet instantly recognizable .']
stop_words = ['.\n', 'a\n', 'of\n', 'to\n', '--\n', 'it\n', 'us\n', '\'s\n', 'rot\n', 'and\n', 'are\n', 'for\n', 'our\n', 'own\n', 'yet\n', 'hack\n', 'work\n', 'from\n', 'like\n', stop_words = ['.\n', 'a\n', 'of\n', 'to\n', '--\n', 'it\n', 'us\n', '\'s\n', 'rot\n', 'and\n', 'are\n', 'for\n',
'film\n', 'that\n', 'life\n', 'very\n', 'reeks\n', 'start\n', 'plays\n', 'clips\n', 'still\n', 'shows\n', 'slice\n', 'finish\n', 'series\n', 'common\n', 'looking\n', 'our\n', 'own\n', 'yet\n', 'hack\n', 'work\n', 'from\n', 'like\n',
'film\n', 'that\n', 'life\n', 'very\n', 'reeks\n', 'start\n', 'plays\n', 'clips\n', 'still\n',
'shows\n', 'slice\n', 'finish\n', 'series\n', 'common\n', 'looking\n',
'vignettes\n', 'different\n', 'instantly\n', 'through-line\n', 'recognizable\n'] 'vignettes\n', 'different\n', 'instantly\n', 'through-line\n', 'recognizable\n']
all_tokens, token_map, total_negative_review_tokens, total_positive_review_tokens, unique_tokens = sentiment.create_data_structures( all_tokens, token_map, total_negative_review_tokens, total_positive_review_tokens, unique_tokens = sentiment.create_data_structures(
list_reviews) list_reviews)
...@@ -169,7 +175,8 @@ class TestShowAdjustedSentenceStatistics(unittest.TestCase): ...@@ -169,7 +175,8 @@ class TestShowAdjustedSentenceStatistics(unittest.TestCase):
all_tokens, token_map, total_negative_review_tokens, total_positive_review_tokens, unique_tokens = sentiment.create_data_structures( all_tokens, token_map, total_negative_review_tokens, total_positive_review_tokens, unique_tokens = sentiment.create_data_structures(
list_reviews) list_reviews)
# correct_output = 'The sentence has 5 negative, 0 neutral, 1 positive, and 1 unknown token(s).\nThe sentence has an average tf-idf score of -0.18812093738509109' # correct_output = 'The sentence has 5 negative, 0 neutral, 1 positive, and 1 unknown token(s).\nThe sentence has an average tf-idf score of -0.18812093738509109'
stop_words, negative, neutral, positive, unknown, total_tfidf_score = sentiment.prompt_for_sentence_statistics(True, token_map, 'this quiet , introspective and entertaining independent is worth seeking .') stop_words, negative, neutral, positive, unknown, total_tfidf_score = sentiment.prompt_for_sentence_statistics(
True, token_map, 'this quiet , introspective and entertaining independent is worth seeking .')
self.assertEqual(2, stop_words) self.assertEqual(2, stop_words)
self.assertEqual(0, negative) self.assertEqual(0, negative)
self.assertEqual(1, neutral) self.assertEqual(1, neutral)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment