-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
52 lines (47 loc) · 2.18 KB
/
main.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 TextUtilities.indexer import Indexer
import GUI.MainWindow
import os
import argparse
from MainImplementation.GameSearcher import GameSearcher
from rich.console import Console
def main():
# defining the parameters of the program
parser = argparse.ArgumentParser(description="Search engine based on Steam collection games")
parser.add_argument("-s", "--sentiment",
dest="vSentiment",
type=str,
default="false",
help="Version of sentiment analysis used to compute the average sentiment values "
"for every game: av = standard average, "
"inav = Inverted Neutral Weighted Average, "
"false = Sentiment Analysis not used.",
metavar="inav")
parser.add_argument("-t", "--threads",
dest="nThreads",
type=int,
default=4,
help="Number of threads used to create the index. Default number = 4.",
metavar=4)
console = Console()
# arguments parsing
args = parser.parse_args()
if (args.nThreads not in range(1, 11)):
console.log("[red] The number of threads must be in the following range: 1-10")
return
if (args.vSentiment not in ["inav", "av", "false"]):
console.log(f"[red] {args.vSentiment} is not a valid value for \"-s\" \"--sentiment\" option")
return
index_dir = "indexdir/base" if args.vSentiment == "false" else "indexdir/sentiment"
if not os.path.exists("indexdir"):
os.mkdir("indexdir")
with console.status("[bold green]Creating index...") as status:
main_idx, reviews_idx = Indexer.openIndex("Dataset", index_dir, console,
True if args.vSentiment != "false" else False,
args.nThreads)
searcher = GameSearcher(main_idx, reviews_idx, True if args.vSentiment != "false" else False, args.vSentiment)
GUI.MainWindow.launchGui(searcher)
'''
Main program
'''
if __name__ == "__main__":
main()