From 710117fbe986907d3ba17f6c6e69e24d91c4926b Mon Sep 17 00:00:00 2001 From: josh herzberg Date: Tue, 5 Nov 2019 20:40:10 -0600 Subject: [PATCH] i still don't understand how these imports work --- lib/tagnews/__init__.py | 3 ++- lib/tagnews/senteval/__init__.py | 4 ++-- lib/tagnews/senteval/eval.py | 6 +++--- lib/tagnews/senteval/police_words.py | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/tagnews/__init__.py b/lib/tagnews/__init__.py index dc14179..c90d3ca 100644 --- a/lib/tagnews/__init__.py +++ b/lib/tagnews/__init__.py @@ -6,8 +6,9 @@ from .utils.load_data import load_data from .utils.load_vectorizer import load_glove from .senteval.eval import SentimentGoogler +from .senteval.police_words import police_words_list, bins __all__ = [utils, crimetype, CrimeTags, GeoCoder, SentimentGoogler, - get_lat_longs_from_geostrings, load_data, load_glove] + get_lat_longs_from_geostrings, load_data, load_glove, police_words_list, bins] __version__ = '1.2.4' diff --git a/lib/tagnews/senteval/__init__.py b/lib/tagnews/senteval/__init__.py index 7b13ead..3611eaa 100644 --- a/lib/tagnews/senteval/__init__.py +++ b/lib/tagnews/senteval/__init__.py @@ -1,3 +1,3 @@ -from . import eval +from . import eval, police_words -__all__ = [eval] +__all__ = [eval, police_words] diff --git a/lib/tagnews/senteval/eval.py b/lib/tagnews/senteval/eval.py index 5d05171..6eb3b3b 100644 --- a/lib/tagnews/senteval/eval.py +++ b/lib/tagnews/senteval/eval.py @@ -2,7 +2,7 @@ from google.cloud.language import enums from google.cloud.language import types -from tagnews.senteval import police_words, bins +from tagnews.senteval.police_words import police_words_list, bins def process_google_result(text): @@ -12,7 +12,7 @@ def process_google_result(text): for entity in sentiment.entities: clean_entity = "".join(filter(str.isalpha, entity)).lower() - if clean_entity in police_words: + if clean_entity in police_words_list: for mention in entity.mentions: return mention.sentiment.score @@ -21,7 +21,7 @@ def process_google_result(text): class SentimentGoogler: def __init__(self): self.client = self.connect_to_client() - self.police_words = police_words + self.police_words = police_words_list def run(self, doc_text): sentiment_ = self.call_api(doc_text) diff --git a/lib/tagnews/senteval/police_words.py b/lib/tagnews/senteval/police_words.py index cd48183..93e770e 100644 --- a/lib/tagnews/senteval/police_words.py +++ b/lib/tagnews/senteval/police_words.py @@ -1,3 +1,3 @@ -police_words = ["police", "officer", "cop", "officers", "pigs"] +police_words_list = ["police", "officer", "cop", "officers", "pigs"] bins = [.1, .2, .3, .4, .5, .6, .7, .8, .9, 1] \ No newline at end of file