Logo Lanfrica

sohamhans19994/Sentiment-analysis-mozambique

Domaine:

natural language processing
Créateur:
soh
Hôte:
# Summary ## Code documentation 1) Used a python virtual enviroment to install required packages, requirements are mentioned in requirements.txt 2) The code is structured as a class named NewsSentimentAnalysis, with separate functions for carrying out different phases of the task       • The first function fetchArticles gets the data from the given url (aljazeera.com), and extracts the top         10 news articles and their texts.       • The saveAsJSON function stores the collected data in JSON form.       • The article texts are then cleaned in the cleanArticles function.       • Sentences are extracted from the articles in the extractSentences function.       • Two separate functions exist for analysing the sentiment of the sentences in the articles.             a. The textblob_analysis function uses the textblob library to return the polarity of the sentences, the average polarity of all the                 sentences in an article is returned as the polarity of the article.             b. The flair_analysis function uses the flair library and their pretrained models to get the sentiment of each sentence and it’s                 confidence score. The overall sentiment of each article is retrieved by averaging over the scores of each sentence.       • The main function inside the class calls all the functions mentioned above in the right order. 3) Running the code • To run the code simply use the command `python3 sentiment_analysis.py` This …