doc2json/jats2json/jats_to_json.py
def postprocess_front_tags_for_s2orc(init_front_dict: Dict):
    """
    Fix authors and year for S2ORC format
    """
    # Make authors in front tags look like S2ORC
    for a in init_front_dict['authors']:
        a['affiliation'] = {}
        # get affiliation if available
        if a['affiliation_ids']:
            affil_id = a['affiliation_ids'][0]
            affil_text = [affil['text'] for affil in init_front_dict['affiliations'] if affil['id'] == affil_id]
            if affil_text:
                a['affiliation'] = {
                    'laboratory': "",
                    'institution': affil_text[0],
                    'location': {}
                }
        del a['affiliation_ids']
        del a['corresponding']
        del a['orcid']
    del init_front_dict['affiliations']

    # Pick best year and make year int in front tags
    if init_front_dict['year'].get('epub'):
        year = init_front_dict['year'].get('epub')
    elif init_front_dict['year'].get('accepted'):
        year = init_front_dict['year'].get('accepted')
    elif init_front_dict['year'].get('collection'):
        year = init_front_dict['year'].get('collection')
    elif init_front_dict['year'].get('received'):
        year = init_front_dict['year'].get('received')
    else:
        year = None
    init_front_dict['year'] = year

    return init_front_dict

    Fix authors and year for S2ORC format
    
Fix authors and year for S2ORC format
Fix authors and year for S2ORC format
def postprocess_front_tags_for_s2orc(init_front_dict: Dict):
    for a in init_front_dict['authors']:
        a['affiliation'] = {}
        if a['affiliation_ids']:
            affil_id = a['affiliation_ids'][0]
            affil_text = [affil['text'] for affil in init_front_dict['affiliations'] if affil['id'] == affil_id]
            if affil_text:
                a['affiliation'] = {
                    'laboratory': "",
                    'institution': affil_text[0],
                    'location': {}
                }
        del a['affiliation_ids']
        del a['corresponding']
        del a['orcid']
    del init_front_dict['affiliations']
    if init_front_dict['year'].get('epub'):
        year = init_front_dict['year'].get('epub')
    elif init_front_dict['year'].get('accepted'):
        year = init_front_dict['year'].get('accepted')
    elif init_front_dict['year'].get('collection'):
        year = init_front_dict['year'].get('collection')
    elif init_front_dict['year'].get('received'):
        year = init_front_dict['year'].get('received')
    else:
        year = None
    init_front_dict['year'] = year
    return init_front_dict
def postprocess_front_tags_for_s2orc ( init_front_dict : Dict ) : for a in init_front_dict [ 'authors' ] : a [ 'affiliation' ] = { } if a [ 'affiliation_ids' ] : affil_id = a [ 'affiliation_ids' ] [ 0 ] affil_text = [ affil [ 'text' ] for affil in init_front_dict [ 'affiliations' ] if affil [ 'id' ] == affil_id ] if affil_text : a [ 'affiliation' ] = { 'laboratory' : "" , 'institution' : affil_text [ 0 ] , 'location' : { } } del a [ 'affiliation_ids' ] del a [ 'corresponding' ] del a [ 'orcid' ] del init_front_dict [ 'affiliations' ] if init_front_dict [ 'year' ] . get ( 'epub' ) : year = init_front_dict [ 'year' ] . get ( 'epub' ) elif init_front_dict [ 'year' ] . get ( 'accepted' ) : year = init_front_dict [ 'year' ] . get ( 'accepted' ) elif init_front_dict [ 'year' ] . get ( 'collection' ) : year = init_front_dict [ 'year' ] . get ( 'collection' ) elif init_front_dict [ 'year' ] . get ( 'received' ) : year = init_front_dict [ 'year' ] . get ( 'received' ) else : year = None init_front_dict [ 'year' ] = year return init_front_dict
Fix authors and year for S2ORC format
Fix authors and year for S2ORC format
"""
    Fix authors and year for S2ORC format
    """ # Make authors in front tags look like S2ORC # get affiliation if available # Pick best year and make year int in front tags
init_front_dict
Dict