def enhance_pubmed_annotations(pubmed: Mapping[str, Any]) -> Mapping[str, Any]:
text = pubmed["<STR_LIT:title>"] + pubmed["<STR_LIT>"]<EOL>annotations = {}<EOL>for nsarg in pubmed["<STR_LIT>"]:<EOL><INDENT>url = f'<STR_LIT>'<EOL>log.info(f"<STR_LIT>")<EOL>r = get_url(url)<EOL>log.info(f"<STR_LIT>")<EOL>new_nsarg = "<STR_LIT>"<EOL>if r and r.status_code == <NUM_LIT:200>:<EOL><INDENT>term = r.json()<EOL>new_nsarg = bel_utils.convert_nsarg(term["<STR_LIT:id>"], decanonicalize=True)<EOL>pubmed["<STR_LIT>"][nsarg]["<STR_LIT:name>"] = term["<STR_LIT:name>"]<EOL>pubmed["<STR_LIT>"][nsarg]["<STR_LIT:label>"] = term["<STR_LIT:label>"]<EOL>pubmed["<STR_LIT>"][nsarg]["<STR_LIT>"] = list(<EOL>set(<EOL>pubmed["<STR_LIT>"][nsarg]["<STR_LIT>"]<EOL>+ term.get("<STR_LIT>", [])<EOL>)<EOL>)<EOL>pubmed["<STR_LIT>"][nsarg]["<STR_LIT>"] = list(<EOL>set(<EOL>pubmed["<STR_LIT>"][nsarg]["<STR_LIT>"]<EOL>+ term.get("<STR_LIT>", [])<EOL>)<EOL>)<EOL><DEDENT>if new_nsarg != nsarg:<EOL><INDENT>annotations[new_nsarg] = copy.deepcopy(pubmed["<STR_LIT>"][nsarg])<EOL><DEDENT>else:<EOL><INDENT>annotations[nsarg] = copy.deepcopy(pubmed["<STR_LIT>"][nsarg])<EOL><DEDENT><DEDENT>for nsarg in annotations:<EOL><INDENT>for idx, span in enumerate(annotations[nsarg]["<STR_LIT>"]):<EOL><INDENT>string = text[span["<STR_LIT>"] - <NUM_LIT:1> : span["<STR_LIT:end>"] - <NUM_LIT:1>]<EOL>annotations[nsarg]["<STR_LIT>"][idx]["<STR_LIT:text>"] = string<EOL><DEDENT><DEDENT>pubmed["<STR_LIT>"] = copy.deepcopy(annotations)<EOL>return pubmed<EOL>
Enhance pubmed namespace IDs

    Add additional entity and annotation types to annotations
    Use preferred id for namespaces as needed
    Add strings from Title, Abstract matching Pubtator BioConcept spans

    NOTE - basically duplicated code with bel_api:api.services.pubmed

    Args:
        pubmed

    Returns:
        pubmed object