{"id":1092,"date":"2019-01-29T19:17:51","date_gmt":"2019-01-29T10:17:51","guid":{"rendered":"http:\/\/www.robfahey.co.uk\/blog\/?page_id=1092"},"modified":"2019-01-31T18:19:42","modified_gmt":"2019-01-31T09:19:42","slug":"sentiment-analysis-in-python","status":"publish","type":"page","link":"http:\/\/www.robfahey.co.uk\/blog\/sentiment-analysis-in-python\/","title":{"rendered":"Sentiment Analysis in Python (2019)"},"content":{"rendered":"\n<p style=\"text-align:right\" class=\"has-medium-font-size\"><strong>(Data Science Week @ Waseda 2019)<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Slides from the Workshop<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>You can access the Powerpoint slides from the workshop on Slideshare: <a href=\"https:\/\/www.slideshare.net\/RobertFahey3\/sentiment-analysis-in-python-waseda-data-science-week-2019\">https:\/\/www.slideshare.net\/RobertFahey3\/sentiment-analysis-in-python-waseda-data-science-week-2019<\/a><\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Example Code and Data<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"http:\/\/robfahey.co.uk\/sentiment_workshop.zip\">sentiment_workshop.zip<\/a> &#8211; this file contains the example code and data used in the workshop. Unzip the file into a directory you can easily find, then open the code using the &#8220;Jupyter Lab&#8221; component in Anaconda.<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Packages used in the workshop<\/h2>\n\n\n\n<p>Most of these packages are already installed in the standard Anaconda distribution, but if you install your Python distribution from somewhere else (or if you&#8217;re using it on a server), you may need to install these directly using the <em>pip install<\/em> command.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>numpy<\/li><li>pandas<\/li><li>scipy<\/li><li>scikit-learn<\/li><li>nltk<\/li><li>matplotlib   <em>(only required for drawing graphs and charts)<\/em><\/li><li>quadprog   <em>(only required for using the iSA aggregate algorithm)<\/em><\/li><\/ul>\n\n\n\n<p>You can find the Python version of the iSA aggregate algorithm on <a href=\"https:\/\/github.com\/robfahey\">my Github page<\/a>.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Word Segmentation in non-European languages<\/h2>\n\n\n\n<p>For those working in non-European languages, you&#8217;ll need to use additional software to divide up sentences into words (<em>tokens<\/em>) and perform functions like stemming or identifying part-of-speech (nouns, verbs etc.).<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Japanese<\/strong>: <a href=\"http:\/\/taku910.github.io\/mecab\/\">MeCab<\/a> (install on your computer, then use the <a href=\"https:\/\/github.com\/SamuraiT\/mecab-python3\">mecab-python<\/a> package to access it from Python), ChaSen\/<a href=\"http:\/\/taku910.github.io\/cabocha\/\">CaboCha<\/a> or <a href=\"https:\/\/github.com\/mocobeta\/janome\">Janome<\/a>. If you&#8217;re using data from Twitter, you may find <a href=\"https:\/\/github.com\/robfahey\/ja_tokeniser\">this short script<\/a> I wrote useful &#8211; it&#8217;ll correctly identify things like web addresses, usernames, emoji and kaomoji, which MeCab would otherwise skip or make mistakes with.<\/li><li><strong>Chinese<\/strong> (or <strong>Arabic<\/strong>): the <a href=\"https:\/\/nlp.stanford.edu\/software\/segmenter.shtml\">Stanford Word Segmenter<\/a><\/li><li><strong>Korean<\/strong>: <a href=\"https:\/\/github.com\/open-korean-text\/open-korean-text\">open-korean-text<\/a> was recommended by some colleagues, though I haven&#8217;t used it.<\/li><li><strong>Thai<\/strong>: There is a package called <a href=\"https:\/\/github.com\/PyThaiNLP\/pythainlp\">PyThaiNLP<\/a> which looks like a pretty comprehensive language processing system for Thai text. Another package called <a href=\"https:\/\/github.com\/pucktada\/cutkum\">cutkum<\/a> looks like a promising project for carrying out accurate word segmentation.<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n","protected":false},"excerpt":{"rendered":"<p>(Data Science Week @ Waseda 2019) Slides from the Workshop You can access the Powerpoint slides from the workshop on Slideshare: https:\/\/www.slideshare.net\/RobertFahey3\/sentiment-analysis-in-python-waseda-data-science-week-2019 Example Code and Data sentiment_workshop.zip &#8211; this file contains the example code and data used in the workshop. Unzip the file into a directory you can easily find, then open the code using &hellip;<\/p>\n<p><a href=\"http:\/\/www.robfahey.co.uk\/blog\/sentiment-analysis-in-python\/\" class=\"more-link\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1092","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/P71QYy-hC","jetpack-related-posts":[{"id":920,"url":"http:\/\/www.robfahey.co.uk\/blog\/social-media-data-workshop-waseda\/","url_meta":{"origin":1092,"position":0},"title":"Using Social Media Data in Political Science Research (2016)","author":"Rob Fahey","date":"07\/12\/2016","format":false,"excerpt":"Workshop @ Waseda University, 2016\/12\/07 This page includes a listing of all of the software and packages mentioned during the workshop, as well as a few others you may find useful. I'll link to detailed guides I've written about this topic, and update the lists as I write more in\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":11,"url":"http:\/\/www.robfahey.co.uk\/blog\/about-me\/","url_meta":{"origin":1092,"position":1},"title":"About Me","author":"Rob Fahey","date":"09\/01\/2012","format":false,"excerpt":"I'm Rob Fahey. I'm an Assistant Professor at the Waseda Institute for Advanced Study (WIAS) at Waseda University in Tokyo, where I work on contemporary politics and political communication, and a Visiting Professor at the Department of Social and Political Sciences at the University of Milan, where I teach courses\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1243,"url":"http:\/\/www.robfahey.co.uk\/blog\/publications\/","url_meta":{"origin":1092,"position":2},"title":"Publications","author":"Rob Fahey","date":"09\/05\/2022","format":false,"excerpt":"Journal Papers Hino A, Ogawa H, Fahey RA, and Liu L (2022), Japan: Political Developments and Data in 2021. European Journal of Political Research Political Data Yearbook.Jungkunz S, Fahey RA, Hino A (2021), How populist attitude scales fail to capture support for populists in power, PLOS One 16 (12): e0261658.Fahey\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1161,"url":"http:\/\/www.robfahey.co.uk\/blog\/social-network-analysis-unimi\/","url_meta":{"origin":1092,"position":3},"title":"Social Network Analysis &#8211; University of Milan (2022)","author":"Rob Fahey","date":"28\/02\/2021","format":false,"excerpt":"Autumn Term Week 1 (October 17-21) DateClass MaterialsAssignmentMonday, October 17 (10:00)SlidesAssignmentTuesday, October 18 (On-Demand)On-Demand LectureSlidesAssignment Week 2 (October 24-28) DateClass MaterialsAssignmentMonday, October 24 (10:00)R Script & DataAssignmentTuesday, October 25 (10:00)R Script & DataAssignmentWednesday, October 26 (On-Demand)On-Demand LectureR Script & DataAssignment Week 3 (November 7-11) DateClass MaterialsAssignmentMonday, November 7 (10:00)SlidesR ScriptAssignmentTuesday,\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":117,"url":"http:\/\/www.robfahey.co.uk\/blog\/sns-polcom-analysis\/","url_meta":{"origin":1092,"position":4},"title":"SNS PolCom Analysis","author":"Rob Fahey","date":"11\/12\/2014","format":false,"excerpt":"This is a holding page for a set of Python \/ MongoDB \/ Google BigQuery\u00a0tools I am building to analyse the use of social media\u00a0platforms by political actors in Japan.","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/www.robfahey.co.uk\/blog\/wp-json\/wp\/v2\/pages\/1092","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.robfahey.co.uk\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.robfahey.co.uk\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.robfahey.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.robfahey.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=1092"}],"version-history":[{"count":7,"href":"http:\/\/www.robfahey.co.uk\/blog\/wp-json\/wp\/v2\/pages\/1092\/revisions"}],"predecessor-version":[{"id":1104,"href":"http:\/\/www.robfahey.co.uk\/blog\/wp-json\/wp\/v2\/pages\/1092\/revisions\/1104"}],"wp:attachment":[{"href":"http:\/\/www.robfahey.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=1092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}