{"id":21318197,"url":"https://github.com/rajatdiptabiswas/twitter-sentiment-analysis","last_synced_at":"2025-10-31T10:43:50.234Z","repository":{"id":112340272,"uuid":"139299662","full_name":"rajatdiptabiswas/twitter-sentiment-analysis","owner":"rajatdiptabiswas","description":":bird: A Python script that analyses sentiment on a given topic from tweets data provided by Twitter","archived":false,"fork":false,"pushed_at":"2019-11-17T12:38:03.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-22T11:10:03.289Z","etag":null,"topics":["natural-language-processing","nltk","python","textblob","twitter","twitter-api","twitter-sentiment-analysis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rajatdiptabiswas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-01T04:15:37.000Z","updated_at":"2019-11-17T12:38:05.000Z","dependencies_parsed_at":"2023-05-13T05:45:10.734Z","dependency_job_id":null,"html_url":"https://github.com/rajatdiptabiswas/twitter-sentiment-analysis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajatdiptabiswas%2Ftwitter-sentiment-analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajatdiptabiswas%2Ftwitter-sentiment-analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajatdiptabiswas%2Ftwitter-sentiment-analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajatdiptabiswas%2Ftwitter-sentiment-analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rajatdiptabiswas","download_url":"https://codeload.github.com/rajatdiptabiswas/twitter-sentiment-analysis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243796741,"owners_count":20349264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["natural-language-processing","nltk","python","textblob","twitter","twitter-api","twitter-sentiment-analysis"],"created_at":"2024-11-21T19:11:55.138Z","updated_at":"2025-10-31T10:43:45.212Z","avatar_url":"https://github.com/rajatdiptabiswas.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Twitter Sentiment Analysis\nA Python script that analyses sentiment on a given topic from tweets data provided by Twitter\n\n\u003c/br\u003e\n\n## Getting Started\n\nThe project requires authentication via the Twitter API. A new application needs to be created to get the necessary keys. A few libraries also need to be installed for the script to run properly.\n\n### Prerequisites\n\n* [Tweepy](http://www.tweepy.org), the official Python library for accessing the Twitter API\n* [TextBlob](https://textblob.readthedocs.io/en/dev/), a Python library for processing textual data\n* [NLTK](https://www.nltk.org) dataset, to help better natural language processing\n* Keys from the [Twitter Developer Application Management](https://apps.twitter.com/) site\n  - Consumer key\n  - Consumer secret\n  - Access token\n  - Access token secret\n  \n### Installing\n\nThe **Tweepy** library can be installed by using the command\n```\npip3 install tweepy\n```  \n\u003c/br\u003e\n\nThe **TextBlob** library can be installed using\n```\npip3 install textblob\n```  \n\u003c/br\u003e\n\nThe **NLTK corpora** can be downloaded by using the following command\n```\npython3 -m textblob.download_corpora\n```\nThese files will provide better natural language processing capabilites for the TextBlob library. \n\n\u003e **Note:** A missing cerificate error can arise when trying to download the NLTK corpus files. To fix the issue, navigate to the Python folder `/Applications/Python 3.6` and run the `Install Certificates.command` file.\n\n\u003c/br\u003e\n\nTo obtain the **consumer keys** and **access tokens** from the Twitter Dev Application Management site, a new app needs to be created using a Twitter account.\n\n* Open [apps.twitter.com](https://apps.twitter.com/) and use the `Create New App` button.\n* Complete the form with the necessary application details. The application name must be unique.\n* Navitgate to the `Keys and Access Tokens` tab.\n* Copy `Consumer Key`, `Consumer Secret`, `Access Token` and `Access Token Secret` and update the variables `consumer_key`, `consumer_secret`, `access_token`, and `access_token_secret` in the `sentiment_analysis.py` file accordingly.\n\n\u003c/br\u003e\n\n## Running the program\n\n* Download the `sentiment_analysis.py` file from the repository\n* Update the consumer keys and access token values with the appropriate data in the file\n* Run the file using\n```\npython3 sentiment_analysis.py\n```\n\n\u003c/br\u003e\n\n## Sample output\n```\nRajats-MacBook-Pro:Desktop rajat$ python3 sentiment_analysis.py \n\nEnter a topic to apply sentiment analysis on:\n\tPutin\n\n\nSentiment analysis results:\n\tPositive\t14.29 %\n\tNegative\t12.86 %\n\tNeutral \t72.86 %\n\n\nPositive tweets:\n\n\t\u003e The new John Bolton: Trump ally swaps fire and brimstone for a spoonful of sugar \n\nTrump’s national security advise… \n\tPolarity = 0.136 ; Subjectivity = 0.136\n\n\t\u003e RT  Yup. Trump and Putin are meeting in Finland next month. Which is more appropriate than you’d think, since if these two kee…\n\tPolarity = 0.333 ; Subjectivity = 0.333\n\n\t\u003e RT  Trump knows. Seth Rich. HRC Server, Uranium One, AWAN, Assange, Putin Summit. Dems can't stop it. Wait for it.\n\tPolarity = 0.375 ; Subjectivity = 0.375\n\n\t\u003e RT  “Why would a president so desirous of making America strong be so obsequious and accommodating when it comes to Russia? That’…\n\tPolarity = 0.433 ; Subjectivity = 0.433\n\n\t\u003e  Putin \"If I help you win election, you turn a blind eye to Crimea and Syria\"\n\nTrump \"Oh, yeah. No problem.… \n\tPolarity = 0.150 ; Subjectivity = 0.150\n\n\nNegative tweets:\n\n\t\u003e RT  Republicans were outraged when Obama couldn't deter Putin from annexing Crimea, but many now silent when Trump considers endors…\n\tPolarity = -0.133 ; Subjectivity = -0.133\n\n\t\u003e RT   If Hillary were President she would not be a traitor, idolize Putin, or do any of the dumb shit that Trump do…\n\tPolarity = -0.287 ; Subjectivity = -0.287\n\n\t\u003e RT  Lots of hysterical SNOWFLAKE LIBS are worried the Russians are listening in on  unsecured phone calls. Gi…\n\tPolarity = -1.000 ; Subjectivity = -1.000\n\n\t\u003e RT  11/ The evil menace currently occupying the WH may not get a passing grade on removing troops from east Asia during Putin's…\n\tPolarity = -0.500 ; Subjectivity = -0.500\n\n\t\u003e RT  Trying to finish up a song about Trump, can't come up with the last verse.\n\n(need to rhyme with \"can\")\n\n- An moron wit…\n\tPolarity = -0.400 ; Subjectivity = -0.400\n\n\nNeutral tweets:\n\n\t\u003e RT  Darth Putin \n\tPolarity = 0.000 ; Subjectivity = 0.000\n\n\t\u003e RT  I was with two Journalists at dinner last night.  They were talking about the Trump Putin summit.  I said that’s not a summit…\n\tPolarity = 0.000 ; Subjectivity = 0.000\n\n\t\u003e RT  Yes, Russians installed Trump. Only took about 80,000 votes in 3 states to change the outcome of the electoral college.…\n\tPolarity = 0.000 ; Subjectivity = 0.000\n\n\t\u003e RT  Looks like Trump is preparing yet another gift for Putin in advance of their July get together. \n\tPolarity = 0.000 ; Subjectivity = 0.000\n\n\t\u003e RT  A young Russian boy was suffering a form of Cancer. He wrote to President Vladimir Putin requesting the President visits him as…\n\tPolarity = 0.050 ; Subjectivity = 0.050\n  \n  \n```\n\n\u003c/br\u003e\n\n## Authors\n\n* **Rajat Dipta Biswas** - *Initial work* - [rajatdiptabiswas](https://github.com/rajatdiptabiswas)\n\nSee also the list of [contributors](https://github.com/rajatdiptabiswas/twitter-sentiment-analysis/graphs/contributors) who participated in this project.\n\n\u003c/br\u003e\n\n## Acknowledgements\n\n* [NLTK documentation](https://www.nltk.org)\n* [TextBlob documentations](https://textblob.readthedocs.io/en/dev/quickstart.html#sentiment-analysis)\n* [Twitter Sentiment Analysis - Learn Python for Data Science](https://www.youtube.com/watch?v=o_OZdbCzHUA)\n* [Twitter Sentiment Analysis using Python](https://www.geeksforgeeks.org/twitter-sentiment-analysis-using-python/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frajatdiptabiswas%2Ftwitter-sentiment-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frajatdiptabiswas%2Ftwitter-sentiment-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frajatdiptabiswas%2Ftwitter-sentiment-analysis/lists"}