So, I used python package "gender-guesser" to detect the gender of the person based on their names. However, I want to identify the gender from a sentence that does not have the person name.
Suppose I have the below sentence:
"Prior to you with a 14 year old male, who got out of bed and had some sort of syncopal episode."
The sentence is just an example and only has the word male and not the person's name. But, the input can contain may contain other words like boy, girl, lady, transgender, guy, woman, man, unknown, etc.
This is what I am currently trying to do, but may not be correct for what I want the end result:
#original string
wordlist=tokens
# using split() function
# total no of words
male_count=0
female_count=0
for i in range(len(wordlist)):
if wordlist[i]==('male' or 'boy' or 'guy' or 'man'):
print(i)
male_count= male_count+1
else:
if wordlist[i]==('female' or 'girl' or 'lady' or 'woman'):
female_count= female_count+1
Is there a better way to identify the gender?