diff --git a/batch/batchFetchPatterns.py b/batch/batchFetchPatterns.py index 7dd2b27..4ac3853 100644 --- a/batch/batchFetchPatterns.py +++ b/batch/batchFetchPatterns.py @@ -58,18 +58,17 @@ def update_progress_bar(n_cur, n_total, bar_length=50): weighted = True for udocId, emotion in docs: - if loglevel <= logging.INFO: - update_progress_bar(udocId, len(docs)) + update_progress_bar(udocId, len(docs)) pattern_freq_vec = pf.get_pattern_freq_by_udocId(udocId, min_count, weighted) # sum vectors horizontally if args.scoring: - sum_vec = pf.sum_pattern_score_vector(pattern_freq_vec, args.vlambda) + emotion_vec = pf.sum_pattern_score_vector(pattern_freq_vec, args.vlambda) else: - sum_vec = pf.sum_pattern_freq_vector(pattern_freq_vec) + emotion_vec = pf.sum_pattern_freq_vector(pattern_freq_vec) - X.append(sum_vec) + X.append(emotion_vec) y.append(emotion) logging.info('save to "%s"' % (args.output_file)) diff --git a/feelit/features.py b/feelit/features.py index 22eca3a..e8654eb 100644 --- a/feelit/features.py +++ b/feelit/features.py @@ -194,8 +194,8 @@ def _sum_pattern_vector(self, pf, use_score=False, vlambda=1.0): temp_vec = freq_vec.values() sum_vec = map(add, sum_vec, temp_vec) - - return sum_vec + + return [v/len(pf) for v in sum_vec] def sum_pattern_freq_vector(self, pf): """