forked from shibing624/python-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcount_rate.py
More file actions
46 lines (42 loc) · 1.15 KB
/
count_rate.py
File metadata and controls
46 lines (42 loc) · 1.15 KB
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
# -*- coding: utf-8 -*-
# Author: XuMing <[email protected]>
# Data: 17/10/15
# Brief:
import sys
path_out = sys.argv[1]
count_total = 0
word_total = 0
idea_total = 0
word_right = 0
idea_right = 0
word_wrong_set = set()
idea_wrong_set = set()
for line in sys.stdin:
parts = line.strip().split("\t")
m_type = parts[3]
if m_type == 'word':
word_total += 1
word_status = parts[20]
if word_status == 'APPROVED':
word_right += 1
else:
word_wrong_set.add(line.strip())
elif m_type == 'idea':
idea_total += 1
idea_status = parts[20]
if idea_status == 'APPROVED':
idea_right += 1
else:
idea_wrong_set.add(line.strip())
word_rate = word_right / word_total
idea_rate = idea_right / idea_total
with open(path_out, 'w') as f:
f.write("word_rate:" + str(word_rate) + "\n")
f.write("idea_rate:" + str(idea_rate) + "\n")
f.write("\n\n")
f.write("word wrong line:\n")
for word_line in word_wrong_set:
f.write(word_line + "\n")
f.write("\nidea wrong line:\n")
for idea_line in idea_wrong_set:
f.write(idea_line + "\n")