You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.4 KiB

11 years ago
#!/usr/bin/env python
from __future__ import print_function
from base import Lo
import os, csv
los = Lo()
model_count = {
'I': {}, 'P': {}, 'C': {}, 'M': {}, 'F': {},
'H': {}, 'S': {}, 'D': {}, 'F': {}
}
def get_rank_thing(filename):
count = tot = lo_match = 0
with open(os.path.join(os.getcwd(), 'raw', filename)) as f:
reader = csv.reader(f)
reader.next()
for r in reader:
mn, cnt = r[0], r[9]
q = (
('A', r[1]), ('B', r[2]), ('C', r[3]), ('D', r[4]),
('E', r[5]), ('F', r[6]), ('G', r[7]), ('H', r[8]),
)
result = los.get_mm_tuple(q)
tot += 1
lo_match += len(result)
if result:
# print(u'%s > %s' % (r[0], list(result)))
count += 1
if cnt not in model_count[mn]: model_count[mn][cnt] = set()
model_count[mn][cnt] = model_count[mn][cnt].union(result)
print(u'[%s]\n Count = %s | Total = %s | Lo_w_match = %s' % (
filename, count, tot, lo_match))
def main():
fs = ('Case1_LS.csv', 'Case1_Gender.csv', 'Case1_Level.csv', 'Case1_SciF.csv')
for f in fs:
get_rank_thing(f)
for i, j in model_count.items():
print('\n===== %s =====' % i)
for k, v in j.items():
print('%s: \n' \
' %s' % (k, list(v)))
if __name__ == '__main__':
main()