-
Notifications
You must be signed in to change notification settings - Fork 0
/
patternParser.py
executable file
·52 lines (42 loc) · 1.74 KB
/
patternParser.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
from subprocess import call
import os
def read_file(database_name):
with open(database_name) as f:
lines = f.readlines()
lines = [line.replace('\n', '') for line in lines]
return lines
class SUMMARY:
def __init__(self) -> None:
self.TOTAL_PATTERNS = 0
self.TOTAL_VERTICES = 0
self.TOTAL_EDGES = 0
def get_statustics(self, lines):
clustered = []
temp = []
for line in lines:
if line == '':
self.TOTAL_PATTERNS += 1
if 'v' in line:
self.TOTAL_VERTICES += 1
if 'e' in line:
self.TOTAL_EDGES += 1
def main():
sm = SUMMARY()
# for i in range(2, 5):
# for j in range(100, 1000, 100):
# name_str = 'edge' + str(i) + 'k' + str(j)
# strr = 'java -jar spmf.jar run TKG sample.txt /home/nimashiri/vsprojects/CFGsubgraph/databases/' + name_str + '.txt' + ' ' + str(j) + ' ' + str(i) + ' ' + 'true false true'
# call([strr], shell=True)
for root, dirs, files in os.walk('databases'):
for file in sorted(files):
current_database = os.path.join(root, file)
lines = read_file(current_database)
sm.get_statustics(lines)
print("Summary for database {}".format(file))
print("===========================================================")
print("The total number of vertices {}".format(sm.TOTAL_PATTERNS))
print("The total number of edges {}".format(sm.TOTAL_EDGES))
print("The total number of patterns {}".format(sm.TOTAL_VERTICES))
print("===========================================================")
if __name__ == '__main__':
main()