itmove credentials to its own file, add makefile - counterfacto - small software tool to analyze twitter and highlight counterfactual statements Err parazyd.org 70 hgit clone git://parazyd.org/counterfacto.git URL:git://parazyd.org/counterfacto.git parazyd.org 70 1Log /git/counterfacto/log.gph parazyd.org 70 1Files /git/counterfacto/files.gph parazyd.org 70 1Refs /git/counterfacto/refs.gph parazyd.org 70 1README /git/counterfacto/file/README.md.gph parazyd.org 70 1LICENSE /git/counterfacto/file/LICENSE.gph parazyd.org 70 i--- Err parazyd.org 70 1commit c197f14a541519e2e261e6ff6bebbfaf742181d0 /git/counterfacto/commit/c197f14a541519e2e261e6ff6bebbfaf742181d0.gph parazyd.org 70 1parent 96a0a3e5c2992c9c5b687762972a385773f51061 /git/counterfacto/commit/96a0a3e5c2992c9c5b687762972a385773f51061.gph parazyd.org 70 hAuthor: parazyd URL:mailto:parazyd@dyne.org parazyd.org 70 iDate: Mon, 2 Jan 2017 20:07:15 +0100 Err parazyd.org 70 i Err parazyd.org 70 imove credentials to its own file, add makefile Err parazyd.org 70 i Err parazyd.org 70 iDiffstat: Err parazyd.org 70 i A .gitignore | 2 ++ Err parazyd.org 70 i A Makefile | 11 +++++++++++ Err parazyd.org 70 i M README.md | 57 +++++++++++++++++++++---------- Err parazyd.org 70 i M counterfacto | 15 ++++++++------- Err parazyd.org 70 i Err parazyd.org 70 i4 files changed, 60 insertions(+), 25 deletions(-) Err parazyd.org 70 i--- Err parazyd.org 70 1diff --git a/.gitignore b/.gitignore /git/counterfacto/file/.gitignore.gph parazyd.org 70 it@@ -0,0 +1,2 @@ Err parazyd.org 70 i+credentials Err parazyd.org 70 i+twokenize.pyc Err parazyd.org 70 1diff --git a/Makefile b/Makefile /git/counterfacto/file/Makefile.gph parazyd.org 70 it@@ -0,0 +1,11 @@ Err parazyd.org 70 i+all: Err parazyd.org 70 i+ @echo downloading python nltk tagger Err parazyd.org 70 i+ @python2 -c "import nltk; nltk.download('averaged_perceptron_tagger')" Err parazyd.org 70 i+ @echo Err parazyd.org 70 i+ @echo please create a file called credentials with the following data: Err parazyd.org 70 i+ @echo "oatoken = 'yourOAuthToken'" Err parazyd.org 70 i+ @echo "oasecret = 'yourOAuthSecret'" Err parazyd.org 70 i+ @echo "conskey = 'yourConsumerKey'" Err parazyd.org 70 i+ @echo "conssecret = 'yourConsSecret'" Err parazyd.org 70 i+ @echo Err parazyd.org 70 i+ @echo you can get these by creating a twitter app Err parazyd.org 70 1diff --git a/README.md b/README.md /git/counterfacto/file/README.md.gph parazyd.org 70 it@@ -3,17 +3,26 @@ Err parazyd.org 70 i Err parazyd.org 70 i Counterfactual (noun) Err parazyd.org 70 i Err parazyd.org 70 i-Definition: the tendency to create possible alternatives to life events that have already occurred; something that is contrary to what actually happened. Err parazyd.org 70 i+Definition: the tendency to create possible alternatives to life events Err parazyd.org 70 i+that have already occurred; something that is contrary to what actually Err parazyd.org 70 i+happened. Err parazyd.org 70 i Err parazyd.org 70 i-Effects: it starts off with disappointment, then one will be able to uncover insights or knowledge that can be used to enhance future performance, leading to a better outcome in life. Err parazyd.org 70 i+Effects: it starts off with disappointment, then one will be able to Err parazyd.org 70 i+uncover insights or knowledge that can be used to enhance future Err parazyd.org 70 i+performance, leading to a better outcome in life. Err parazyd.org 70 i Err parazyd.org 70 i ---------------------------------------------------------------------------------- Err parazyd.org 70 i Err parazyd.org 70 i-Counterfacto is a small software tool that can analyse search results on twitter to highlight counterfactual statements on certain topics. Err parazyd.org 70 i+Counterfacto is a small software tool that can analyse search results Err parazyd.org 70 i+on twitter to highlight counterfactual statements on certain topics. Err parazyd.org 70 i Err parazyd.org 70 i-This tool is used by PIEnews.eu researchers for sentiment analysis about poverty and other related topics, to understand actual stories elaborated as counterfactual. Err parazyd.org 70 i+This tool is used by PIEnews.eu researchers for sentiment analysis Err parazyd.org 70 i+about poverty and other related topics, to understand actual stories Err parazyd.org 70 i+elaborated as counterfactual. Err parazyd.org 70 i Err parazyd.org 70 i-We deem such a tool as a useful experiment, considering the importance of counterfactual analysis for political sentiment assessments and focus on news stories. Err parazyd.org 70 i+We deem such a tool as a useful experiment, considering the importance Err parazyd.org 70 i+of counterfactual analysis for political sentiment assessments and Err parazyd.org 70 i+focus on news stories. Err parazyd.org 70 i Err parazyd.org 70 i ## Dependencies Err parazyd.org 70 i Err parazyd.org 70 it@@ -23,28 +32,30 @@ Python is required along the following packages: Err parazyd.org 70 i python-twitter python-nltk Err parazyd.org 70 i ``` Err parazyd.org 70 i Err parazyd.org 70 i-Then run the `python` console in a terminal and type Err parazyd.org 70 i+Your distro may have an outdated nltk (less than 3.2) without the Err parazyd.org 70 i+perceptron module, in that case an update from `pip` is needed: Err parazyd.org 70 i Err parazyd.org 70 i ``` Err parazyd.org 70 i-import nltk Err parazyd.org 70 i-nltk.download('averaged_perceptron_tagger') Err parazyd.org 70 i+pip install nltk --upgrade Err parazyd.org 70 i ``` Err parazyd.org 70 i Err parazyd.org 70 i-This will download the nltk_data folder and place it in your `$HOME`. Err parazyd.org 70 i+After installing the necessary python modules, run `make`, which will Err parazyd.org 70 i+then download the needed data for nltk, and tell you how to use your Err parazyd.org 70 i+twitter credentials in counterfacto Err parazyd.org 70 i Err parazyd.org 70 i-Your distro may have an outdated nltk (less than 3.2) without the perceptron module, in that case an update from `pip` is needed: Err parazyd.org 70 i+## Usage Err parazyd.org 70 i Err parazyd.org 70 i ``` Err parazyd.org 70 i-pip install nltk --upgrade Err parazyd.org 70 i+usage: ./counterfacto [-a account] [-f tweetfile] [-s searchterm] Err parazyd.org 70 i ``` Err parazyd.org 70 i Err parazyd.org 70 i ## References Err parazyd.org 70 i Err parazyd.org 70 i-- Learning Representations for Counterfactual Inference (2016) http://jmlr.org/proceedings/papers/v48/johansson16.pdf Err parazyd.org 70 i+- [Learning Representations for Counterfactual Inference (2016)](http://jmlr.org/proceedings/papers/v48/johansson16.pdf) Err parazyd.org 70 i Err parazyd.org 70 i-- Bounding and Minimizing Counterfactual Error (2016) https://arxiv.org/abs/1606.03976 Err parazyd.org 70 i+- [Bounding and Minimizing Counterfactual Error (2016)](https://arxiv.org/abs/1606.03976) Err parazyd.org 70 i Err parazyd.org 70 i-- "Counterfactuals in the Language of Social Media: A Natural Language Processing Project in Conjunction with the World Well Being Project" (2015) http://www.seas.upenn.edu/~cse400/CSE400_2015_2016/reports/report_15.pdf Err parazyd.org 70 i+- [Counterfactuals in the Language of Social Media: A Natural Language Processing Project in Conjunction with the World Well Being Project (2015)](http://www.seas.upenn.edu/~cse400/CSE400_2015_2016/reports/report_15.pdf) Err parazyd.org 70 i Err parazyd.org 70 i ## Licensing Err parazyd.org 70 i Err parazyd.org 70 it@@ -54,10 +65,20 @@ as part of the PIEnews project Err parazyd.org 70 i Software written by Ivan J. Err parazyd.org 70 i with contributions by Denis Roio Err parazyd.org 70 i Err parazyd.org 70 i-This source code is free software; you can redistribute it and/or modify it under the terms of the GNU Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. Err parazyd.org 70 i+This source code is free software; you can redistribute it and/or Err parazyd.org 70 i+modify it under the terms of the GNU Public License as published by the Err parazyd.org 70 i+Free Software Foundation; either version 3 of the License, or (at your Err parazyd.org 70 i+option) any later version. Err parazyd.org 70 i Err parazyd.org 70 i-This source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Please refer to the GNU Public License for more details. Err parazyd.org 70 i+This source code is distributed in the hope that it will be useful, but Err parazyd.org 70 i+WITHOUT ANY WARRANTY; without even the implied warranty of Err parazyd.org 70 i+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Please refer to Err parazyd.org 70 i+the GNU Public License for more details. Err parazyd.org 70 i Err parazyd.org 70 i-You should have received a copy of the GNU Public License along with this source code; if not, write to: Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Err parazyd.org 70 i+You should have received a copy of the GNU Public License along with Err parazyd.org 70 i+this source code; if not, write to: Free Software Foundation, Inc., Err parazyd.org 70 i+Mass Ave, Cambridge, MA 02139, USA. Err parazyd.org 70 i Err parazyd.org 70 i-This project has received funding from the European Union’s Horizon 2020 Programme for research, technological development and demonstration under grant agreement nr. 687922 Err parazyd.org 70 i+This project has received funding from the European Union’s Horizon 2020 Err parazyd.org 70 i+Programme for research, technological development and demonstration under Err parazyd.org 70 i+grant agreement nr. 687922 Err parazyd.org 70 1diff --git a/counterfacto b/counterfacto /git/counterfacto/file/counterfacto.gph parazyd.org 70 it@@ -35,11 +35,12 @@ global tweetfile Err parazyd.org 70 i global taggedFile Err parazyd.org 70 i taggedFile = 'tagged.txt' Err parazyd.org 70 i Err parazyd.org 70 i-## get these by creating a twitter app Err parazyd.org 70 i-oatoken = '' Err parazyd.org 70 i-oasecret = '' Err parazyd.org 70 i-conskey = '' Err parazyd.org 70 i-conssecret = '' Err parazyd.org 70 i+try: Err parazyd.org 70 i+ with open('credentials') as fd: Err parazyd.org 70 i+ exec(fd.read()) Err parazyd.org 70 i+except: Err parazyd.org 70 i+ print('no credentials file found. please create it.') Err parazyd.org 70 i+ exit(1) Err parazyd.org 70 i Err parazyd.org 70 i Err parazyd.org 70 i def main(): Err parazyd.org 70 it@@ -103,7 +104,7 @@ def main(): Err parazyd.org 70 i classify(tweetfile) Err parazyd.org 70 i Err parazyd.org 70 i except: Err parazyd.org 70 i- print("usage: counterfacto [-a account] [-f tweetfile] [-s searchterm]") Err parazyd.org 70 i+ print("usage: " + sys.argv[0] + " [-a account] [-f tweetfile] [-s searchterm]") Err parazyd.org 70 i exit(1) Err parazyd.org 70 i Err parazyd.org 70 i ## {{{ processing functions Err parazyd.org 70 it@@ -300,6 +301,6 @@ def classify(tweetfile): Err parazyd.org 70 i tweetFile.close() Err parazyd.org 70 i tagFile.close() Err parazyd.org 70 i Err parazyd.org 70 i- print("counterfactuals: " + str(count)) Err parazyd.org 70 i+ print("counterfactuals: " + str(count) + "/100") Err parazyd.org 70 i Err parazyd.org 70 i main() Err parazyd.org 70 .