-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhits.py
More file actions
64 lines (47 loc) · 1.96 KB
/
hits.py
File metadata and controls
64 lines (47 loc) · 1.96 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
58
59
60
61
62
63
64
# import numpy
# from numpy import *
from Question import Question
import common2
from common2 import *
import pickle
import networkx as nx
from networkx.exception import NetworkXError
from hits_nx import hits_nx
graph = []
fin_pairs = open("questions/ques_pairs_with_groundtruth.txt")
lines = fin_pairs.readlines()
lines = ' '.join(lines)
fin_pairs.close()
asker_to_asker_question=[]
asker_question_to_best_answer_user=[]
asker_question_to_all_non_best_answers_user=[]
asker_to_best_answer_user=[]
asker_to_all_non_best_answer_user=[]
asker_question_to_best_answerer_user_questions =[]
with open("dump2/questions4.dump", "rb") as fp: # Unpickling
questions = pickle.load(fp)
with open("edges_dump/asker_to_asker_question.dump", "rb") as fp: #Pickling
asker_to_asker_question = pickle.load(fp)
with open("edges_dump/asker_question_to_best_answer_user.dump", "rb") as fp: #Pickling
asker_question_to_best_answer_user = pickle.load(fp)
with open("edges_dump/asker_question_to_all_non_best_answers_user.dump", "rb") as fp: #Pickling
asker_question_to_all_non_best_answers_user = pickle.load(fp)
# with open("edges_dump/asker_to_best_answer_user.dump", "rb") as fp: #Pickling
# asker_to_best_answer_user = pickle.load(fp)
# with open("edges_dump/asker_to_all_non_best_answer_user.dump", "rb") as fp: #Pickling
# asker_to_all_non_best_answer_user = pickle.load(fp)
with open("edges_dump/asker_question_to_best_answerer_user_questions.dump", "rb") as fp: #Pickling
asker_question_to_best_answerer_user_questions = pickle.load(fp)
edges=asker_to_asker_question+asker_question_to_best_answer_user+asker_question_to_best_answer_user+asker_question_to_best_answer_user+asker_question_to_best_answer_user+asker_question_to_best_answer_user
G=nx.Graph()
for edge in edges:
G.add_edge(*edge)
h,a=hits_nx(G)
# print h,a
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)