forked from zhaoyingjun/chatbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getConfig.py
31 lines (26 loc) · 876 Bytes
/
getConfig.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
import math
import os
import random
import sys
import time
import numpy as np
# python2 and python3 support
try:
reload
except NameError:
# py3k has unicode by default
pass
else:
reload(sys).setdefaultencoding('utf-8')
try:
from ConfigParser import SafeConfigParser
except:
from configparser import SafeConfigParser # In Python 3, ConfigParser has been renamed to configparser for PEP 8 compliance.
def get_config(config_file='seq2seq.ini'):
parser = SafeConfigParser()
parser.read(config_file)
# get the ints, floats and strings
_conf_ints = [ (key, int(value)) for key,value in parser.items('ints') ]
_conf_floats = [ (key, float(value)) for key,value in parser.items('floats') ]
_conf_strings = [ (key, str(value)) for key,value in parser.items('strings') ]
return dict(_conf_ints + _conf_floats + _conf_strings)