def get_bib(self,EID=None): EID = int(EID) scp_doc = AbsDoc(scp_id = EID) scp_doc.read(self.client) scp_doc.write() bib=[] for x in scp_doc.data.get('item').get('bibrecord').get('tail').get('bibliography').get('reference'): EID_x = x.get('ref-info').get('refd-itemidlist').get('itemid')[1].get('$') bib.append(EID_x) return bib
def scopus_abs(scopus_id=None): ## Scopus (Abtract) document example # Initialize document with ID as integer scp_doc = AbsDoc(scp_id=scopus_id) if scp_doc.read(client): print("scp_doc.title: ", scp_doc.title) scp_doc.write()
def readAbsDocWithScopusID(self, scpID='84872135457'): ## Scopus (Abtract) document example # Initialize document with Scopus ID. scp_doc = AbsDoc(scp_id=scpID) if scp_doc.read(self.client): print("scp_doc.title: ", scp_doc.title) scp_doc.write() else: print("Read document failed.")
def autorships(dataset_name, aut_dump_name): data = pd.read_csv(dataset_name) ids = data['scopusID'].values with open(aut_dump_name, 'w') as aut: num = 0 for id in tqdm(ids): scp_doc = AbsDoc(scp_id=id.split(':')[1]) if scp_doc.read(client): scp_doc.write() else: print("Read document failed.") aut.write('None' + u'\r\n') continue num += 1 try: aut.write(';'.join([':'.join([i['ce:indexed-name'], i['@auid']]) for i in scp_doc.data['authors']['author']]) + u'\r\n') except: aut.write('None' + u'\r\n')
else: print ("Read author failed.") ## Affiliation example # Initialize affiliation with ID as string my_aff = ElsAffil(affil_id = '60101411') if my_aff.read(client): print ("my_aff.name: ", my_aff.name) my_aff.write() else: print ("Read affiliation failed.") ## Scopus (Abtract) document example # Initialize document with ID as integer scp_doc = AbsDoc(scp_id = 84872135457) if scp_doc.read(client): print ("scp_doc.title: ", scp_doc.title) scp_doc.write() else: print ("Read document failed.") ## ScienceDirect (full-text) document example using PII pii_doc = FullDoc(sd_pii = 'S1674927814000082') if pii_doc.read(client): print ("pii_doc.title: ", pii_doc.title) pii_doc.write() else: print ("Read document failed.") ## ScienceDirect (full-text) document example using DOI doi_doc = FullDoc(doi = '10.1016/S1525-1578(10)60571-5')
def genData(self): raw_df = self.raw_df scopus_list = raw_df['scopus'] # Load configuration con_file = open("config.json") config = json.load(con_file) con_file.close() # Initialize client client = ElsClient(config['apikey']) author_id_list = [] given_name_list = [] sur_name_list = [] affiliation_id_list = [] affiliation_city_list = [] affilname_list = [] affiliation_country_list = [] citedby_count_list = [] for scopus_id in scopus_list: print(len(author_id_list)) # Initialize document with Scopus ID. print(scopus_id) if type(scopus_id) is str: scopus_id = self.scopusID(scopus_id) # ['client', 'data', 'id', 'int_id', 'read', 'title', 'uri', 'write'] scp_doc = AbsDoc(scp_id=scopus_id) if scp_doc.read(client): # dict_keys(['coredata']) # dict_keys(['srctype', 'prism:issueIdentifier', 'eid', 'prism:coverDate', 'prism:aggregationType', 'prism:url', 'subtypeDescription', 'dc:creator', 'link', 'prism:publicationName', 'source-id', 'citedby-count', 'prism:volume', 'subtype', 'prism:pageRange', 'dc:title', 'prism:endingPage', 'openaccess', 'openaccessFlag', 'prism:doi', 'prism:issn', 'prism:startingPage', 'dc:identifier']) # dict_keys(['ce:given-name', 'preferred-name', '@seq', 'ce:initials', '@_fa', 'affiliation', 'ce:surname', '@auid', 'author-url', 'ce:indexed-name']) if 'dc:creator' in scp_doc.data['coredata'].keys(): if 'ce:given-name' in scp_doc.data['coredata'][ 'dc:creator']['author'][0].keys(): given_name_list.append( scp_doc.data['coredata']['dc:creator'] ['author'][0]['ce:given-name']) else: given_name_list.append( scp_doc.data['coredata']['dc:creator'] ['author'][0]['preferred-name'] ['ce:given-name']) if 'affiliation' in scp_doc.data['coredata'][ 'dc:creator']['author'][0].keys(): # print(type(scp_doc.data['coredata']['dc:creator']['author'][0]['affiliation'])) if type(scp_doc.data['coredata']['dc:creator'] ['author'][0]['affiliation']) is list: affiliation_id_list.append( scp_doc.data['coredata']['dc:creator'] ['author'][0]['affiliation'][0]['@id']) else: affiliation_id_list.append( scp_doc.data['coredata']['dc:creator'] ['author'][0]['affiliation']['@id']) else: affiliation_id_list.append('NA') author_id_list.append( scp_doc.data['coredata']['dc:creator']['author'][0] ['@auid']) sur_name_list.append( scp_doc.data['coredata']['dc:creator']['author'][0] ['ce:surname']) else: given_name_list.append('NA') sur_name_list.append('NA') author_id_list.append('NA') affiliation_id_list.append('NA') citedby_count_list.append( scp_doc.data['coredata']['citedby-count']) else: given_name_list.append('NA') sur_name_list.append('NA') author_id_list.append('NA') affiliation_id_list.append('NA') citedby_count_list.append('NA') else: given_name_list.append('NA') sur_name_list.append('NA') author_id_list.append('NA') affiliation_id_list.append('NA') citedby_count_list.append('NA') raw_df['given-name'] = given_name_list raw_df['sur_name'] = sur_name_list raw_df['author_id'] = author_id_list raw_df['affiliation_id'] = affiliation_id_list raw_df['citedby_count'] = citedby_count_list return raw_df