-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist-clones.py
More file actions
40 lines (33 loc) · 1.35 KB
/
Copy pathlist-clones.py
File metadata and controls
40 lines (33 loc) · 1.35 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
#!/usr/bin/env python3
from parse_dist_mapping import LevenDistMapping, load_leven_dist_mapping
from typing import List
def print_clone_type(mapping: LevenDistMapping, clone_type: int, leven_range: List[int]) -> int:
"""Returns the number of clones of this type detected"""
counter = 0
print(" - type", clone_type)
for diff, leven in mapping.items():
if leven in leven_range:
print(" -", diff, f"[{leven}]")
counter += 1
return counter
if __name__ == '__main__':
import sys
if len(sys.argv) != 2:
print(f"usage: {sys.argv[0]} <mapping.csv>")
exit(1)
mapping = load_leven_dist_mapping(sys.argv[1])
t1 = print_clone_type(mapping, 1, list(range(0, 9)))
t2 = print_clone_type(mapping, 2, list(range(9, 18)))
t3 = print_clone_type(mapping, 3, list(range(18, 27)))
t4 = print_clone_type(mapping, 4, list(range(30, 36)))
print(" - others")
other = 0
for diff, leven in mapping.items():
if leven > 35:
other += 1
print(" -", diff, f"[{leven}]")
print("======= Clones ======= ")
print(f"Type-1: {t1}\nType-2: {t2}\nType-3: {t3}\nType-4: {t4}")
print(f"Clones: {t1+t2+t3+t4} --- Others: {other}")
# it does not have to be efficient :D
print(f"Max-Dist: {max(mapping.values())}\nMin-Dist: {min(mapping.values())}")