Esempio n. 1
0
 def average(self, name, surname):
     r = 0
     count = 0
     avg = 0
     dgg = DameGenderGuesser()
     guess1 = int(dgg.guess(name, binary="True"))
     if (guess1 != 2):
         r = r + guess1
         count = count + 1
     if (self.config['DEFAULT']['genderapi'] == 'yes'):
         dga = DameGenderApi()
         guess2 = int(dga.guess(name, binary="True"))
         if (guess2 != 2):
             r = r + guess2
             count = count + 1
     if (self.config['DEFAULT']['genderize'] == 'yes'):
         dg = DameGenderize()
         guess3 = int(dg.guess(name, binary="True"))
         if (guess3 != 2):
             r = r + guess3
             count = count + 1
     if (self.config['DEFAULT']['namsor'] == 'yes'):
         dn = DameNamsor()
         guess4 = int(dn.guess(str(name), str(surname), binary="True"))
         if (guess4 != 2):
             r = r + guess4
             count = count + 1
     avg = r / count
     return avg
 def test_dame_genderguesser_gender_list(self):
     dgg = DameGenderGuesser()
     gl = dgg.gender_list(path="files/names/partial.csv")
     self.assertEqual(
         gl,
         [1, 1, 1, 1, 2, 1, 0, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1])
     self.assertEqual(len(gl), 21)
     self.assertEqual(dgg.females, 3)
     self.assertEqual(dgg.males, 16)
     self.assertEqual(dgg.unknown, 2)
 def test_dame_genderguesser_guess_list(self):
     dgg = DameGenderGuesser()
     self.assertEqual([
         'male', 'male', 'male', 'male', 'male', 'male', 'female', 'female',
         'male', 'male'
     ],
                      dgg.guess_list(path="files/names/partial.csv",
                                     binary=False)[0:10])
     self.assertEqual([1, 1, 1, 1, 1, 1, 0, 0, 1, 1],
                      dgg.guess_list(path="files/names/partial.csv",
                                     binary=True)[0:10])
Esempio n. 4
0
 def test_dame_genderguesser_gender_list_method_returns_correct_result(
         self):
     dgg = DameGenderGuesser()
     gl = dgg.gender_list()
     self.assertEqual(
         gl,
         [1, 1, 1, 1, 2, 1, 0, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1])
     self.assertEqual(len(gl), 21)
     self.assertEqual(dgg.females, 3)
     self.assertEqual(dgg.males, 16)
     self.assertEqual(dgg.unknown, 2)
 def test_genderguesser_list(self):
     dgg = DameGenderGuesser()
     g1 = dgg.guess("Sara", binary=False)
     self.assertEqual(g1, "female")
     g2 = dgg.guess("Sara", binary=True)
     self.assertEqual(g2, 0)
     g3 = dgg.guess("Laura", binary=False)
     self.assertEqual(g3, "female")
     g4 = dgg.guess("Laura", binary=True)
     self.assertEqual(g4, 0)
 def test_dame_genderguesser_accuracy(self):
     dgg = DameGenderGuesser()
     gl1 = dgg.gender_list(path="files/names/partial.csv")
     gl2 = dgg.guess_list(path="files/names/partial.csv", binary=True)
     self.assertTrue(dgg.accuracy_score_dame(gl1, gl2) >= 0.5)
     self.assertTrue(dgg.accuracy(path="files/names/partial.csv") >= 0.5)
