<commit_before>from ConfigParser import ConfigParser

defaults = {'parse': 'defaultparse',
            'clean': True,
            'consolidate': True,
            'datadir': '/data/patentdata/patents/2013',
            'dataregex': 'ipg\d{6}.xml'}

def extract_process_options(handler):
    """
    Extracts the high level options from the [process] section
    of the configuration file. Returns a dictionary of the options
    """
    result = {}
    result['parse'] = handler.get('process','parse')
    result['clean'] = handler.get('process','clean')
    result['consolidate'] = handler.get('process','consolidate')
    result['outputdir'] = handler.get('process','outputdir')
    return result

def extract_parse_options(handler, section):
    options = {}
    options['datadir'] = handler.get(section,'datadir')
    options['dataregex'] = handler.get(section,'dataregex')
    return options

def get_config_options(configfile):
    handler = ConfigParser(defaults)
    handler.read(configfile)
    process_config = extract_process_options(handler)
    parse_config = extract_parse_options(handler, process_config['parse'])
    return process_config, parse_config
<commit_msg>extract actual Boolean values<commit_after>from ConfigParser import ConfigParser

defaults = {'parse': 'defaultparse',
            'clean': True,
            'consolidate': True,
            'datadir': '/data/patentdata/patents/2013',
            'dataregex': 'ipg\d{6}.xml'}

def extract_process_options(handler):
    """
    Extracts the high level options from the [process] section
    of the configuration file. Returns a dictionary of the options
    """
    result = {}
    result['parse'] = handler.get('process','parse')
    result['clean'] = handler.get('process','clean') == 'True'
    result['consolidate'] = handler.get('process','consolidate') == 'True'
    result['outputdir'] = handler.get('process','outputdir')
    return result

def extract_parse_options(handler, section):
    options = {}
    options['datadir'] = handler.get(section,'datadir')
    options['dataregex'] = handler.get(section,'dataregex')
    return options

def get_config_options(configfile):
    handler = ConfigParser(defaults)
    handler.read(configfile)
    process_config = extract_process_options(handler)
    parse_config = extract_parse_options(handler, process_config['parse'])
    return process_config, parse_config

{'fraction_non_alphanumeric': 0.13344453711426188, 'fraction_numerical': 0.004170141784820684, 'mean_word_length': 4.170258620689655, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5590123', 'n_tokens_mistral': 682, 'n_tokens_neox': 675, 'n_words': 145}