Question
Problem 1 Score Dictionary For this assignment, create a new file called sentiment.py . All code should be defined in this file. Write a function
Problem 1 Score Dictionary
For this assignment, create a new file called sentiment.py. All code should be defined in this file.
Write a function called load_score_dict which takes in one optional argument representing the file name of the score dictionary. It should default to sentiment.txt, so when we call the function with no arguments, we should get this dictionary.
It should return a dictionary where the keys are the words and the values are the corresponding sentiment scores as floats.
Note: You should assume the following formatting specifications:
- There may be blank lines in the file which should be ignored.
- There may be lines which start with #; these lines should be ignored.
- Otherwise, you may assume the line is of the format word [value], separated by a single space
Use python 3.8
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started