From 8d48481fec3d1a9569df2b837d741997bae62ea8 Mon Sep 17 00:00:00 2001 From: Sanchit Garg Date: Mon, 18 Nov 2019 13:52:10 +0530 Subject: [PATCH 01/13] compatibility for pip >=10 --- setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 19d88a0..d2424b2 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,11 @@ from setuptools import setup, find_packages from codecs import open from os import path -from pip.req import parse_requirements + +try: # for pip >= 10 + from pip._internal.req import parse_requirements +except ImportError: # for pip <= 9.0.3 + from pip.req import parse_requirements here = path.abspath(path.dirname(__file__)) From 05fe2fb764595fbd2ca1392c3798ed5c67e6089d Mon Sep 17 00:00:00 2001 From: Sanchit Garg Date: Mon, 18 Nov 2019 17:56:56 +0530 Subject: [PATCH 02/13] updating circleci config --- .circleci/config.yml | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f0464ec..5278eb3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,18 +3,14 @@ version: 2 jobs: build: docker: - - image: phusion/baseimage + - image: circleci/openjdk:8-jdk working_directory: ~/circulate steps: - run: name: Install Python Pip JDK command: | apt-get -qq update - apt-get -y install git openssh-client python python-pip python-dev software-properties-common - add-apt-repository -y ppa:openjdk-r/ppa - apt-get update && apt-get install -y openjdk-8-jdk - export JDK_HOME=/usr/lib/jvm/java-8-openjdk-amd64 - export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 + apt-get -y install git openssh-client python3 python3-pip python3-dev software-properties-common - checkout - run: name: Private Pypi Config Setup @@ -28,30 +24,30 @@ jobs: - run: name: Pre-install Virtual Env command: | - pip install virtualenv - virtualenv venv + pip3 install virtualenv + virtualenv -p python3 venv - restore_cache: - key: deps2.7-{{ .Branch }}-{{ checksum "requirements.txt" }} + key: deps3.5-{{ .Branch }}-{{ checksum "requirements.txt" }} - run: name: Install Dependencies command: | . venv/bin/activate - export JDK_HOME=/usr/lib/jvm/java-8-openjdk-amd64 - export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 - pip install -U pip wheel setuptools - pip install cython - pip install coveralls - pip install -r requirements.txt --extra-index-url $PYPI_HOST + export JDK_HOME=/usr/local/openjdk-8 + export JAVA_HOME=/usr/local/openjdk-8 + pip3 install -U pip wheel setuptools + pip3 install cython + pip3 install coveralls + pip3 install -r requirements.txt --extra-index-url $PYPI_HOST - save_cache: - key: deps2.7-{{ .Branch }}-{{ checksum "requirements.txt" }} + key: deps3.5-{{ .Branch }}-{{ checksum "requirements.txt" }} paths: - "venv" - run: name: Test command: | . venv/bin/activate - export JDK_HOME=/usr/lib/jvm/java-8-openjdk-amd64 - export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 + export JDK_HOME=/usr/local/openjdk-8 + export JAVA_HOME=/usr/local/openjdk-8 coverage run --source=emoint -m unittest discover -v coverage report COVERALLS_REPO_TOKEN=$COVERALLS_REPO_TOKEN coveralls --verbose @@ -59,8 +55,8 @@ jobs: name: Push To Private Pypi Server command: | . venv/bin/activate - python setup.py bdist_wheel upload -r $PYPI_HOST - python setup.py sdist upload -r $PYPI_HOST + python3 setup.py bdist_wheel upload -r $PYPI_HOST + python3 setup.py sdist upload -r $PYPI_HOST - store_artifacts: path: test-reports/ destination: tr1 From 20a61da658d8e014171e0caf02fa7cf4102d8722 Mon Sep 17 00:00:00 2001 From: Sanchit Garg Date: Mon, 18 Nov 2019 18:09:46 +0530 Subject: [PATCH 03/13] fixing build break --- .circleci/config.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5278eb3..6a090c4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,8 +9,8 @@ jobs: - run: name: Install Python Pip JDK command: | - apt-get -qq update - apt-get -y install git openssh-client python3 python3-pip python3-dev software-properties-common + sudo apt-get -qq update + sudo apt-get -y install git openssh-client python3 python3-pip python3-dev software-properties-common - checkout - run: name: Private Pypi Config Setup @@ -25,13 +25,13 @@ jobs: name: Pre-install Virtual Env command: | pip3 install virtualenv - virtualenv -p python3 venv + virtualenv -p python3 ~/venv - restore_cache: key: deps3.5-{{ .Branch }}-{{ checksum "requirements.txt" }} - run: name: Install Dependencies command: | - . venv/bin/activate + . ~/venv/bin/activate export JDK_HOME=/usr/local/openjdk-8 export JAVA_HOME=/usr/local/openjdk-8 pip3 install -U pip wheel setuptools @@ -54,7 +54,7 @@ jobs: - run: name: Push To Private Pypi Server command: | - . venv/bin/activate + . ~/venv/bin/activate python3 setup.py bdist_wheel upload -r $PYPI_HOST python3 setup.py sdist upload -r $PYPI_HOST - store_artifacts: From 14ab7bb8b9e32dd0aeffbe082f0c302c19140f04 Mon Sep 17 00:00:00 2001 From: Sanchit Garg Date: Mon, 18 Nov 2019 19:55:50 +0530 Subject: [PATCH 04/13] env vars fixes --- .circleci/config.yml | 2 +- requirements.txt | 5 +++-- setup.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6a090c4..4886625 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,7 +37,7 @@ jobs: pip3 install -U pip wheel setuptools pip3 install cython pip3 install coveralls - pip3 install -r requirements.txt --extra-index-url $PYPI_HOST + pip3 install -r requirements.txt - save_cache: key: deps3.5-{{ .Branch }}-{{ checksum "requirements.txt" }} paths: diff --git a/requirements.txt b/requirements.txt index 87fd2b9..f296f41 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ ---extra-index-url $PYPI_HOST +--extra-index-url $PYPI_HOST_WITH_CRED +--trusted-host pypi.deepaffects.com Cython xgboost sklearn @@ -6,5 +7,5 @@ pandas scipy numpy pyjnius -tweetokenize +tweetokenize==1.1.0 nltk diff --git a/setup.py b/setup.py index d2424b2..da7b8a0 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ setup( name='EmoInt', - version='0.1.0', + version='0.1.1', description='Affective Computing', long_description=long_description, url='https://github.com/seernet/EmoInt', From 2ec979d905812fe5c78e8d3b2958e61f136d72da Mon Sep 17 00:00:00 2001 From: Sanchit Garg Date: Tue, 19 Nov 2019 14:38:44 +0530 Subject: [PATCH 05/13] using orignial host name --- .circleci/config.yml | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4886625..0e7147c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -41,7 +41,7 @@ jobs: - save_cache: key: deps3.5-{{ .Branch }}-{{ checksum "requirements.txt" }} paths: - - "venv" + - "~/venv" - run: name: Test command: | diff --git a/requirements.txt b/requirements.txt index f296f41..309fb5b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ ---extra-index-url $PYPI_HOST_WITH_CRED +--extra-index-url $PYPI_HOST --trusted-host pypi.deepaffects.com Cython xgboost From b7f6453965388afa5708f54c97bb91ea24245fb6 Mon Sep 17 00:00:00 2001 From: Sanchit Garg Date: Tue, 19 Nov 2019 14:56:42 +0530 Subject: [PATCH 06/13] retrying with creds in hostname --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 309fb5b..4b109e1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ ---extra-index-url $PYPI_HOST --trusted-host pypi.deepaffects.com +--extra-index-url $PYPI_HOST_WITH_CRED Cython xgboost sklearn From 6f983627f4223cb1d473f7d0b8e23876f1740d71 Mon Sep 17 00:00:00 2001 From: Sanchit Garg Date: Tue, 19 Nov 2019 15:03:32 +0530 Subject: [PATCH 07/13] moving var --extra-index-url to config --- .circleci/config.yml | 2 +- requirements.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0e7147c..7b96852 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,7 +37,7 @@ jobs: pip3 install -U pip wheel setuptools pip3 install cython pip3 install coveralls - pip3 install -r requirements.txt + pip3 install --extra-index-url $PYPI_HOST -r requirements.txt - save_cache: key: deps3.5-{{ .Branch }}-{{ checksum "requirements.txt" }} paths: diff --git a/requirements.txt b/requirements.txt index 4b109e1..3ed621d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ --trusted-host pypi.deepaffects.com ---extra-index-url $PYPI_HOST_WITH_CRED Cython xgboost sklearn From 270d4ecbc0a5ac2eaac45973876064aca4b2b4e0 Mon Sep 17 00:00:00 2001 From: Sanchit Garg Date: Tue, 19 Nov 2019 15:06:39 +0530 Subject: [PATCH 08/13] updating the path of venv --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7b96852..89a432d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,7 +45,7 @@ jobs: - run: name: Test command: | - . venv/bin/activate + . ~/venv/bin/activate export JDK_HOME=/usr/local/openjdk-8 export JAVA_HOME=/usr/local/openjdk-8 coverage run --source=emoint -m unittest discover -v From 9ad3b6161d078ce49017bc12fc1066eb532e8b19 Mon Sep 17 00:00:00 2001 From: Sanchit Garg Date: Tue, 19 Nov 2019 16:04:47 +0530 Subject: [PATCH 09/13] test module fix --- emoint/featurizers/liwc_featurizer.py | 2 +- emoint/tests/test_ensembles.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/emoint/featurizers/liwc_featurizer.py b/emoint/featurizers/liwc_featurizer.py index b510e61..fc4980a 100644 --- a/emoint/featurizers/liwc_featurizer.py +++ b/emoint/featurizers/liwc_featurizer.py @@ -6,7 +6,7 @@ from emoint.featurizers.base_featurizers import Featurizer from emoint.utils.utils import LIWCTrie -from utils import liwc_lexicon_path +from .utils import liwc_lexicon_path """ Info: http://liwc.wpengine.com/ diff --git a/emoint/tests/test_ensembles.py b/emoint/tests/test_ensembles.py index 0ccd168..3087393 100644 --- a/emoint/tests/test_ensembles.py +++ b/emoint/tests/test_ensembles.py @@ -25,7 +25,7 @@ def helper(self, func, ens_type, out_file, expected, w=None): with open(out_file, 'r') as f: got = f.read().splitlines() self.assertListEqual( - [float(x) for x in got], + [round(float(x), 1) for x in got], expected, msg='Expected: {} != Got: {}'.format(expected, got) ) From 847a54217591c34545d0da260b3cadf4fc0bb2a7 Mon Sep 17 00:00:00 2001 From: Sanchit Garg Date: Tue, 19 Nov 2019 17:58:08 +0530 Subject: [PATCH 10/13] str byte compatibility changes --- emoint/featurizers/base_featurizers.py | 5 ++++- emoint/featurizers/emoji_sentiment_ranking_featurizer.py | 5 ++++- emoint/featurizers/liwc_featurizer.py | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/emoint/featurizers/base_featurizers.py b/emoint/featurizers/base_featurizers.py index 0b47296..1cac4b7 100644 --- a/emoint/featurizers/base_featurizers.py +++ b/emoint/featurizers/base_featurizers.py @@ -94,7 +94,10 @@ def create_embedding_mapping(lexicon_path, word_first=True, leave_head=False): lines = lines[1:] lexicon_map = {} for l in lines: - splits = l.split(' ') + if isinstance(l, str): + splits = l.split(' ') + else: + splits = l.decode('utf-8').split('\t') if word_first: lexicon_map[splits[0]] = np.asarray(splits[1:], dtype='float32') else: diff --git a/emoint/featurizers/emoji_sentiment_ranking_featurizer.py b/emoint/featurizers/emoji_sentiment_ranking_featurizer.py index 9629fbc..286772c 100644 --- a/emoint/featurizers/emoji_sentiment_ranking_featurizer.py +++ b/emoint/featurizers/emoji_sentiment_ranking_featurizer.py @@ -34,7 +34,10 @@ def create_lexicon_mapping(lexicons_path): rows = csv.DictReader(open(lexicons_path), ) emoji_map = {} for row in rows: - emoji_map[row['Emoji'].decode('utf-8')] = [ + tmp = row['Emoji'] + if not isinstance(tmp, str): + tmp = row['Emoji'].decode('utf-8') + emoji_map[tmp] = [ float(row['Negative'])/float(row['Occurrences']), float(row['Positive'])/float(row['Occurrences']), float(row['Neutral'])/float(row['Occurrences']) diff --git a/emoint/featurizers/liwc_featurizer.py b/emoint/featurizers/liwc_featurizer.py index fc4980a..f767618 100644 --- a/emoint/featurizers/liwc_featurizer.py +++ b/emoint/featurizers/liwc_featurizer.py @@ -40,7 +40,7 @@ def create_lexicon_mapping(lexicon_path): liwc_trie.insert(pair[0], pair[1]) except Exception as ex: pass - return categories.values(), liwc_trie + return list(categories.values()), liwc_trie def __init__(self, lexicons_path=liwc_lexicon_path): """Initialize LIWC Lexicon Featurizer @@ -80,7 +80,8 @@ def set_punctuation_counts(self, text, liwc): def featurize(self, text, tokenizer): liwc = {} - text = text.decode('utf8') + if not isinstance(text, str): + text = text.decode('utf8') num_capital_words = len(re.findall(r"[A-Z]['A-Z]*", text)) words = re.findall(r"[a-z]['a-z]*", text.lower()) From c35928610ba2e690ab165d03f3d94f54d2582fdb Mon Sep 17 00:00:00 2001 From: Sanchit Garg Date: Wed, 20 Nov 2019 11:50:30 +0530 Subject: [PATCH 11/13] just to change the cache for circleci --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 3ed621d..041d00c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,5 @@ pandas scipy numpy pyjnius -tweetokenize==1.1.0 nltk +tweetokenize==1.1.0 \ No newline at end of file diff --git a/setup.py b/setup.py index da7b8a0..50e100f 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ setup( name='EmoInt', - version='0.1.1', + version='0.1.2', description='Affective Computing', long_description=long_description, url='https://github.com/seernet/EmoInt', From 0ee95a0fd7c6191d0c2eb44ed1cdc46e0b990508 Mon Sep 17 00:00:00 2001 From: Sanchit Garg Date: Wed, 20 Nov 2019 11:55:55 +0530 Subject: [PATCH 12/13] using pypi host with cred --- .circleci/config.yml | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 89a432d..63b97c9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,7 +37,7 @@ jobs: pip3 install -U pip wheel setuptools pip3 install cython pip3 install coveralls - pip3 install --extra-index-url $PYPI_HOST -r requirements.txt + pip3 install --extra-index-url $PYPI_HOST_WITH_CRED -r requirements.txt - save_cache: key: deps3.5-{{ .Branch }}-{{ checksum "requirements.txt" }} paths: diff --git a/requirements.txt b/requirements.txt index 041d00c..0fa0652 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,4 @@ scipy numpy pyjnius nltk -tweetokenize==1.1.0 \ No newline at end of file +tweetokenize==1.1.0 From b5bd5e25c4018d0a1194b2ad8a93f0f124fa627e Mon Sep 17 00:00:00 2001 From: Sanchit Garg Date: Wed, 20 Nov 2019 12:04:17 +0530 Subject: [PATCH 13/13] travis ci changes --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5ac39fa..cb0ba58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,11 @@ language: python python: - - "2.7" + - "3.5" install: - - pip install -U pip wheel setuptools - - pip install coveralls --quiet - - pip install cython --quiet - - pip install -r requirements.txt --extra-index-url $PYPI_HOST --quiet + - pip3 install -U pip wheel setuptools + - pip3 install coveralls --quiet + - pip3 install cython --quiet + - pip3 install -r requirements.txt --extra-index-url $PYPI_HOST_WITH_CRED --quiet script: coverage run --source=. -m unittest discover -v