Question: Python: Problem 4 Command Line Interface In your if __name__ == '__main__' section, write an interface which allows in a user to pass in the

Python: Problem 4 Command Line Interface

In your if __name__ == '__main__' section, write an interface which allows in a user to pass in the name of a file through the command line like this:

python sentiment.py some_file.txt

sentiment.py content:

# Data sourced from: # https://github.com/aesuli/sentiwordnet

abandon -0.125 abandoned 0.5 abandonment -0.5 abasia -0.5 abatable 0.625 abatic -0.25 abaxially 0.25 abbe 0.125 abdicable 0.375 abduction -1.0 aberrate -0.25 aberration -0.25 abetalipoproteinemia -0.75 abient 0.25 ability 0.5 abiotrophy -0.25 abject -1.0 ablate -0.125 ablated -0.125 ablative 0.625 ablaut 0.5 able 0.125 ablepharia 0.5 ablism 0.125 abnormal -0.25 abnormality 0.25 abnormally 0.125 abocclusion 0.125 abolishable 0.625 abomination -0.125 abort -0.625 abortifacient -0.375

and many more rows

If the user fails to pass in a file name, your code should handle the situation without throwing an Exception by printing a message to the console instructing the user to input a file name.

Otherwise, your code should load in the text from the file, extract the list of unique words, and compute the sentiment score using the dictionary from sentiment.txt. It should then print out the word Positive to the console if the file score is > 0, Negative if the file score is < 0, and Neutral otherwise. There should be no other output to the console.

We suggest using the provided text files to

confirm whether your code is working or not

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!