Question
In Python 3.6: The problem is that we need to count words and Counting and ranking word frequency in a text The goal of this
In Python 3.6: The problem is that we need to count words and Counting and ranking word frequency in a text The goal of this project is to familiarize ourselves with the processing of text files using Python (without importing specialized libraries for text parsing) and to practice working with Python data types, such as strings, lists, dictionaries, and files. Download the text of the ebook The Hound of the Baskervilles by A. Conan Doyle from the Project Gutenbergs website: https://www.gutenberg.org/files/2852/2852-0.txt Click on the Plain Text UTF-8 folder.
We want to analyze the sentiment of the text on the sentence level. That is, we want to classify each sentence in this text as having either positive, neutral, or negative sentiment. The following three sentences illustrate each sentiment type. For example,
I am so excited about my new car. (Positive sentiment)
I feel tired and moody today. (Negative sentiment)
There is parked car on the street. (Neutral sentiment)
To aid us in deciding which words carry positive, neutral, or negative sentiment, we will consult the two files positivesentimentwords.txt and negativesentimentwords.txt. Each of these files contains a list of words that are generally associated with positive/negative sentiment.
The classification of each sentence as being positive, neutral, or negative is based on the following assessment. If more words in a sentence carry the positive sentiment than negative, we will classify that sentence as having a positive sentiment. If the number of positive and negative words in a sentence is equal, we will classify that sentence as neutral. Otherwise, the sentence is classified as having a negative sentiment.
Upon completion, your code should print sentence counts for each sentiment type:
Positive:
Negative:
Neutral :
this is the positivesentimenwords.txt file
a+ abound abounds abundance abundant accessable accessible acclaim acclaimed acclamation accolade accolades accommodative accomodative accomplish accomplished accomplishment accomplishmentsa accurate accurately achievable achievement achievements achievible acumen adaptable adaptive adequate adjustable admirable
this is the negativesentimenwords.txt file:
2-faced 2-faces abnormal abolish abominable abominably abominate abomination abort aborted aborts abrade abrasive abrupt abruptly abscond absence absent-minded absentee absurd absurdity absurdly absurdness abuse abused abuses abusive abysmal abysmally abyss
use python and give the output after you run the code
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