forked from findmyway/DBLP-Coauthor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapper2.py
34 lines (31 loc) · 1023 Bytes
/
mapper2.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
#!/usr/bin/env python
import sys
def creatDic():
freqDic = {}
with open('sortedList', 'r') as sortedList:
for line in sortedList:
line = line.strip().split('\t')
freqDic[int(line[0])] = int(line[1])
return freqDic
def read_input(inFile):
for line in inFile:
yield line.split(',')
def main(freqDic, minSup):
data = read_input(sys.stdin)
for names in data:
names = {name:freqDic[int(name)] for name in names \
if name.isdigit() \
and freqDic.get(int(name), 0) >= minSup}
lenth = len(names)
if lenth >= 2:
conPatItems = [name for name, value in \
sorted(names.iteritems(), \
key = lambda p:p[1])]
for i in range(lenth-1):
print "%s\t%s" % (conPatItems[i], conPatItems[i+1::])
else:
continue
if __name__ == '__main__':
support = 100
dic = creatDic()
main(dic, support)