ci_mapping/data/parse_mag_data.py
def parse_papers(response):
    """Parse paper information from a MAG API response.
    
    Args:
        response (json): Response from MAG API in JSON format. Contains paper information.

    Returns:
        d (dict): Paper metadata.

    """
    remappings = {
        "id": "Id",
        "prob": "prob",
        "title": "Ti",
        "publication_type": "Pt",
        "year": "Y",
        "date": "D",
        "citations": "CC",
    }

    d = {k: response[v] for k, v in remappings.items()}

    # Some MAG fields might be empty - replace empty values with np.nan
    try:
        d["doi"] = response["DOI"]
    except KeyError as e:
        # logging.info(f"{response['Id']}: {e}")
        d["doi"] = np.nan
    try:
        d["bibtex_doc_type"] = response["BT"]
    except KeyError as e:
        # logging.info(f"{response['Id']}: {e}")
        d["bibtex_doc_type"] = np.nan
    try:
        d["references"] = json.dumps(response["RId"])
    except KeyError as e:
        # logging.info(f"{response['Id']}: {e}")
        d["references"] = np.nan
    try:
        d["abstract"] = inverted2abstract(response["IA"])
    except KeyError as e:
        # logging.info(f"{response['Id']}: {e}")
        d["abstract"] = np.nan
    try:
        d["publisher"] = response["PB"]
    except KeyError as e:
        # logging.info(f"{response['Id']}: {e}")
        d["publisher"] = np.nan

    return d
Parse paper information from a MAG API response.
    
    Args:
        response (json): Response from MAG API in JSON format. Contains paper information.

    Returns:
        d (dict): Paper metadata.

    
Parse paper information from a MAG API response.
Parse paper information from a MAG API response .
def parse_papers(response):
    remappings = {
        "id": "Id",
        "prob": "prob",
        "title": "Ti",
        "publication_type": "Pt",
        "year": "Y",
        "date": "D",
        "citations": "CC",
    }
    d = {k: response[v] for k, v in remappings.items()}
    try:
        d["doi"] = response["DOI"]
    except KeyError as e:
        d["doi"] = np.nan
    try:
        d["bibtex_doc_type"] = response["BT"]
    except KeyError as e:
        d["bibtex_doc_type"] = np.nan
    try:
        d["references"] = json.dumps(response["RId"])
    except KeyError as e:
        d["references"] = np.nan
    try:
        d["abstract"] = inverted2abstract(response["IA"])
    except KeyError as e:
        d["abstract"] = np.nan
    try:
        d["publisher"] = response["PB"]
    except KeyError as e:
        d["publisher"] = np.nan
    return d
def parse_papers ( response ) : remappings = { "id" : "Id" , "prob" : "prob" , "title" : "Ti" , "publication_type" : "Pt" , "year" : "Y" , "date" : "D" , "citations" : "CC" , } d = { k : response [ v ] for k , v in remappings . items ( ) } try : d [ "doi" ] = response [ "DOI" ] except KeyError as e : d [ "doi" ] = np . nan try : d [ "bibtex_doc_type" ] = response [ "BT" ] except KeyError as e : d [ "bibtex_doc_type" ] = np . nan try : d [ "references" ] = json . dumps ( response [ "RId" ] ) except KeyError as e : d [ "references" ] = np . nan try : d [ "abstract" ] = inverted2abstract ( response [ "IA" ] ) except KeyError as e : d [ "abstract" ] = np . nan try : d [ "publisher" ] = response [ "PB" ] except KeyError as e : d [ "publisher" ] = np . nan return d
Parse paper information from a MAG API response.
Parse paper information from a MAG API response .
"""Parse paper information from a MAG API response.
    
    Args:
        response (json): Response from MAG API in JSON format. Contains paper information.

    Returns:
        d (dict): Paper metadata.

    """ # Some MAG fields might be empty - replace empty values with np.nan # logging.info(f"{response['Id']}: {e}") # logging.info(f"{response['Id']}: {e}") # logging.info(f"{response['Id']}: {e}") # logging.info(f"{response['Id']}: {e}") # logging.info(f"{response['Id']}: {e}")
d (dict): Paper metadata.
d ( dict ) : Paper metadata .
response
Response from MAG API in JSON format. Contains paper information.
Response from MAG API in JSON format . Contains paper information .