def parse_authors(paper_dict, max_authors=4): raw_authors = [utf8totex(x) for x in paper_dict['authors']] show_authors = raw_authors[:max_authors] if any(['price-whelan' in x.lower() for x in show_authors]): # Bold my name because it makes the cut to be shown names = [] for name in show_authors: if 'price-whelan' in name.lower(): name = '\\textbf{Price-Whelan,~A.~M.}' else: name = format_name(name) names.append(name) author_tex = '; '.join(names) if len(show_authors) < len(raw_authors): # use et al. author_tex = author_tex + "~\\textit{et al.}" else: # Add "incl. APW" after et al., because I'm buried in the author list author_tex = "{0}".format(format_name(show_authors[0])) author_tex += "~\\textit{et al.}~(incl. \\textbf{APW})" return author_tex
def parse_authors(paper_dict, max_authors=4): raw_authors = [utf8totex(x) for x in paper_dict['authors']] show_authors = raw_authors[:max_authors] if any(['mackereth' in x.lower() for x in show_authors]): # Bold my name because it makes the cut to be shown names = [] for name in show_authors: if 'mackereth' in name.lower(): name = '\\textbf{Mackereth,~J.~T.}' else: name = format_name(name) names.append(name) author_tex = '; '.join(names) if len(show_authors) < len(raw_authors): # use et al. author_tex = author_tex + "~et al." else: # Add "incl. " after et al., because I'm buried in the author list author_tex = "{0}".format(format_name(show_authors[0])) author_tex += "~et al.~(incl. \\textbf{JTM})" return author_tex
def get_papers(author): papers = list( ads.SearchQuery( author=author, fl=[ "id", "title", "author", "doi", "year", "pubdate", "pub", "volume", "page", "identifier", "doctype", "citation_count", "bibcode", ], max_pages=100, )) dicts = [] for paper in papers: aid = [ ":".join(t.split(":")[1:]) for t in paper.identifier if t.startswith("arXiv:") ] for t in paper.identifier: if len(t.split(".")) != 2: continue try: list(map(int, t.split("."))) except ValueError: pass else: aid.append(t) try: page = int(paper.page[0]) except (ValueError, TypeError): page = None if paper.page is not None and paper.page[0].startswith("arXiv:"): aid.append(":".join(paper.page[0].split(":")[1:])) dicts.append( dict( doctype=paper.doctype, authors=list(map(utf8totex, paper.author)), year=paper.year, pubdate=paper.pubdate, doi=paper.doi[0] if paper.doi is not None else None, title=utf8totex(paper.title[0]), pub=paper.pub, volume=paper.volume, page=page, arxiv=aid[0] if len(aid) else None, citations=(paper.citation_count if paper.citation_count is not None else 0), url="https://ui.adsabs.harvard.edu/abs/" + paper.bibcode, )) return sorted(dicts, key=itemgetter("pubdate"), reverse=True)
def format_repo(repo): repo = repo["node"] for k in ["name", "description"]: repo[k] = utf8totex(repo[k]) txt = "\\item \href{{{repo[url]}}}{{{{\\bf {repo[name]}}}}} --- " txt += "{repo[stargazers][totalCount]} stars / " txt += "{repo[forkCount]} forks \\\\\n" txt += "{repo[description]} " txt += "\\href{{{repo[homepageUrl]}}}{{[docs]}}" txt = txt.format(repo=repo) return txt
def format_title(arg): """ Customized! """ # Do the conversion arg = utf8totex(arg) # Handle subscripts arg = re.sub("<SUB>(.*?)</SUB>", r"$_\1$", arg) # Fudge O2 paper arg = re.sub("O2Buildup", r"O$_2$ Buildup", arg) # Capitalize! arg = titlecase(arg, callback=title_callback) return arg
def get_paper_items(papers): refereeds = [] proceedings = [] preprints = [] first_authors = [] co_authors = [] #need to do a re-sort by pubdate dates = [] papers = sorted(papers, key=lambda x: x['pubdate'], reverse=True) for paper in papers: authors = parse_authors(paper) entry = authors # Skip if the publication is in the skip list: if any([ re.match(re.compile(pattr), paper['pub'].lower()) for pattr in JOURNAL_SKIP ]): continue is_proceedings = False if paper['doctype'] == 'inproceedings': is_proceedings = True if paper["doi"] is not None: title = "\\doi{{{0}}}{{{1}}}".format(paper["doi"], utf8totex(paper["title"])) else: title = "\\textit{{{0}}}".format(utf8totex(paper["title"])) entry += ", " + title if paper['pubdate'] is not None: entry += ", {0}".format(paper['pubdate'].split('-')[0]) if paper["pub"] not in [None, "ArXiv e-prints", "arXiv e-prints"]: # HACK pub = JOURNAL_MAP.get(paper["pub"].strip("0123456789# ").lower(), None) if pub is None: if is_proceedings: pub = paper['pub'] else: print("Journal '{0}' not recognized for paper '{1}' - " " skipping...".format(paper['pub'], paper['title'])) continue entry += ", " + pub is_preprint = False else: is_preprint = True if paper["volume"] is not None: entry += ", {{{0}}}".format(paper["volume"]) if paper["page"] is not None: entry += ", {0}".format(paper["page"]) if paper["arxiv"] is not None: entry += " (\\arxiv{{{0}}})".format(paper["arxiv"]) if paper["citations"] > 1: entry += ( "~~{{\\footnotesize[\\href{{{0}}}{{cited: {1}}}]}}".format( paper["url"], paper["citations"])) if is_preprint: preprints.append(entry) elif is_proceedings: proceedings.append(entry) else: refereeds.append(entry) if "mackereth" in paper["authors"][0].lower() and not is_proceedings: first_authors.append(entry) if "mackereth" not in paper["authors"][0].lower( ) and not is_proceedings and not is_preprint: co_authors.append(entry) # Now go through and add the \item and numbers: for corpus in [ preprints, proceedings, refereeds, first_authors, co_authors ]: for i, item in enumerate(corpus): num = len(corpus) - i corpus[i] = ("\\item[{\\scriptsize" + str(num) + "}]" + item) return refereeds, proceedings, preprints, first_authors, co_authors
def get_paper_items(papers): refereeds = [] preprints = [] for paper in papers: authors = parse_authors(paper) entry = authors # Skip if the publication is in the skip list: if any([re.match(re.compile(pattr), paper['pub'].lower()) for pattr in JOURNAL_SKIP]): continue if paper["doi"] is not None: title = "\\doi{{{0}}}{{{1}}}".format(paper["doi"], utf8totex(paper["title"])) else: title = "\\textit{{{0}}}".format(utf8totex(paper["title"])) entry += ", " + title if paper["pub"] not in [None, "ArXiv e-prints", "arXiv e-prints"]: # HACK pub = JOURNAL_MAP.get(paper["pub"].strip("0123456789# ").lower(), None) if pub is None: print("Journal '{0}' not recognized for paper '{1}' - " " skipping...".format(paper['pub'], paper['title'])) continue entry += ", " + pub is_preprint = False else: is_preprint = True if paper["volume"] is not None: entry += ", \\textbf{{{0}}}".format(paper["volume"]) if paper["page"] is not None: entry += ", {0}".format(paper["page"]) if paper['pubdate'] is not None: entry += ", {0}".format(paper['pubdate'].split('-')[0]) if paper["arxiv"] is not None: entry += " (\\arxiv{{{0}}})".format(paper["arxiv"]) if paper["citations"] > 1: entry += (" [\\href{{{0}}}{{{1} citations}}]" .format(paper["url"], paper["citations"])) if is_preprint: preprints.append(entry) else: refereeds.append(entry) # Now go through and add the \item and numbers: for corpus in [preprints, refereeds]: for i, item in enumerate(corpus): num = len(corpus) - i corpus[i] = ("\\item[{\\color{deemph}\\scriptsize" + str(num) + "}]" + item) return refereeds, preprints