File size: 896 Bytes
6eff5e7
 
 
 
fd61399
6eff5e7
 
 
 
5ee7598
6eff5e7
 
2fad322
 
 
fd61399
 
 
6eff5e7
 
2fad322
6eff5e7
 
 
 
6004e76
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from urllib.parse import urlparse
import requests
from semanticscholar import SemanticScholar

### Input Formatting

## Input formatting for the given author (reviewer)
# Extracting text from a link

def get_text_from_author_id(author_id, max_count=150):
    if author_id is None:
        raise ValueError('Input valid author ID')
    aid = str(author_id)
    if 'http' in aid: # handle semantic scholar url input
        aid = aid.split('/')
        aid = aid[-1]
        # aid = aid[aid.index('author')+2]
    url = "https://api.semanticscholar.org/graph/v1/author/%s?fields=url,name,paperCount,papers,papers.title,papers.abstract,papers.url,papers.year,papers.citationCount"%aid
    r = requests.get(url)
    if r.status_code == 404:
        raise ValueError('Author link not found.')
    data = r.json()
    papers = data['papers'][:max_count]
    name = data['name']

    return name, papers