Skip to content
Snippets Groups Projects
Commit 767f8142 authored by Sam Neupane's avatar Sam Neupane
Browse files

hw

parent 45063937
Branches
No related tags found
No related merge requests found
import unittest
class MyTestCase(unittest.TestCase):
def test_sentim(self):
self.assertEqual(method_11)
if __name__ == '__main__':
unittest.main()
......@@ -2,12 +2,9 @@ from __future__ import print_function, division
from builtins import input
def main():
reviews = list()
try:
with open('sentiment.txt') as s:
reviews = list(s)
......@@ -70,7 +67,6 @@ def main():
if word_in_file in sentiments.keys():
average.append(sum(sentiments[word]) / len(sentiments[word]))
if y == 2:
average.append(sum(sentiments[word_in_file]) / len(sentiments[word_in_file]))
if not average:
......@@ -81,15 +77,13 @@ def main():
if average_words >= 2.01:
print('The average score of words in {y} is {av}'.format(y=file, av=average_words))
print('The overall sentiment of {y} is positive'.format(y=file))
if average_words <= 1.99:
elif average_words <= 1.99:
print('The average score of words in {y} is {av}'.format(y=file, av=average_words))
print('The overall sentiment of {y} is negative'.format(y=file))
else:
print('The average score of words in {y} is {av}'.format(y=file, av=average_words))
print('The overall sentiment of {y} is neutral'.format(y=file))
if y == 3:
# rating = sum(sentiments[x])/len(sentiments[x])
split_file = file.split()
......@@ -103,11 +97,6 @@ def main():
method_11(check_word)
sum_word = sum(method_11(check_word)) / len(method_11(check_word))
for file_word, rate in sum_word.items():
if rate == highest_score:
j = file_word
......
from unittest import TestCase
from sentiment import method_11
class TestMethod_11(TestCase):
def test_method_11(self,reviews,sentiments):
self.assertEqual(['arty'], )
def test_method_11(self):
reviews = ['John', "jack "]
sentiments = [2,2]
self.assertEqual(method_11(reviews,sentiments)[3,0,1,1], ['arty'])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment