Beispiel #1
0
from os.path import join
from zoofoo import detect_gender
import csv
DATA_DIR = 'tempdata'
WRANGLED_FINAL_FILENAME = join(DATA_DIR, 'wrangledbabynames.json')
NAMES_DATA_ROWS = list(csv.DictReader(open(WRANGLED_FINAL_FILENAME)))


NAMES_TO_TEST = ['Michael', 'Kelly', 'Kanye', 'THOR', 'casey', 'Arya', 'ZZZblahblah']

namecount = {'M': 0, 'F': 0, 'NA': 0}
babycount = {'males': 0, 'females': 0}
for name in NAMES_TO_TEST:
    result = detect_gender(name)
    print(name, result['gender'], result['ratio'])
    if result['gender']:
        namecount[result['gender']] += 1
    if result['gender'] != 'NA': 
        babycount['males'] += result['males']
        babycount['females'] += result['females']

print("Total:")
print("F:", namecount['F'], 'M:', namecount['M'], 'NA:', namecount['NA'])
print('females:', babycount['females'], 'males:', babycount['males'])
Beispiel #2
0
from os.path import join
import json
from zoofoo import detect_gender

input_names = ['Michael', 'Kelly', 'Kanye', 'THOR', 'casey', 'Arya','ZZZblahblah']
answer = []

for name in input_names:
  answer.append(detect_gender(name))
    
boys = 0
girls = 0
na = 0

boy_count = 0
girl_count = 0

for i in answer:
    print(i['name'],i['gender'], i['ratio'])
    if i['gender'] == 'F':
        girls += 1                      #count gender
        girl_count += int(i['females']) #count girls
        boy_count += int(i['males'])    #count boys
    
    elif i['gender'] == 'M':
        boys += 1                       #count gender                  
        girl_count += int(i['females']) #count girls
        boy_count += int(i['males'])    #count boys

    else:
        na += 1 #count na
Beispiel #3
0
from os.path import join
from zoofoo import detect_gender
import csv
DATA_DIR = 'tempdata'
WRANGLED_FINAL_FILENAME = join(DATA_DIR, 'wrangledbabynames.json')
NAMES_DATA_ROWS = list(csv.DictReader(open(WRANGLED_FINAL_FILENAME)))

NAMES_TO_TEST = [
    'Michael', 'Kelly', 'Kanye', 'THOR', 'casey', 'Arya', 'ZZZblahblah'
]

namecount = {'M': 0, 'F': 0, 'NA': 0}
babycount = {'males': 0, 'females': 0}
for name in NAMES_TO_TEST:
    result = detect_gender(name)
    print(name, result['gender'], result['ratio'])
    if result['gender']:
        namecount[result['gender']] += 1

    if result['gender'] != 'NA':
        babycount['males'] += result['males']
        babycount['females'] += result['females']

print("Total:")
print("F:", namecount['F'], 'M:', namecount['M'], 'NA:', namecount['NA'])
print('females:', babycount['females'], 'males:', babycount['males'])
Beispiel #4
0
from zoofoo import detect_gender
detect_gender("Taylor")
Beispiel #5
0
from zoofoo import detect_gender

namelist=['Michael', 'Kelly', 'Kanye', 'THOR', 'casey', 'Arya', 'ZZZblahblah']
f=0
m=0
u=0
females=0
males=0
for name in namelist:
	persondict=detect_gender(name)
	print(name, persondict['gender'], persondict['ratio'])
	if persondict['gender']=='F':
		f+=1
		females+=persondict['females']
		males+=persondict['males']
	elif persondict['gender']== 'M':
		m+=1
		males+=persondict['males']
		females+=persondict['females']
	else:
		u+=1
print("Total:")
print("F:", f, "M:", m, "NA:", u)
print("females:", females, "males:", males)
Beispiel #6
0
from os.path import join
import json
from zoofoo import detect_gender

input_names = [
    'Michael', 'Kelly', 'Kanye', 'THOR', 'casey', 'Arya', 'ZZZblahblah'
]
answer = []

for name in input_names:
    answer.append(detect_gender(name))

boys = 0
girls = 0
na = 0

boy_count = 0
girl_count = 0

for i in answer:
    print(i['name'], i['gender'], i['ratio'])
    if i['gender'] == 'F':
        girls += 1  #count gender
        girl_count += int(i['females'])  #count girls
        boy_count += int(i['males'])  #count boys

    elif i['gender'] == 'M':
        boys += 1  #count gender
        girl_count += int(i['females'])  #count girls
        boy_count += int(i['males'])  #count boys