def test_declared_gender(self): for description, expected_gender in [ ("pronoun: she", "female"), ("she,her", "female"), ("she/her", "female"), ("she/her/hers", "female"), ("she,her,hers", "female"), ("pronouns: she/her", "female"), ("i am a nonbinary person", "nonbinary"), ("hi i'm non-binary", "nonbinary"), ("non binary human", "nonbinary"), ("i'm nb", "nonbinary"), ("just a guy living life", "male"), ("a southern gal", "female"), ("Proud womanist", "female"), ("latina", "female"), ("latino", "male"), ("he", "male"), ("he/him", "male"), ("he,him", "male"), ("he/his", "male"), ("he,his", "male"), ("he is a man", "male"), ("i go by they", "nonbinary"), ("them/they", "nonbinary"), ("them,they", "nonbinary"), ("xe", "nonbinary"), ("ze", "nonbinary"), ("zie", "nonbinary"), ("hir", "nonbinary"), ("pronoun.is/she", "female"), ("pronoun.is/he", "male"), ("pronoun.is/they", "nonbinary"), ("pronoun.is/foo", "nonbinary"), ("pronoun.is/zie", "nonbinary"), ("pronoun.is/hir", "nonbinary"), ("mum to one boy and one girl", "andy"), ("proud mom", "female"), ("cardamom", "andy"), ("doting dad", "male"), ("crawdad", "andy"), ("grandfather", "male"), ("the empire state building", "andy"), ]: guess = declared_gender(description) assert guess == expected_gender, ( "Should have guessed profile '%s' was '%s', not '%s'" % (description, expected_gender, guess))
def test_declared_gender(self): for description, expected_gender in [ ('pronoun: she', 'female'), ('she,her', 'female'), ('she/her', 'female'), ('she/her/hers', 'female'), ('she,her,hers', 'female'), ('pronouns: she/her', 'female'), ('i am a nonbinary person', 'nonbinary'), ('hi i\'m non-binary', 'nonbinary'), ('non binary human', 'nonbinary'), ('i\'m nb', 'nonbinary'), ('just a guy living life', 'male'), ('a southern gal', 'female'), ('Proud womanist', 'female'), ('latina', 'female'), ('latino', 'male'), ('he', 'male'), ('he/him', 'male'), ('he,him', 'male'), ('he/his', 'male'), ('he,his', 'male'), ('he is a man', 'male'), ('i go by they', 'nonbinary'), ('them/they', 'nonbinary'), ('them,they', 'nonbinary'), ('xe', 'nonbinary'), ('ze', 'nonbinary'), ('zie', 'nonbinary'), ('hir', 'nonbinary'), ('pronoun.is/she', 'female'), ('pronoun.is/he', 'male'), ('pronoun.is/they', 'nonbinary'), ('pronoun.is/foo', 'nonbinary'), ('pronoun.is/zie', 'nonbinary'), ('pronoun.is/hir', 'nonbinary'), ('mum to one boy and one girl', 'andy'), ('proud mom', 'female'), ('cardamom', 'andy'), ('doting dad', 'male'), ('crawdad', 'andy'), ('grandfather', 'male'), ('the empire state building', 'andy'), ]: guess = declared_gender(description) assert guess == expected_gender, ( "Should have guessed profile '%s' was '%s', not '%s'" % (description, expected_gender, guess))
def test_declared_gender(self): for description, expected_gender in [ ('pronoun: she', 'female'), ('she,her', 'female'), ('she/her', 'female'), ('she/her/hers', 'female'), ('she,her,hers', 'female'), ('pronouns: she/her', 'female'), ('i am a nonbinary person', 'nonbinary'), ('hi i\'m non-binary', 'nonbinary'), ('non binary human', 'nonbinary'), ('just a guy living life', 'male'), ('a southern gal', 'female'), ('Proud womanist', 'female'), ('latina', 'female'), ('latino', 'male'), ('he', 'male'), ('he/him', 'male'), ('he,him', 'male'), ('he/his', 'male'), ('he,his', 'male'), ('he is a man', 'male'), ('i go by they', 'nonbinary'), ('them/they', 'nonbinary'), ('them,they', 'nonbinary'), ('xe', 'nonbinary'), ('ze', 'nonbinary'), ('zie', 'nonbinary'), ('hir', 'nonbinary'), ('pronoun.is/she', 'female'), ('pronoun.is/he', 'male'), ('pronoun.is/they', 'nonbinary'), ('pronoun.is/foo', 'nonbinary'), ('pronoun.is/zie', 'nonbinary'), ('pronoun.is/hir', 'nonbinary'), ('mum to one boy and one girl', 'andy'), ('proud mom', 'female'), ('cardamom', 'andy'), ('doting dad', 'male'), ('crawdad', 'andy'), ('grandfather', 'male'), ('the empire state building', 'andy'), ]: guess = declared_gender(description) assert guess == expected_gender, ( "Should have guessed profile '%s' was '%s', not '%s'" % ( description, expected_gender, guess))
def guessGender(name, description=None, country=None): g = "undetermined" g = declared_gender(description) if g == 'andy': for name, country in [ (split(name), None), (name, None), (unidecode(name), None), (split(unidecode(name)), None), ]: g = detector.get_gender(name, country) if g != 'andy': # Not androgynous. break g = detector.get_gender(rm_punctuation(name), country) if g != 'andy': # Not androgynous. break if g != 'andy': return g else: return "undetermined"