From e8ce7876c5869522f982073d70c3ee7be179e1f9 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 10 Nov 2018 15:59:24 +0100 Subject: citation coverage reports --- util.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'util.py') diff --git a/util.py b/util.py index ed7ee396..cae867b9 100644 --- a/util.py +++ b/util.py @@ -87,6 +87,9 @@ def write_report(fn, title=None, keys=None, rows=[]): f.write("") print("{} {}".format(fn, count)) +def percent(m, n): + return round(n / m * 100) + class NameLine(object): def __init__(self, s): self.s = s.strip() @@ -102,9 +105,12 @@ class BoldLine(object): class LinkLine(object): def __init__(self, href, txt): self.href = href - self.txt = txt.strip + self.txt = txt.strip() def __str__(self): - return '{}'.format(self.href, self.txt) + if self.href: + return '{}'.format(self.href, self.txt) + else: + return '{}'.format(self.txt) def write_table(f, keys, rows): count = 0 @@ -145,6 +151,13 @@ class DbPaper(object): @property def authors(self): return [ (author['ids'][0] if len(author['ids']) else '', author['name']) for author in self.data['authors'] ] + @property + def pdf_link(self): + if self.data['s2PdfUrl']: + return self.data['s2PdfUrl'] + if len(self.data['pdfUrls']): + return self.data['pdfUrls'][0] + return None def record(self): return [ self.paper_id, self.title, self.journal, self.year ] @@ -173,6 +186,9 @@ class RawPaper(object): @property def authors(self): return [ (author[0]['ids'][0] if len(author[0]['ids']) else '', author[0]['name']) for author in self.data['authors'] ] + @property + def pdf_link(self): + return self.data['primaryPaperLink'] or None def record(self): return [ self.paper_id, self.title, self.journal, self.year ] -- cgit v1.2.3-70-g09d2