From e6293eab5054820f6518a06b6652067afb5dee98 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Sun, 4 Nov 2018 00:07:43 -0700 Subject: [PATCH] Filter out phantoms from bottom pagerank --- src/build.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/build.py b/src/build.py index 39e535a..1fe8a6e 100644 --- a/src/build.py +++ b/src/build.py @@ -258,7 +258,13 @@ def build_statistics_page(page, articles): content += "
\n".join(cited_times_items) content += "\n" - # Lowest pagerank + # Lowest pagerank of written articles + G = networkx.Graph() + for article in articles: + for citation in article.citations: + if citation.article.player is not None: + G.add_edge(article.title, citation.target) + rank_by_article = networkx.pagerank(G) pageranks = reverse_statistics_dict(rank_by_article) bot_ranked = list(enumerate(map(lambda x: x[1], pageranks), start=1))[-10:] # Format the ranks into strings @@ -268,7 +274,6 @@ def build_statistics_page(page, articles): content += "
\n".join(bot_ranked_items) content += "\n" - # Fill in the entry skeleton return page.format(title="Statistics", content=content)