mirror of https://gitlab.com/bashrc2/epicyon
Gender detection from profile tag
parent
d96cdd6c85
commit
5b2986d685
3
inbox.py
3
inbox.py
|
@ -2195,7 +2195,8 @@ def _updateSpeaker(baseDir: str, nickname: str, domain: str,
|
|||
|
||||
speakerName = \
|
||||
getDisplayName(baseDir, postJsonObject['actor'], personCache)
|
||||
gender = getGenderFromBio(baseDir, postJsonObject['actor'], personCache)
|
||||
gender = getGenderFromBio(baseDir, postJsonObject['actor'],
|
||||
personCache, translate)
|
||||
if not speakerName:
|
||||
return
|
||||
if announcingActor:
|
||||
|
|
|
@ -381,5 +381,8 @@
|
|||
"mentioning": "ذكر",
|
||||
"sad face": "وجه حزين",
|
||||
"thinking emoji": "التفكير الرموز التعبيرية",
|
||||
"laughing": "يضحك"
|
||||
"laughing": "يضحك",
|
||||
"gender": "جنس تذكير أو تأنيث",
|
||||
"He/Him": "هو",
|
||||
"She/Her": "هي"
|
||||
}
|
||||
|
|
|
@ -381,5 +381,8 @@
|
|||
"mentioning": "esmentant",
|
||||
"sad face": "cara trista",
|
||||
"thinking emoji": "emoji pensant",
|
||||
"laughing": "rient"
|
||||
"laughing": "rient",
|
||||
"gender": "gènere",
|
||||
"He/Him": "Ell",
|
||||
"She/Her": "Ella"
|
||||
}
|
||||
|
|
|
@ -381,5 +381,8 @@
|
|||
"mentioning": "sôn",
|
||||
"sad face": "wyneb trist",
|
||||
"thinking emoji": "meddwl emoji",
|
||||
"laughing": "chwerthin"
|
||||
"laughing": "chwerthin",
|
||||
"gender": "rhyw",
|
||||
"He/Him": "Ef",
|
||||
"She/Her": "Hi/Ei"
|
||||
}
|
||||
|
|
|
@ -381,5 +381,8 @@
|
|||
"mentioning": "Erwähnen",
|
||||
"sad face": "trauriges Gesicht",
|
||||
"thinking emoji": "Emowji denken",
|
||||
"laughing": "Lachen"
|
||||
"laughing": "Lachen",
|
||||
"gender": "geschlecht",
|
||||
"He/Him": "Er/ihm",
|
||||
"She/Her": "Sie"
|
||||
}
|
||||
|
|
|
@ -381,5 +381,8 @@
|
|||
"mentioning": "mentioning",
|
||||
"sad face": "sad face",
|
||||
"thinking emoji": "thinking emowji",
|
||||
"laughing": "laughing"
|
||||
"laughing": "laughing",
|
||||
"gender": "gender",
|
||||
"He/Him": "He/Him",
|
||||
"She/Her": "She/Her"
|
||||
}
|
||||
|
|
|
@ -381,5 +381,8 @@
|
|||
"mentioning": "mencionar",
|
||||
"sad face": "cara triste",
|
||||
"thinking emoji": "pensando emowji",
|
||||
"laughing": "risa"
|
||||
"laughing": "risa",
|
||||
"gender": "género",
|
||||
"He/Him": "El",
|
||||
"She/Her": "Ella"
|
||||
}
|
||||
|
|
|
@ -381,5 +381,8 @@
|
|||
"mentioning": "mentionnant",
|
||||
"sad face": "visage triste",
|
||||
"thinking emoji": "penser emowji",
|
||||
"laughing": "en riant"
|
||||
"laughing": "en riant",
|
||||
"gender": "le genre",
|
||||
"He/Him": "Il/Lui",
|
||||
"She/Her": "Elle"
|
||||
}
|
||||
|
|
|
@ -381,5 +381,8 @@
|
|||
"mentioning": "ag lua",
|
||||
"sad face": "aghaidh brónach",
|
||||
"thinking emoji": "ag smaoineamh emowji",
|
||||
"laughing": "ag gáire"
|
||||
"laughing": "ag gáire",
|
||||
"gender": "inscne",
|
||||
"He/Him": "Sé/Eisean",
|
||||
"She/Her": "Sí"
|
||||
}
|
||||
|
|
|
@ -381,5 +381,8 @@
|
|||
"mentioning": "उल्लेख",
|
||||
"sad face": "उदास चेहरा",
|
||||
"thinking emoji": "सोच रहे हैं इमोजी",
|
||||
"laughing": "हस रहा"
|
||||
"laughing": "हस रहा",
|
||||
"gender": "लिंग",
|
||||
"He/Him": "वह/उसे",
|
||||
"She/Her": "वह/उसकी"
|
||||
}
|
||||
|
|
|
@ -381,5 +381,8 @@
|
|||
"mentioning": "menzionando",
|
||||
"sad face": "faccia triste",
|
||||
"thinking emoji": "pensiero emoji",
|
||||
"laughing": "ridendo"
|
||||
"laughing": "ridendo",
|
||||
"gender": "genere",
|
||||
"He/Him": "Lui",
|
||||
"She/Her": "Lei"
|
||||
}
|
||||
|
|
|
@ -381,5 +381,8 @@
|
|||
"mentioning": "言及する",
|
||||
"sad face": "悲しい顔",
|
||||
"thinking emoji": "絵文字を考える",
|
||||
"laughing": "笑い"
|
||||
"laughing": "笑い",
|
||||
"gender": "性別",
|
||||
"He/Him": "彼",
|
||||
"She/Her": "彼女"
|
||||
}
|
||||
|
|
|
@ -377,5 +377,8 @@
|
|||
"mentioning": "mentioning",
|
||||
"sad face": "sad face",
|
||||
"thinking emoji": "thinking emowji",
|
||||
"laughing": "laughing"
|
||||
"laughing": "laughing",
|
||||
"gender": "gender",
|
||||
"He/Him": "He/Him",
|
||||
"She/Her": "She/Her"
|
||||
}
|
||||
|
|
|
@ -381,5 +381,8 @@
|
|||
"mentioning": "mencionando",
|
||||
"sad face": "rosto triste",
|
||||
"thinking emoji": "pensando emowji",
|
||||
"laughing": "rindo"
|
||||
"laughing": "rindo",
|
||||
"gender": "gênero",
|
||||
"He/Him": "Ele",
|
||||
"She/Her": "Ela"
|
||||
}
|
||||
|
|
|
@ -381,5 +381,8 @@
|
|||
"mentioning": "упоминание",
|
||||
"sad face": "грустное лицо",
|
||||
"thinking emoji": "думающий смайлик",
|
||||
"laughing": "смеющийся"
|
||||
"laughing": "смеющийся",
|
||||
"gender": "Пол",
|
||||
"He/Him": "Он/Его",
|
||||
"She/Her": "Она/Ее"
|
||||
}
|
||||
|
|
|
@ -381,5 +381,8 @@
|
|||
"mentioning": "提及",
|
||||
"sad face": "悲伤的脸",
|
||||
"thinking emoji": "思维表情符号",
|
||||
"laughing": "笑"
|
||||
"laughing": "笑",
|
||||
"gender": "",
|
||||
"He/Him": "",
|
||||
"She/Her": ""
|
||||
}
|
||||
|
|
41
utils.py
41
utils.py
|
@ -669,7 +669,8 @@ def getDisplayName(baseDir: str, actor: str, personCache: {}) -> str:
|
|||
return nameFound
|
||||
|
||||
|
||||
def getGenderFromBio(baseDir: str, actor: str, personCache: {}) -> str:
|
||||
def getGenderFromBio(baseDir: str, actor: str, personCache: {},
|
||||
translate: {}) -> str:
|
||||
"""Tries to ascertain gender from bio description
|
||||
"""
|
||||
if '/statuses/' in actor:
|
||||
|
@ -678,7 +679,21 @@ def getGenderFromBio(baseDir: str, actor: str, personCache: {}) -> str:
|
|||
return None
|
||||
bioFound = None
|
||||
if personCache[actor].get('actor'):
|
||||
if personCache[actor]['actor'].get('summary'):
|
||||
# is gender defined as a profile tag?
|
||||
if personCache[actor]['actor'].get('attachment'):
|
||||
tagsList = personCache[actor]['actor']['attachment']
|
||||
if isinstance(tagsList, list):
|
||||
for tag in tagsList:
|
||||
if not isinstance(tag, dict):
|
||||
continue
|
||||
if not tag.get('name') or not tag.get('value'):
|
||||
continue
|
||||
if tag['name'].lower() == \
|
||||
translate['gender'].lower():
|
||||
bioFound = tag['value']
|
||||
break
|
||||
# if not then use the bio
|
||||
if not bioFound and personCache[actor]['actor'].get('summary'):
|
||||
bioFound = personCache[actor]['actor']['summary']
|
||||
else:
|
||||
# Try to obtain from the cached actors
|
||||
|
@ -687,14 +702,32 @@ def getGenderFromBio(baseDir: str, actor: str, personCache: {}) -> str:
|
|||
if os.path.isfile(cachedActorFilename):
|
||||
actorJson = loadJson(cachedActorFilename, 1)
|
||||
if actorJson:
|
||||
if actorJson.get('summary'):
|
||||
# is gender defined as a profile tag?
|
||||
if actorJson.get('attachment'):
|
||||
tagsList = actorJson['attachment']
|
||||
if isinstance(tagsList, list):
|
||||
for tag in tagsList:
|
||||
if not isinstance(tag, dict):
|
||||
continue
|
||||
if not tag.get('name') or not tag.get('value'):
|
||||
continue
|
||||
if tag['name'].lower() == \
|
||||
translate['gender'].lower():
|
||||
bioFound = tag['value']
|
||||
break
|
||||
# if not then use the bio
|
||||
if not bioFound and actorJson.get('summary'):
|
||||
bioFound = actorJson['summary']
|
||||
if not bioFound:
|
||||
return None
|
||||
gender = 'They/Them'
|
||||
bioFoundOrig = bioFound
|
||||
bioFound = bioFound.lower()
|
||||
if 'him' in bioFound or 'male' in bioFound:
|
||||
if translate['He/Him'] in bioFound:
|
||||
gender = 'He/Him'
|
||||
elif translate['She/Her'] in bioFound:
|
||||
gender = 'She/Her'
|
||||
elif 'him' in bioFound or 'male' in bioFound:
|
||||
gender = 'He/Him'
|
||||
elif 'her' in bioFound or 'she' in bioFound or \
|
||||
'fem' in bioFound or 'woman' in bioFound:
|
||||
|
|
Loading…
Reference in New Issue