def fetch_name(resume_text):
tokenized_sentences = nltk.sent_tokenize(resume_text)
for sentence in tokenized_sentences:
for chunk in nltk.ne_chunk(nltk.pos_tag(nltk.word_tokenize(sentence), tagset='universal')):
if hasattr(chunk, 'label'):# and chunk.label() == 'PERSON':
chunk = chunk[0]
(name, tag) = chunk
if tag == 'NOUN':
#print(name)
#z.extend(name)
return name
path = '/home/python/resumes/*.txt'
files = glob.glob(path)
for n in files:
with io.open(n,'r') as f:
data=f.read()
print(fetch_name(data))
Following is the output that i obtain from the code that follows. I need the output in a form of list ['Sharayu','neeraj'.....]
SHARAYU
Neeraj
Gregory
MEhul
Shashank
Sandeep
Atul
ADITYA
Manoj
SAGAR
Shreya