-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindgender.pro
58 lines (34 loc) · 1.33 KB
/
findgender.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
pro findgender,infile
; written in IDL, because I am stupid and old and lazy
if not keyword_set(infile) then infile = 'aas_registrant_firstname.txt'
readcol,infile,aas_name,f='(A)',/silent
readcol,'female_uniq.csv',f_name,f_num,f='(A,F)',/silent
readcol,'male_uniq.csv',m_name,m_num,f='(A,F)',/silent
f_name = strlowcase(f_name)
m_name = strlowcase(m_name)
aas_name = strlowcase(aas_name)
gender = strarr(n_elements(aas_name)) + 'x'
for n=0L,n_elements(aas_name)-1 do begin
xf = where(f_name eq aas_name[n])
xm = where(m_name eq aas_name[n])
if xf[0] eq -1 and xm[0] eq -1 then continue
if xm[0] ne -1 and xf[0] ne -1 then begin
g = f_num[xf[0]] / m_num[xm[0]]
if g gt 1. then gender[n] = 'f'
if g le 1. then gender[n] = 'm'
endif
if xm[0] ne -1 and xf[0] eq -1 then gender[n] = 'm'
if xf[0] ne -1 and xm[0] eq -1 then gender[n] = 'f'
endfor
forprint,textout=infile+'.gender',aas_name,gender,/silent,/nocomm,f='(A,",",A4)'
print,''
print,'fraction of names w/ gender assigned:'
print,float(n_elements(where(gender ne "x")))/float(n_elements(gender))
print,''
print,'fraction of men'
print,float(n_elements(where(gender eq "m")))/float(n_elements(where(gender ne "x")))
print,''
print,'fraction of women'
print,float(n_elements(where(gender eq "f")))/float(n_elements(where(gender ne "x")))
stop
end