wzkariampuzha commited on
Commit
6565ba7
1 Parent(s): 762da8b

Update extract_abs.py

Browse files
Files changed (1) hide show
  1. extract_abs.py +6 -3
extract_abs.py CHANGED
@@ -198,7 +198,8 @@ def autosearch(searchterm:Union[str,int], GARD_dict:Dict[str,str], matching=2) -
198
  #search in form of 'GARD:0000001'
199
  if 'gard:' in searchterm and len(searchterm)==12:
200
  searchterm = searchterm.replace('gard:','GARD:')
201
- l = [k for k,v in GARD_dict.items() if v==searchterm].sort(reverse=True, key=lambda x:len(x))
 
202
  if len(l)>0:
203
  print("SEARCH TERM MATCHED TO GARD DICTIONARY. SEARCHING FOR: ",l)
204
  return l
@@ -209,7 +210,8 @@ def autosearch(searchterm:Union[str,int], GARD_dict:Dict[str,str], matching=2) -
209
  if len(searchterm)>7:
210
  raise ValueError('GARD ID IS NOT VALID. RE-ENTER SEARCH TERM')
211
  searchterm = 'GARD:'+'0'*(7-len(str(searchterm)))+str(searchterm)
212
- l = [k for k,v in GARD_dict.items() if v==searchterm].sort(reverse=True, key=lambda x:len(x))
 
213
  if len(l)>0:
214
  print("SEARCH TERM MATCHED TO GARD DICTIONARY. SEARCHING FOR: ",l)
215
  return l
@@ -217,7 +219,8 @@ def autosearch(searchterm:Union[str,int], GARD_dict:Dict[str,str], matching=2) -
217
  #search in form of 'mackay shek carr syndrome' and returns all synonyms ('retinal degeneration with nanophthalmos, cystic macular degeneration, and angle closure glaucoma', 'retinal degeneration, nanophthalmos, glaucoma', 'mackay shek carr syndrome')
218
  #considers the GARD ID as the lemma, and the search term as one form. maps the form to the lemma and then uses that lemma to find all related forms in the GARD dict.
219
  elif searchterm in GARD_dict.keys():
220
- l = [k for k,v in GARD_dict.items() if v==GARD_dict[searchterm]].sort(reverse=True, key=lambda x:len(x))
 
221
  print("SEARCH TERM MATCHED TO GARD DICTIONARY. SEARCHING FOR: ",l)
222
  return l
223
 
 
198
  #search in form of 'GARD:0000001'
199
  if 'gard:' in searchterm and len(searchterm)==12:
200
  searchterm = searchterm.replace('gard:','GARD:')
201
+ l = [k for k,v in GARD_dict.items() if v==searchterm]
202
+ l.sort(reverse=True, key=lambda x:len(x))
203
  if len(l)>0:
204
  print("SEARCH TERM MATCHED TO GARD DICTIONARY. SEARCHING FOR: ",l)
205
  return l
 
210
  if len(searchterm)>7:
211
  raise ValueError('GARD ID IS NOT VALID. RE-ENTER SEARCH TERM')
212
  searchterm = 'GARD:'+'0'*(7-len(str(searchterm)))+str(searchterm)
213
+ l = [k for k,v in GARD_dict.items() if v==searchterm]
214
+ l.sort(reverse=True, key=lambda x:len(x))
215
  if len(l)>0:
216
  print("SEARCH TERM MATCHED TO GARD DICTIONARY. SEARCHING FOR: ",l)
217
  return l
 
219
  #search in form of 'mackay shek carr syndrome' and returns all synonyms ('retinal degeneration with nanophthalmos, cystic macular degeneration, and angle closure glaucoma', 'retinal degeneration, nanophthalmos, glaucoma', 'mackay shek carr syndrome')
220
  #considers the GARD ID as the lemma, and the search term as one form. maps the form to the lemma and then uses that lemma to find all related forms in the GARD dict.
221
  elif searchterm in GARD_dict.keys():
222
+ l = [k for k,v in GARD_dict.items() if v==GARD_dict[searchterm]]
223
+ l.sort(reverse=True, key=lambda x:len(x))
224
  print("SEARCH TERM MATCHED TO GARD DICTIONARY. SEARCHING FOR: ",l)
225
  return l
226