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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!