Commit 2171709d authored by Dhananjaya Jayashanka's avatar Dhananjaya Jayashanka

update textAnalyze.py file

parent 60e7e948
import string import string
from collections import Counter from collections import Counter
def textAnalyze(speech): def textAnalyze(speech):
text = speech text = speech
...@@ -36,13 +37,15 @@ def textAnalyze(speech): ...@@ -36,13 +37,15 @@ def textAnalyze(speech):
final_words.append(word) final_words.append(word)
emotion_list = [] emotion_list = []
with open('Emotion/emotions.txt', 'r') as file:
for line in file:
clear_line = line.replace("\n", '').replace(",", '').replace("'", '').strip()
word, emotion = clear_line.split(':')
if word in final_words: for i in final_words:
emotion_list.append(emotion) with open('Emotion/emotions.txt', 'r') as file:
for line in file:
clear_line = line.replace("\n", '').replace(",", '').replace("'", '').strip()
word, emotion = clear_line.split(':')
if i in word:
final_emotions = emotion.replace("", '').strip()
emotion_list.append(final_emotions)
print(emotion_list) print(emotion_list)
w = Counter(emotion_list) w = Counter(emotion_list)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment