pritamdeka commited on
Commit
12638e1
Β·
1 Parent(s): 01f5167

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -45
app.py CHANGED
@@ -210,51 +210,35 @@ def keyphrase_generator(article_link, model_1, model_2, max_num_keywords):
210
  final_list.append(f_1)
211
 
212
 
213
- #if __name__ == '__main__':
214
- #for qu in range(len(final_list)):
215
- results=search(f_1)
216
- id_list = results['IdList']
217
- #if(id_list != []):
218
- papers = fetch_details(id_list)
219
- abstract_list=[]
220
- year_list=[]
221
- journal_list=[]
222
- title_list=[]
223
- for i, paper in enumerate(papers['PubmedArticle']):
224
- x=(json.dumps(papers['PubmedArticle'][i], indent=2))
225
- t_list=[]
226
- y = json.loads(x)
227
- try:
228
- value_1 = y['MedlineCitation']['Article']['Abstract']['AbstractText']
229
- value = (y['MedlineCitation']['Article']['ArticleTitle'])
230
- value_2 = (y['MedlineCitation']['Article']['Journal']['JournalIssue']['PubDate']['Year'])
231
- value_journal = (y['MedlineCitation']['Article']['Journal']['Title'])
232
- t_list.append(value)
233
- title_list.append(t_list)
234
- year_list.append(value_2)
235
- abstract_list.append(value_1)
236
- journal_list.append(value_journal)
237
- except KeyError:
238
- value_1 = []
239
- title_list.append(t_list)
240
- abstract_list.append(value_1)
241
- year_list.append(value_2)
242
- journal_list.append(value_journal)
243
- mydict={'Title': title_list, 'Abstract':abstract_list, 'Journal Title': journal_list, 'Year': year_list}
244
- df_new=pd.DataFrame(mydict)
245
- #print(df_new)
246
- #else:
247
- # abstract_list=[]
248
- # title_list=[]
249
- # year_list=[]
250
- # journal_list=[]
251
- # a=["No result"]
252
- # b=["No results"]
253
- # abstract_list.append(a)
254
- # title_list.append(b)
255
- # mydict={'Title': title_list, 'Abstract':abstract_list, 'Journal Title': journal_list, 'Year': year_list}
256
- # df_new=pd.DataFrame(mydict)
257
- #print(df_new)
258
  return title_list
259
 
260
  gr.Interface(keyphrase_generator,
 
210
  final_list.append(f_1)
211
 
212
 
213
+ ncbi_url='https://eutils.ncbi.nlm.nih.gov/entrez/eutils/'
214
+
215
+ last_url='esearch.fcgi?db=pubmed'+'&term='+f_1
216
+ search_rettype = '&rettype=json'
217
+ overall_url=ncbi_url+last_url+search_rettype+'&sort=relevance'
218
+ r = requests.get(overall_url)
219
+
220
+ root = ET.fromstring(r.text)
221
+ levels = root.findall('.//Id')
222
+ name_list=[]
223
+ for level in levels:
224
+ name = level.text
225
+ name_list.append(name)
226
+ name_1 = ','.join(name_list)
227
+ fetch_url='efetch.fcgi?db=pubmed'
228
+ search_id='&id='+name_1
229
+ ret_type='&rettype=text'
230
+ ret_mode='&retmode=xml'
231
+ ret_max='&retmax=10'
232
+ ret_sort='&sort=relevance'
233
+ return_url=ncbi_url+fetch_url+search_id+ret_type+ret_mode+ret_max+ret_sort
234
+ r_1 = requests.get(return_url)
235
+ root_1 = ET.fromstring(r_1.text)
236
+ levels_1 = root_1.findall('.//ArticleTitle')
237
+ for level in levels_1:
238
+ name = level.text
239
+ title_list.append(name)
240
+
241
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  return title_list
243
 
244
  gr.Interface(keyphrase_generator,