Skip to content

Commit

Permalink
Merge b5bd5e2 into b7da8fe
Browse files Browse the repository at this point in the history
  • Loading branch information
gargsanchit31 committed Nov 20, 2019
2 parents b7da8fe + b5bd5e2 commit 4678d81
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 40 deletions.
46 changes: 21 additions & 25 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
Expand All @@ -28,39 +24,39 @@ 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
. ~/venv/bin/activate
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 --extra-index-url $PYPI_HOST_WITH_CRED -r requirements.txt
- save_cache:
key: deps2.7-{{ .Branch }}-{{ checksum "requirements.txt" }}
key: deps3.5-{{ .Branch }}-{{ checksum "requirements.txt" }}
paths:
- "venv"
- "~/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
. ~/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
coverage report
COVERALLS_REPO_TOKEN=$COVERALLS_REPO_TOKEN coveralls --verbose
- run:
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
. ~/venv/bin/activate
python3 setup.py bdist_wheel upload -r $PYPI_HOST
python3 setup.py sdist upload -r $PYPI_HOST
- store_artifacts:
path: test-reports/
destination: tr1
Expand Down
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 4 additions & 1 deletion emoint/featurizers/base_featurizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion emoint/featurizers/emoji_sentiment_ranking_featurizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
7 changes: 4 additions & 3 deletions emoint/featurizers/liwc_featurizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion emoint/tests/test_ensembles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
--extra-index-url $PYPI_HOST
--trusted-host pypi.deepaffects.com
Cython
xgboost
sklearn
pandas
scipy
numpy
pyjnius
tweetokenize
nltk
tweetokenize==1.1.0
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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__))

Expand All @@ -13,7 +17,7 @@

setup(
name='EmoInt',
version='0.1.0',
version='0.1.2',
description='Affective Computing',
long_description=long_description,
url='https://github.com/seernet/EmoInt',
Expand Down

0 comments on commit 4678d81

Please sign in to comment.