-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain2_chinese.py
More file actions
58 lines (41 loc) · 1.13 KB
/
main2_chinese.py
File metadata and controls
58 lines (41 loc) · 1.13 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
47
48
49
50
51
52
53
54
55
56
57
import pagerank
from Question import Question
from common2 import *
graph = []
edges_dict = {}
def addEdge(e):
if e not in edges_dict:
edges_dict[e] = True
graph.append(e)
counter = 0
for user in user_questions.keys(): #iterate over the users
counter += 1
if counter % 100 == 0:
print counter, len(graph)
try:
non_best_answers = user_non_best_answers_question_id[user]
best_answers = user_best_answers_question_id[user]
except:
continue
for best_answer_question_id in best_answers:
for non_best_answer_question_id in non_best_answers:
addEdge((int(non_best_answer_question_id), int(best_answer_question_id)))
# from hits_nx import hits_nx
# import networkx as nx
# G=nx.Graph()
# for edge in graph:
# G.add_edge(*edge)
# h,a=hits_nx(G)
# difficulty = dict()
# for i in questions.keys():
# if(h.has_key(int(i))):
# difficulty[int(i)] = h[int(i)]
# else:
# difficulty[int(i)]=0
# computeAccuracy(difficulty)
f = open('edges_chinese.txt','w')
for edge in graph:
f.write(str(edge[0]) + " " + str(edge[1]) + "\n")
f.close()
# ratings = pagerank.pagerank(graph)[0]
# computeAccuracy(ratings)