forked from lavizhao/Tyrion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraw_test.py
50 lines (34 loc) · 940 Bytes
/
raw_test.py
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
#coding: utf-8
'''
抽取出候选的测试集
'''
from data import get_conf
cf = get_conf()
#毛候选文件
idir = cf["item_dir"]
from gen_feature import get_mydb
mdb = get_mydb()
def main():
f = open(idir)
f.readline()
t = open(cf["pred129"],"w")
item_set = set()
count = 0
for line in f:
line = line.strip()
item,geo,category = line.split(',')
sql_str = 'select distinct user from trans where item = \"%s\"'%(item)
sql_res = mdb.select_sql(sql_str,"tmall")
for i in sql_res:
user = i[0]
beh = 0
geo = "ns"
date = "2014-12-19"
tm = "12"
tw = "%s,%s,%s,%s,%s,%s %s\n"%(user,item,beh,geo,category,date,tm)
t.write(tw)
count += 1
if count % 1000 == 0:
print count / 10000.0 , "万"
if __name__ == '__main__':
main()