<commit_before>#usr/bin python env
import sys

def config(afile="./config.json"):
    '''load config given a YAML or a JSON file'''
    if afile.endswith("json"):
        import json
        with open(afile) as json_f:
            try:
                config = json.load(json_f)
            except ValueError as e:
                sys.exit("Error parsing config.json file: %s" %e)
        return config
        
        
    elif afile.endswith("yml"):
        import yaml
        try:
            with open(afile, 'r') as ymlfile:
                try:
                    config = yaml.load(ymlfile.read())
                except ValueError as e:
                    sys.exit("Error parsing config.yml file: %s" %e)
            return config
        except IOError, e:
            sys.exit("File not found: config.yml")
    else:
        sys.exit("No config file found")<commit_msg>config aBSPATH<commit_after>#usr/bin python env
import os

def config(afile="config.json"):
    '''load config given a YAML or a JSON file'''
    if afile.endswith("json"):
        import json
        curr_dir = os.path.join(os.getcwd(), "crawtext")
        afile = os.path.join(curr_dir, afile)
        with open(afile) as json_f:
            try:
                config = json.load(json_f)
            except ValueError as e:
                sys.exit("Error parsing config.json file: %s" %e)
        return config
        
        
    elif afile.endswith("yml"):
        import yaml
        
        curr_dir = os.path.join(os.getcwd(), "crawtext")
        afile = os.path.join(curr_dir, afile)
        try:
            with open(afile, 'r') as ymlfile:
                try:
                    config = yaml.load(ymlfile.read())
                except ValueError as e:
                    sys.exit("Error parsing config.yml file: %s" %e)
            return config
        except IOError, e:
            sys.exit("File not found: config.yml")
    else:
        sys.exit("No config file found")
{'fraction_non_alphanumeric': 0.10712481051035877, 'fraction_numerical': 0.0, 'mean_word_length': 1.5950196592398427, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6494271', 'n_tokens_mistral': 604, 'n_tokens_neox': 579, 'n_words': 164}