-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
84 lines (41 loc) · 1.8 KB
/
main.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# -*- coding: utf-8 -*-
import twitter.gen_friendship as twiter
import github.gen_friendship as github
import cal_matrix
import filters
import argparse
def start(githubu, twiteru, depth=2, iterations=100):
print "crawl the github social graph of %s" % githubu
matrix_g, nodes_g = github.start(githubu, depth)
print "crawl the twiter social graph of %s" % twiteru
matrix_t, nodes_t = twiter.start(twiteru, depth)
print "calculate the similarity matrix between github social graph and twiter social graph"
similarity_matrix = cal_matrix.cal_similarity_matrix(matrix_g, matrix_t, iterations)
print "make decision"
return filters.start(similarity_matrix, nodes_g, nodes_t)
if __name__ == "__main__":
argument_parser = argparse.ArgumentParser(description="")
argument_parser.add_argument("github", help="")
argument_parser.add_argument("twiter", help="")
argument_parser.add_argument("-d", "--depth", help="", type=int)
argument_parser.add_argument("-i", "--iterations", type=int, help="")
args = argument_parser.parse_args()
githubu = args.github
twiteru = args.twiter
print "crawl the github social graph of %s" % githubu
if args.depth:
matrix_g, nodes_g = github.start(githubu, args.depth)
else:
matrix_g, nodes_g = github.start(githubu)
print "crawl the twiter social graph of %s" % twiteru
if args.depth:
matrix_t, nodes_t = twiter.start(twiteru, args.depth)
else:
matrix_t, nodes_t = twiter.start(twiteru)
print "calculate the similarity matrix between github social graph and twiter social graph"
if args.iterations:
similarity_matrix = cal_matrix.cal_similarity_matrix(matrix_g, matrix_t, args.iterations)
else:
similarity_matrix = cal_matrix.cal_similarity_matrix(matrix_g, matrix_t)
print "make decision"
filters.start(similarity_matrix, nodes_g, nodes_t)