File size: 1,077 Bytes
031e5e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import configparser
import logging

def getconfig(configfile_path:str):
    """

    configfile_path: file path of .cfg file

    """

    config = configparser.ConfigParser()

    try:
        config.read_file(open(configfile_path))
        return config
    except:
        logging.warning("config file not found")


# Declare all the necessary variables
def get_classifier_params(model_name):
    config = getconfig('paramconfig.cfg')
    params = {}
    params['model_name'] = config.get(model_name,'MODEL')
    params['split_by'] = config.get(model_name,'SPLIT_BY')
    params['split_length'] = int(config.get(model_name,'SPLIT_LENGTH'))
    params['split_overlap'] = int(config.get(model_name,'SPLIT_OVERLAP'))
    params['remove_punc'] = bool(int(config.get(model_name,'REMOVE_PUNC')))
    params['split_respect_sentence_boundary'] = bool(int(config.get(model_name,'RESPECT_SENTENCE_BOUNDARY')))
    params['threshold'] = float(config.get(model_name,'THRESHOLD'))
    params['top_n'] = int(config.get(model_name,'TOP_KEY'))

    return params