def get_pubtator(pmid):
r = get_url(PUBTATOR_TMPL.replace("<STR_LIT>", pmid), timeout=<NUM_LIT:10>)<EOL>if r and r.status_code == <NUM_LIT:200>:<EOL><INDENT>pubtator = r.json()[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>log.error(<EOL>f"<STR_LIT>"<EOL>)<EOL>return None<EOL><DEDENT>known_types = ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>"]<EOL>for idx, anno in enumerate(pubtator["<STR_LIT>"]):<EOL><INDENT>s_match = re.match(r"<STR_LIT>", anno["<STR_LIT>"])<EOL>c_match = re.match(r"<STR_LIT>", anno["<STR_LIT>"])<EOL>if c_match:<EOL><INDENT>(ctype, namespace, cid) = (<EOL>c_match.group(<NUM_LIT:1>),<EOL>c_match.group(<NUM_LIT:2>),<EOL>c_match.group(<NUM_LIT:3>),<EOL>)<EOL>if ctype not in known_types:<EOL><INDENT>log.info(f"<STR_LIT>")<EOL><DEDENT>if namespace not in known_types:<EOL><INDENT>log.info(f"<STR_LIT>")<EOL><DEDENT>pubtator["<STR_LIT>"][idx][<EOL>"<STR_LIT>"<EOL>] = f'<STR_LIT>'<EOL>pubtator["<STR_LIT>"][idx]["<STR_LIT>"] = pubtator_entity_convert.get(<EOL>ctype, None<EOL>)<EOL>pubtator["<STR_LIT>"][idx][<EOL>"<STR_LIT>"<EOL>] = pubtator_annotation_convert.get(ctype, None)<EOL><DEDENT>elif s_match:<EOL><INDENT>(ctype, cid) = (s_match.group(<NUM_LIT:1>), s_match.group(<NUM_LIT:2>))<EOL>if ctype not in known_types:<EOL><INDENT>log.info(f"<STR_LIT>")<EOL><DEDENT>pubtator["<STR_LIT>"][idx][<EOL>"<STR_LIT>"<EOL>] = f'<STR_LIT>'<EOL>pubtator["<STR_LIT>"][idx]["<STR_LIT>"] = pubtator_entity_convert.get(<EOL>ctype, None<EOL>)<EOL>pubtator["<STR_LIT>"][idx][<EOL>"<STR_LIT>"<EOL>] = pubtator_annotation_convert.get(ctype, None)<EOL><DEDENT><DEDENT>annotations = {}<EOL>for anno in pubtator["<STR_LIT>"]:<EOL><INDENT>log.info(anno)<EOL>if anno["<STR_LIT>"] not in annotations:<EOL><INDENT>annotations[anno["<STR_LIT>"]] = {"<STR_LIT>": [anno["<STR_LIT>"]]}<EOL>annotations[anno["<STR_LIT>"]]["<STR_LIT>"] = [anno.get("<STR_LIT>", [])]<EOL>annotations[anno["<STR_LIT>"]]["<STR_LIT>"] = [<EOL>anno.get("<STR_LIT>", [])<EOL>]<EOL><DEDENT>else:<EOL><INDENT>annotations[anno["<STR_LIT>"]]["<STR_LIT>"].append(anno["<STR_LIT>"])<EOL><DEDENT><DEDENT>del pubtator["<STR_LIT>"]<EOL>pubtator["<STR_LIT>"] = copy.deepcopy(annotations)<EOL>return pubtator<EOL>
Get Pubtator Bioconcepts from Pubmed Abstract

    Re-configure the denotations into an annotation dictionary format
    and collapse duplicate terms so that their spans are in a list.