示例#1
0
 def test_read_metrics_new_author(self):
     myAuth = ElsAuthor(uri = self.auth_uri)
     myAuth.read_metrics(self.good_client)
     assert (
         myAuth.data['coredata']['citation-count'] and  
         myAuth.data['coredata']['cited-by-count'] and 
         myAuth.data['coredata']['document-count'] and 
         myAuth.data['h-index'])
示例#2
0
def get_author_by_id(client, author):
    author_data = {}

    my_auth = ElsAuthor(
        uri=f"https://api.elsevier.com/content/author/author_id/{author}")

    if my_auth.read(client):
        my_auth.read_metrics(client)
        my_auth.read_docs(client)

        field_str = ""
        field_list = []
        for area in my_auth.data['subject-areas']['subject-area']:
            field_str += f"{area['$']} | "
            field_list.append(area['$'])

        author_data['name'] = my_auth.full_name
        author_data['url'] = my_auth.data['coredata']['link'][0]['@href']
        author_data['h-index'] = my_auth.data['h-index']
        author_data['docs'] = my_auth.data['coredata']['document-count']
        author_data['cit'] = my_auth.data['coredata']['citation-count']
        author_data['fields'] = field_list
        author_data['pub-range'] = my_auth.data['author-profile'][
            'publication-range']
        try:
            author_data['affiliation'] = {
                'name':
                my_auth.data['author-profile']['affiliation-current']
                ['affiliation']['ip-doc']['preferred-name']['$'],
                'country':
                my_auth.data['author-profile']['affiliation-current']
                ['affiliation']['ip-doc']['address']['country'],
                'url':
                my_auth.data['author-profile']['affiliation-current']
                ['affiliation']['ip-doc']['org-URL']
            }
        except KeyError:
            author_data['affiliation'] = {'name': '', 'country': '', 'url': ''}

        # print(author_data)

        return author_data

    else:
        print("Read author failed.")
示例#3
0
def author_score(fname, lname):
    client = elsevier_auth()

    the_zip = zip(fname, lname)
    num = len(fname)
    count = 0
    total = 0
    score = 0

    for first, last in the_zip:
        start = time.time()
        print(first, last)
        myDocSrch = ElsSearch(
            'AUTHLASTNAME(' + last + ') AND AUTHFIRST(' + first + ')',
            'author')
        myDocSrch.execute(client)

        for x in myDocSrch.results:
            try:
                a_id = x['dc:identifier']
            except:
                continue
            auth_id = a_id.replace('AUTHOR_ID:', '')

            author = ElsAuthor(author_id=auth_id)
            if (author.read_metrics(client)):
                h_index = author.data['h-index']
                score += h_index
                print(first, last, " ID:", auth_id, " h-index:", h_index)
            else:
                print("no data")
                score += 0

        end = time.time()
        diff = end - start
        total += diff
        count += 1
        num -= 1
        avg = total / count
        est = (num * avg) / 60
        print("time used for this author:", end - start, "s")
        print(num, "authors, estimated time left:", est, "minutes")
        print()
    return score