Esempio n. 7
0
    if (dg.config['DEFAULT']['namsor'] == 'yes'):
        dn = DameNamsor()
        dn.pretty_gg_list(path=args.csv,
                          jsonf=args.jsondownloaded,
                          measure=args.measure,
                          api='Namsor')

    if (dg.config['DEFAULT']['genderize'] == 'yes'):
        dg = DameGenderize()
        dg.pretty_gg_list(path=args.csv,
                          jsonf=args.jsondownloaded,
                          measure=args.measure,
                          api='Genderize')

    dgg = DameGenderGuesser()
    dgg.pretty_gg_list(path=args.csv,
                       jsonf=args.jsondownloaded,
                       measure=args.measure,
                       api='Genderguesser')

    ds = DameSexmachine()
    ds.pretty_gg_list(path=args.csv,
                      jsonf=args.jsondownloaded,
                      measure=args.measure,
                      api='Damegender')

    if (dg.config['DEFAULT']['genderapi'] == 'yes'):
        dga = DameGenderApi()
        dga.pretty_gg_list(path=args.csv,
                           jsonf=args.jsondownloaded,
Esempio n. 8
0
    #print(dn.accuracy_score_dame([1, 1, 1, 1, 2, 1], [1, 1, 1, 1, 1, 1]))
    #namsor_accuracy = dn.accuracy_score_dame([1, 1, 1, 1, 2, 1], [1, 1, 1, 1, 2, 1])

    print("Namsor accuracy: %s" % namsor_accuracy)

    dg = DameGenderize()
    print("################### Genderize!!")
    gl = dg.gender_list(path=args.csv)
    print("Gender list: " + str(gl))
    sl = dg.guess_list(path=args.csv, binary=True)
    print("Guess list:  " +str(gl))

    genderize_accuracy = dg.accuracy_score_dame(gl,sl)
    print("Genderize accuracy: %s" % genderize_accuracy)

    dgg = DameGenderGuesser()
    print("################### GenderGuesser!!")
    gl = dgg.gender_list(path=args.csv)
    print("Gender list: " + str(gl))
    sl = dgg.guess_list(path=args.csv, binary=True)
    print("Guess list:  " +str(sl))

    genderguesser_accuracy = dgg.accuracy_score_dame(gl,sl)
    print("GenderGuesser accuracy: %s" % genderguesser_accuracy)

    ds = DameSexmachine()
    print("################### Dame Gender!!")
    gl = ds.gender_list(path=args.csv)
    print("Gender list: " + str(gl))
    sl = ds.guess_list(path=args.csv, binary=True)
    print("Guess list:  " +str(sl))
Esempio n. 9
0
        print("Namsor confusion matrix:\n")
        dn.print_confusion_matrix_dame(path=args.csv)
    elif (args.dimensions == "3x3"):
        namsor_confusion_matrix = dn.confusion_matrix(path=args.csv)
        print("Namsor confusion matrix:\n %s" % namsor_confusion_matrix)

    dg = DameGenderize()
    if (args.dimensions == "3x2"):
        print("Genderize confusion matrix:\n")
        dg.print_confusion_matrix_dame(path=args.csv)
    elif (args.dimensions == "3x3"):
        dg = DameGenderize()
        genderize_confusion_matrix = dg.confusion_matrix(path=args.csv)
        print("Genderize confusion matrix:\n %s" % genderize_confusion_matrix)

    dgg = DameGenderGuesser()
    if (args.dimensions == "3x2"):
        print("Gender Guesser confusion matrix:\n")
        dgg.print_confusion_matrix_dame(path=args.csv)
    elif (args.dimensions == "3x3"):
        genderguesser_confusion_matrix = dgg.confusion_matrix(path=args.csv)
        print("Gender Guesser confusion matrix:\n %s" % genderguesser_confusion_matrix)

    ds = DameSexmachine()
    if (args.dimensions == "3x2"):
        print("Sexmachine confusion matrix:\n")
        ds.print_confusion_matrix_dame(path=args.csv, ml=args.ml)
    elif (args.dimensions == "3x3"):
        ds = DameSexmachine()
        sexmachine_confusion_matrix = ds.confusion_matrix(path=args.csv)
        print("Sexmachine confusion matrix:\n %s" % sexmachine_confusion_matrix)
Esempio n. 10
0
if (args.api == "all"):
    dg = Gender()
    if (dg.config['DEFAULT']['namsor'] == 'yes'):
        dn = DameNamsor()
        dn.pretty_cm(path=args.csv, jsonf=args.jsondownloaded, reverse=args.reverse, dimensions=args.dimensions, api=args.api.title())

    if (dg.config['DEFAULT']['genderize'] == 'yes'):
        dg = DameGenderize()
        dg.pretty_cm(path=args.csv, jsonf=args.jsondownloaded, reverse=args.reverse, dimensions=args.dimensions, api=args.api.title())
#        dg.print_confusion_matrix_gender(path=args.csv, dimensions=args.dimensions)

    if (dg.config['DEFAULT']['genderapi'] == 'yes'):
        dga = DameGenderApi()
        dga.pretty_cm(path=args.csv, jsonf=args.jsondownloaded, reverse=args.reverse, dimensions=args.dimensions, api=args.api.title())

    dgg = DameGenderGuesser()
    dgg.print_confusion_matrix_gender(path=args.csv, dimensions=args.dimensions)

    ds = DameSexmachine()
    ds.pretty_cm(path=args.csv, jsonf=args.jsondownloaded, reverse=args.reverse, dimensions=args.dimensions, api=args.api.title())

    if (dg.config['DEFAULT']['nameapi'] == 'yes'):
        dna = DameNameapi()
        dna.pretty_cm(path=args.csv, jsonf=args.jsondownloaded, reverse=args.reverse, dimensions=args.dimensions, api=args.api.title())

elif (args.api == "namsor"):
    dn = DameNamsor()
    dn.pretty_cm(path=args.csv, jsonf=args.jsondownloaded, reverse=args.reverse, dimensions=args.dimensions, api=args.api.title())

elif (args.api == "genderize"):
    dg = DameGenderize()
Esempio n. 11
0
    gl1 = d.gender_list(path=args.csv)
    if (os.path.isfile(args.jsondownloaded)):
        gl2 = d.json2guess_list(jsonf=args.jsondownloaded, binary=True)
    else:
        gl2 = d.guess_list(path=args.csv, binary=True)
#    gl2 = d.guess_list(path=args.csv, binary=True)
    ec = d.error_coded(gl1, gl2)
    print("+ The error code: %s" % ec)
    ecwa = d.error_coded_without_na(gl1, gl2)
    print("+ The error code without na: %s" % ecwa)
    naCoded = d.na_coded(gl1, gl2)
    print("+ The na coded: %s" % naCoded)
    egb = d.error_gender_bias(gl1, gl2)
    print("+ The error gender bias: %s" % egb)
elif (args.api == "genderguesser"):
    d = DameGenderGuesser()
    print("Gender Guesser with %s has: " % args.csv)
    gl1 = d.gender_list(path=args.csv)
    gl2 = d.guess_list(path=args.csv, binary=True)
    ec = d.error_coded(gl1, gl2)
    print("+ The error code: %s" % ec)
    ecwa = d.error_coded_without_na(gl1, gl2)
    print("+ The error code without na: %s" % ecwa)
    naCoded = d.na_coded(gl1, gl2)
    print("+ The na coded: %s" % naCoded)
    egb = d.error_gender_bias(gl1, gl2)
    print("+ The error gender bias: %s" % egb)
elif (args.api == "nameapi"):
    d = DameNameapi()
    print("Nameapi with %s has: " % args.csv)
    gl1 = d.gender_list(path=args.csv)
Esempio n. 12
0
 def test_dame_genderguesser_accuracy_method_returns_correct_result(self):
     dgg = DameGenderGuesser()
     self.assertTrue(dgg.accuracy(path="files/names/partial.csv") >= 0.5)
Esempio n. 13
0
import sys
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('name',  help="Name to be detected")
parser.add_argument('--surname', help="Surname to be detected")
parser.add_argument("--api", choices=['namsor', 'genderize', 'genderguesser', 'genderapi', 'nameapi'], required=True)
#parser.add_argument('--prob', default="yes", choices=['yes', 'no'])
parser.add_argument('--version', action='version', version='0.1')

args = parser.parse_args()

du = DameUtils()

if (len(sys.argv) > 1):
    if (args.api == "genderguesser"):
        dgg = DameGenderGuesser()
        print(dgg.guess(args.name))
    elif (args.api == "genderapi"):
        dga = DameGenderApi()
        print(dga.guess(args.name, binary=False))
        print("accuracy: " + str(dga.accuracy(args.name)))
    elif (args.api == "genderize"):
        dg = DameGenderize()
        print(dg.guess(args.name))
        print("probability: " + str(dg.prob(args.name)))
    elif (args.api == "namsor"):
        dn = DameNamsor()
        if (du.is_not_blank(args.surname)):
            print(dn.guess(str(args.name), str(args.surname)))
            print("scale: " + str(dn.scale(str(args.name), str(args.surname))))
        else: