-
Notifications
You must be signed in to change notification settings - Fork 19
/
similarity.py
57 lines (48 loc) · 1.54 KB
/
similarity.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
import os
import os.path
import shutil
import time, datetime
import md5
import operator
app_info_list=[]
class app_info:
def __init__(self):
self.packagename=""
self.classSignatures=[]
def DA_init_data(filePath):
inputFile = open(filePath, 'r')
lines = inputFile.readlines()
i = 0
while i<len(lines) and lines != "":
app_info_tmp = app_info()
app_info_tmp.packagename = lines[i].strip()
i += 1
while i < len(lines) and lines[i].find("########")==-1:
classSignature=lines[i].split(" ")
#print classSignature[0]
app_info_tmp.classSignatures.append(classSignature[0])
i += 1
app_info_list.append(app_info_tmp)
i += 1
# for i in range(len(app_info_list)):
# print app_info_list[i].packagename
# for j in range(10):
# print app_info_list[i].classSignatures[j]
# print " "
def DA_compare_class(classListA, classListB):
pointA = 0
pointB = 0
score = 0
while pointA < len(classListA) and pointB < len(classListB):
if cmp(classListA[pointA], classListB[pointB]) == 0:
score += 1
pointA += 1
pointB += 1
elif cmp(classListA[pointA], classListB[pointB]) < 0:
pointA += 1
else:
pointB += 1
return score
if __name__=="__main__":
DA_init_data('./result/result.txt')
print DA_compare_class(app_info_list[0].classSignatures, app_info_list[1].classSignatures)