leavoigt commited on
Commit
5138366
1 Parent(s): 0220aea

Create config.py

Browse files
Files changed (1) hide show
  1. utils/config.py +31 -0
utils/config.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import configparser
2
+ import logging
3
+
4
+ def getconfig(configfile_path:str):
5
+ """
6
+ configfile_path: file path of .cfg file
7
+ """
8
+
9
+ config = configparser.ConfigParser()
10
+
11
+ try:
12
+ config.read_file(open(configfile_path))
13
+ return config
14
+ except:
15
+ logging.warning("config file not found")
16
+
17
+
18
+ # Declare all the necessary variables
19
+ def get_classifier_params(model_name):
20
+ config = getconfig('paramconfig.cfg')
21
+ params = {}
22
+ params['model_name'] = config.get(model_name,'MODEL')
23
+ params['split_by'] = config.get(model_name,'SPLIT_BY')
24
+ params['split_length'] = int(config.get(model_name,'SPLIT_LENGTH'))
25
+ params['split_overlap'] = int(config.get(model_name,'SPLIT_OVERLAP'))
26
+ params['remove_punc'] = bool(int(config.get(model_name,'REMOVE_PUNC')))
27
+ params['split_respect_sentence_boundary'] = bool(int(config.get(model_name,'RESPECT_SENTENCE_BOUNDARY')))
28
+ params['threshold'] = float(config.get(model_name,'THRESHOLD'))
29
+ params['top_n'] = int(config.get(model_name,'TOP_KEY'))
30
+
31
+ return params