diff --git a/date_selection.py b/date_selection.py index 34de4c08d98b66e5998de164a9c9e5aa94044385..b48c34a0e6ed40570a07c4031a4e95254ff23b95 100644 --- a/date_selection.py +++ b/date_selection.py @@ -15,8 +15,6 @@ def rank_dates_by_mention_count(articles, start_date, end_date): def rank_dates_by_wilson(articles, start_date, end_date): - edges = [] - # count how often each published -> mentioned pair occurs pub_to_mention_count = Counter({}) for article in articles: @@ -28,6 +26,7 @@ def rank_dates_by_wilson(articles, start_date, end_date): # the edge weight for each published -> mentioned pair # is how often it occurs * the temporal distance between the dates + edges = [] for pub_date, mentioned_date in pub_to_mention_count.keys(): date_diff = (datetime.strptime(pub_date, '%Y-%m-%d') - datetime.strptime(mentioned_date, '%Y-%m-%d')).days edge_weight = pub_to_mention_count[(pub_date, mentioned_date)] * abs(date_diff)