From d109d83bf590c0dcaa78b4e9ad6e1580caf5070c Mon Sep 17 00:00:00 2001 From: "borondics.accounts@gmail.com" Date: Fri, 21 Jul 2023 15:43:49 +0200 Subject: [PATCH] updated citations --- data/citations.toml | 2 ++ scripts/update_citations.py | 53 +++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 data/citations.toml create mode 100644 scripts/update_citations.py diff --git a/data/citations.toml b/data/citations.toml new file mode 100644 index 00000000..bbd1f862 --- /dev/null +++ b/data/citations.toml @@ -0,0 +1,2 @@ +direct = 121 +secondary = 831 diff --git a/scripts/update_citations.py b/scripts/update_citations.py new file mode 100644 index 00000000..a5c837f1 --- /dev/null +++ b/scripts/update_citations.py @@ -0,0 +1,53 @@ +import sys + +import toml +from scholarly import scholarly + +print("Searching on Google scholar") + +author = scholarly.search_author_id('_7AMrKgAAAAJ') # _7AMrKgAAAAJ is Quasar + +quasar_stats = scholarly.fill(author, sections=['basics', 'indices', 'counts', 'publications']) + +scholarly.pprint(quasar_stats) + +# What papers cited our publications? +cit = [] +for pub in quasar_stats['publications']: + print(pub) + cit.append([citation for citation in scholarly.citedby(pub)]) # limit the number of test runs because this will get blocked bu Google quickly + +print(f'There are currently {len(quasar_stats["publications"])} Quasar papers.') +for pub in quasar_stats['publications']: + print(' ',pub['bib']['title']) + +fcit = [item for sublist in cit for item in sublist] # this is a flat list now +print(f'\nWe have {len(fcit)} citations so far for our Quasar papers.') + +# I wonder if this can be done in fewer lines. :D +authors = [c["author_id"] for c in fcit] +citing_authors = [item for sublist in authors for item in sublist] +citing_authors = set([c for c in citing_authors if c]) # citing authors with Google Scholar profile +print(f'\nThere are {len(citing_authors)} people citing Quasar with a Google Scholar profile.') + +# count how many papers cite those papers that use Quasar - this is the real impact. +secondary_cit = sum([paper["num_citations"] for paper in fcit]) +print(f'\n{secondary_cit} papers cite the works which use Quasar.') + +FN = "../data/citations.toml" +td = toml.load(FN) + +if len(fcit) < int(td["direct"]): + print("Citation number of direct citations has decreased; exiting.") + sys.exit(-1) +else: + td["direct"] = len(fcit) + +if secondary_cit < int(td["secondary"]): + print("Citation number of secondary citations has decreased; exiting.") + sys.exit(-1) +else: + td["secondary"] = secondary_cit + +with open(FN, "wt") as of: + toml.dump(td, of)