genderComputer.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:gender_classifier 作者: LU-C4i 项目源码 文件源码
def initialCheckName(self, name):
        '''Check if name is written in Cyrillic or Greek script, and transliterate'''
        if only_cyrillic_chars(name) or only_greek_chars(name):
            name = unidecode(name)

        '''Initial check for gender-specific words at the beginning of the name'''
        f = name.split()[0]
        if f in self.maleWords:
            conf = 1
            return ('male',conf)
        elif f in self.femaleWords:
            conf = 1
            return ('female', conf)

        '''Check for gender-specific words at the second part of the name'''
        if len(name.split())> 1:
            l = name.split()[1]
            if l in self.maleWords:
                conf = 1
                return ('male',conf)
            elif l in self.femaleWords:
                conf = 1
                return ('female', conf)
        return (None,0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号