From ada2317435affe3f96e884ec4029e90a404db34f Mon Sep 17 00:00:00 2001
From: Tim Van Baak Top 10 pages by page rank: Top 10 pages by page rank: Most citations made from:
\n"
+ # Top pages by pagerank
+ # Compute pagerank for each article
G = networkx.Graph()
for citer, citeds in cite_map.items():
for cited in citeds:
G.add_edge(citer, cited)
- ranks = networkx.pagerank(G)
- sranks = sorted(ranks.items(), key=lambda x: x[1], reverse=True)
- ranking = list(enumerate(map(lambda x: x[0], sranks)))
- content += "
\n".join(map(lambda x: "{0} – {1}".format(x[0]+1, x[1]), ranking[:10]))
- content += "
\n"
+ content += "
\n".join(top_ranked_items)
+ content += "
\n"
- citation_tally = [(kv[0], len(kv[1])) for kv in cite_map.items()]
- citation_count = defaultdict(list)
- for title, count in citation_tally: citation_count[count].append(title)
- content += "
\n".join(map(
- lambda kv: "{0} – {1}".format(
- kv[0],
- "; ".join(sorted(
- kv[1],
- key=lambda t: utils.titlesort(t)))),
- sorted(citation_count.items(), reverse=True)[:3]))
- content += "
\n".join(top_citations_items)
+ content += "
Most citations made to:
\n"
- all_cited = set([title for cites in cite_map.values() for title in cites])
+ # Build a map of what cites each article
+ all_cited = set([title for citeds in cite_map.values() for title in citeds])
cited_by_map = {
cited: [
citer
for citer in cite_map.keys()
if cited in cite_map[citer]]
for cited in all_cited }
- cited_tally = [(kv[0], len(kv[1])) for kv in cited_by_map.items()]
- cited_count = defaultdict(list)
- for title, count in cited_tally: cited_count[count].append(title)
- content += "
\n".join(map(
- lambda kv: "{0} – {1}".format(kv[0], "; ".join(sorted(kv[1]))),
- sorted(cited_count.items(), reverse=True)[:3]))
- content += "
Most citations made to:
\n"
+ content += "
\n".join(top_cited_items)
+ content += "
Longest article:
\n"
article_length = {}
for article in articles:
format_map = {
@@ -198,61 +213,66 @@ def build_statistics_page(articles, config):
for format_id, cite_tuple in article.citations.items()
}
plain_content = article.content.format(**format_map)
- words = len(plain_content.split())
- article_length[article.title] = words
- content += "
\n".join(map(
- lambda kv: "{0} – {1}".format(kv[1], kv[0]),
- sorted(article_length.items(), reverse=True, key=lambda t: t[1])[:3]))
- content += "
Longest article:
\n"
+ content += "
\n".join(top_length_items)
+ content += "
Total word count:
\n"
content += str(sum(article_length.values())) + "
Player total page rank:
\n"
players = sorted(set([article.player for article in articles if article.player is not None]))
- articles_by = {
+ articles_by_player = {
player : [
a
for a in articles
if a.player == player]
for player in players}
- player_rank = {
- player : sum(map(lambda a: ranks[a.title] if a.title in ranks else 0, articles))
- for player, articles in articles_by.items()}
- content += "
\n".join(map(
- lambda kv: "{0} – {1}".format(kv[0], round(kv[1], 3)),
- sorted(player_rank.items(), key=lambda t:t[1], reverse=True)))
- content += "
Player total page rank:
\n"
+ content += "
\n".join(player_rank_items)
+ content += "
Citations made by player
\n"
player_cite_count = {
player : sum(map(lambda a:len(a.wcites | a.pcites), articles))
- for player, articles in articles_by.items()}
- content += "
\n".join(map(
- lambda kv: "{0} – {1}".format(kv[0], kv[1]),
- sorted(player_cite_count.items(), key=lambda t:t[1], reverse=True)))
- content += "
Citations made by player
\n"
+ content += "
\n".join(player_cites_made_items)
+ content += "
Citations made to player
\n"
cited_times = {player : 0 for player in players}
for article in articles:
if article.player is not None:
cited_times[article.player] += len(article.citedby)
- content += "
\n".join(map(
- lambda kv: "{0} – {1}".format(kv[0], kv[1]),
- sorted(cited_times.items(), key=lambda t:t[1], reverse=True)))
- content += "
Citations made to player
\n"
+ content += "
\n".join(cited_times_items)
+ content += "