-
Notifications
You must be signed in to change notification settings - Fork 0
/
analogy_confirmation_final.py
62 lines (56 loc) · 1.74 KB
/
analogy_confirmation_final.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
def loadGoldData(dataset):
with open(dataset, 'r') as file:
lines = file.readlines()
simGold = []
i = 0
while i < len(lines):
line = lines[i].strip()
i += 1
if line.startswith("#"):
continue
if line.startswith("\n"):
i += 1
continue
splits = line.split(" ")
correctedsplits = [ ]
correctedsplits.append(splits[0])
correctedsplits.append(splits[1])
correctedsplits.append(splits[2])
correctedsplits.append(splits[3])
correctedsplits.append(splits[4])
correctedsplits.append(splits[5])
correctedsplits.append(splits[6])
correctedsplits.append(splits[7])
correctedsplits.append(splits[8])
simGold.append(correctedsplits)
return simGold
def confirm_correct():
count=0.0
countlines=0.0
analogydataset = loadGoldData(files_op)
for value in analogydataset:
#if(value[6]==word):
similarityrating=value[5]
originalRating=value[4]
if (originalRating >= '4.0'):
countlines+=1
if similarityrating >= '0.65':
count+=1
print(count/countlines)
def confirm_wrong():
count=0.0
countlines=0.0
analogydataset = loadGoldData(files_op)
for value in analogydataset:
#if(value[6]==word):
similarityrating=value[5]
originalRating=value[4]
if (originalRating <= '2.0'):
countlines+=1
if similarityrating <= '0.20':
count+=1
print(count/countlines)
if __name__ == '__main__':
files_op ="input_file"
confirm_correct()
confirm_wrong()