From 87df1b748087442ad0ecb9cf9296f6d749baa43f Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Fri, 2 Nov 2018 00:50:34 -0700 Subject: [PATCH] Fix pagerank crashing on citationless articles --- src/build.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/build.py b/src/build.py index 40413e5..02b6db9 100644 --- a/src/build.py +++ b/src/build.py @@ -205,10 +205,12 @@ def build_statistics_page(page, articles): pagerank_by_player = {player: 0 for player in players} for article in articles: if article.player is not None: - pagerank_by_player[article.player] += rank_by_article[article.title] + pagerank_by_player[article.player] += (rank_by_article[article.title] + if article.title in rank_by_article else 0) for addendum in article.addendums: addendum_title = "{0.title}-T{0.turn}".format(addendum) - pagerank_by_player[addendum_title] += rank_by_article[addendum_title] + pagerank_by_player[addendum_title] += (rank_by_article[addendum_title] + if addendum_title in rank_by_article else 0) for player in players: pagerank_by_player[player] = round(pagerank_by_player[player], 3) player_rank = reverse_statistics_dict(pagerank_by_player)