-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigurator.py
35 lines (24 loc) · 889 Bytes
/
configurator.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
import json
class Configurator:
"""
"""
def __init__(self, path="config.json"):
self.cfg = self.load_json(path)
def get_stop_words(self):
return self.load_txt(self.cfg["stop_words_path"])
def get_black_words(self):
return self.load_txt(self.cfg["black_words_path"])
def get_start_words(self):
return self.load_txt(self.cfg["starts_words_path"])
def get_in_words(self):
return self.load_txt(self.cfg["in_words_path"])
def get_exact_words(self):
return self.load_txt(self.cfg["exact_words_path"])
@staticmethod
def load_json(path, encoding="utf-8"):
with open(path, encoding=encoding) as file:
return json.load(file)
@staticmethod
def load_txt(path, encoding="utf-8"):
with open(path, 'r', encoding=encoding) as f:
return f.read().splitlines()