From 6812b51648b3a1d7d1bd69f1fe9fef489d5e0900 Mon Sep 17 00:00:00 2001 From: Maximilian Blunck <blunck@cl.uni-heidelberg.de> Date: Wed, 17 Jan 2018 17:19:32 +0100 Subject: [PATCH] Bug fix --- contrast_feature.py | 7 +++---- ngram_feature.py | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/contrast_feature.py b/contrast_feature.py index e2ef84a..224a77c 100644 --- a/contrast_feature.py +++ b/contrast_feature.py @@ -49,10 +49,9 @@ def extract(corpus_instance): sent_verb = analyser.polarity_scores(verb)['compound'] sent_situation = analyser.polarity_scores(situation)['compound'] - if (sent_verb > 0.0 and sent_situation < 0.0) or (sent_verb < 0.0 and sent_situation > 0.0): - print("phrase: {} {} sent verb: {} sent situation: {}".format(verb, situation, sent_verb, sent_situation)) - - + #if (sent_verb > 0.0 and sent_situation < 0.0) or (sent_verb < 0.0 and sent_situation > 0.0): + print("phrase: {} {} sent verb: {} sent situation: {}".format(verb, situation, sent_verb, sent_situation)) + if __name__ == '__main__': corpus = corpus.read_corpus("corpus_shuffled.csv")[:1000] diff --git a/ngram_feature.py b/ngram_feature.py index 2a5354d..7a940d9 100644 --- a/ngram_feature.py +++ b/ngram_feature.py @@ -15,7 +15,7 @@ def extract(corpus_instance, corpus_dict_key, vocabulary): return vector.toarray()[0] -def get_vocabulary(corpus, corpus_dict_key, n): +def get_vocabulary(corpus, corpus_dict_key, n_range): """ Creates vocabulary based on given corpus. """ @@ -23,7 +23,7 @@ def get_vocabulary(corpus, corpus_dict_key, n): for line in corpus: all_reviews.append(line[corpus_dict_key]) - vectorizer = CountVectorizer(ngram_range=(n, n)) + vectorizer = CountVectorizer(ngram_range=n_range) vectorizer.fit(all_reviews) return vectorizer.vocabulary_ -- GitLab