def disambiguate_author(author, vivo_authors=get_vivo_authors()): """ Given an author dictionary with name parts, find matches in the data structure returned by get_vivo_authors :param author: dictionary of name parts :param vivo_authors: authors in VIVO, seven dictionaries with seven keys based on various types of name parts :return: list of uri in vivo matching the author """ author_uri_list = [] return author_uri_list
def disambiguate_author(author, vivo_authors=get_vivo_authors()): """ Given an author dictionary with name parts, find matches in the data structure returned by get_vivo_authors :param author: dictionary of name parts :param vivo_authors: authors in VIVO, seven dictionaries with seven keys based on various types of name parts :return: list of uri in vivo matching the author """ author_uri_list = [] return author_uri_list
def disambiguate_author(author, vivo_authors): """ Given an author dictionary with name parts, find matches in the data structure returned by get_vivo_authors :param author: dictionary of name parts :param vivo_authors: authors in VIVO, seven dictionaries with seven keys based on various types of name parts :return: list of uri in vivo matching the author """ author_uri_list = [] return author_uri_list parms = get_parms() data_in = read_csv_fp(sys.stdin) print >> sys.stderr, len(data_in) vivo_authors = get_vivo_authors( parms) # get dictionaries of authors keyed by name parts print >> sys.stderr, 'VIVO authors', len(vivo_authors) print >> sys.stderr, vivo_authors data_out = {} row_out = 0 for row, data in data_in.items(): if data['uf'] == 'false': # Always put in the non-UF author as new row_out += 1 data_out[row_out] = data data_out[row_out]['uri'] = '' else: author_uris = disambiguate_author(data, vivo_authors) if len(author_uris ) == 0: # Only put in a new UF author if no one at UF matches row_out += 1
import sys def disambiguate_author(author, vivo_authors=get_vivo_authors()): """ Given an author dictionary with name parts, find matches in the data structure returned by get_vivo_authors :param author: dictionary of name parts :param vivo_authors: authors in VIVO, seven dictionaries with seven keys based on various types of name parts :return: list of uri in vivo matching the author """ author_uri_list = [] return author_uri_list data_in = read_csv_fp(sys.stdin) print >>sys.stderr, len(data_in) vivo_authors = get_vivo_authors() # get dictionaries of authors keyed by name parts print >>sys.stderr, 'VIVO authors', len(vivo_authors) print >>sys.stderr, vivo_authors data_out = {} row_out = 0 for row, data in data_in.items(): if data['uf'] == 'false': # Always put in the non-UF author as new row_out += 1 data_out[row_out] = data data_out[row_out]['uri'] = '' else: author_uris = disambiguate_author(data, vivo_authors) if len(author_uris) == 0: # Only put in a new UF author if no one at UF matches row_out += 1 data_out[row_out] = data
def test_vivo_get_authors(self): result = get_vivo_authors() self.assertTrue(len(result) > 0)