Filter out phantoms from bottom pagerank

This commit is contained in:
Tim Van Baak 2018-11-04 00:07:43 -07:00
parent 56421820bb
commit e6293eab50
1 changed files with 7 additions and 2 deletions

View File

@ -258,7 +258,13 @@ def build_statistics_page(page, articles):
content += "<br>\n".join(cited_times_items) content += "<br>\n".join(cited_times_items)
content += "</div>\n" content += "</div>\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) pageranks = reverse_statistics_dict(rank_by_article)
bot_ranked = list(enumerate(map(lambda x: x[1], pageranks), start=1))[-10:] bot_ranked = list(enumerate(map(lambda x: x[1], pageranks), start=1))[-10:]
# Format the ranks into strings # Format the ranks into strings
@ -268,7 +274,6 @@ def build_statistics_page(page, articles):
content += "<br>\n".join(bot_ranked_items) content += "<br>\n".join(bot_ranked_items)
content += "</div>\n" content += "</div>\n"
# Fill in the entry skeleton # Fill in the entry skeleton
return page.format(title="Statistics", content=content) return page.format(title="Statistics", content=content)