Repository navigation
Expand file tree
/
Copy pathpreamble_tool.py
More file actions
77 lines (73 loc) · 2.98 KB
/
Copy pathpreamble_tool.py
File metadata and controls
77 lines (73 loc) · 2.98 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
65
66
67
68
69
70
71
72
73
74
75
76
77
"""
Author: Henry Keena
File: preamble_tool.py
Description: Primary file for running the tool.
"""
#Declares Imports
import sys
import traceback
import collector as Collector
import analyzer as Analyzer
"""
Function: help()
Description: Print function to display help options for tool operations.
"""
def help():
print("\nUSAGE:\tpython3 preamble_tool.py [OPTION]")
print("\nOPTIONS:\n")
print("Display Help/Options\t\t--help\t-h")
print("Collect Project Data\t\t--collect-project-data\t-cpd")
print("Collect First Term Data\t\t--collect-first-terms\t-cft")
print("Analyze Project Data\t\t--analyze-project-data\t-apd")
print("")
"""
Function: main()
Description: Main function for handling operation/calls of the tool.
"""
def main():
try:
args = sys.argv[1:]
# Checks for valid number of arguments
if len(args) != 1:
print("\nINCORRECT NUMBER OF ARGUMENTS\n")
help()
exit()
# Display Help/Options
if args[0] == '--help' or args[0] == '-h':
help()
# Collect Project Data collector.py
elif args[0] == '--collect-project-data' or args[0] == '-cpd':
print("Beginning Preamble Collection...\n")
Collector.project_identifier_collector()
# Collect First Term Data analyzer.py
elif args[0] == '--collect-first-terms' or args[0] == '-cft':
print("Collecting Project Identifier First Terms...\n")
Analyzer.seperate_identifiers_all()
working_identifiers = Analyzer.get_all_identifiers()
working_identifiers = Analyzer.remove_single_letter_identifiers(working_identifiers)
working_identifiers = Analyzer.ronin_filter(working_identifiers)
Analyzer.first_term_fetcher(working_identifiers)
# Analyze Project Data analyzer.py
elif args[0] == '--analyze-project-data' or args[0] == '-apd':
print("Beginning Dataset Analysis...\n")
Analyzer.seperate_identifiers_all()
working_identifiers = Analyzer.get_all_identifiers()
start_num = len(working_identifiers)
working_identifiers = Analyzer.remove_single_letter_identifiers(working_identifiers)
working_identifiers = Analyzer.ronin_filter(working_identifiers)
working_identifiers = Analyzer.heuristics_filter(working_identifiers)
print("\nOriginal Number of Identifiers:", start_num)
filtered_num = len(working_identifiers)
print("Total Number of Removed/Filtered Identifiers :", (start_num-filtered_num))
print("Remaining Identifiers:", filtered_num)
Analyzer.generate_identifier_preamble_list(working_identifiers)
# Display Help if invalid argument
else:
print("\nINCORRECT ARGUMENT\n")
help()
exit()
except Exception:
print("RUNTIME EXCEPTION:", traceback.format_exc())
# Calls Main
if __name__=='__main__':
main()