I am trying to extract skills from a resume which works fine but now I want to check if in case skill is empty then the program should open up a rawtext.json file but the problem is that as soon as I write elif to check if the skill is empty then, I get invalid syntax or unexpected indent.
def getSkills(sentences):
try:
sen=[]
z=0
for words in sentences:
for i in range(len(words)):
if(words[i][0].lower()=='skills') and words[i][1]=='NNP':
index =[z,i]
break
z+=1
skills=[]
for i in sentences[index[0]][index[1]+1:]:
if i[0].isalpha() and i[1]=='NNP':
skills.append(i[0])
return skills
elif skills == []:
with open('rawtext.json','r', encoding='utf-8') as f:
data = json.load(f)
result = [x["name"].replace("@", " ").lower() for x in data]
print(result)
else:
return None
except:
return None
Can someone please guide me on how can I implement this logic? Thank you for your assistance in this regard.
Aucun commentaire:
Enregistrer un commentaire