<commit_before># -*- coding: utf-8 -*-
import random
import yaml


from address import Address
from name import Name

MALE = 'male'
FEMALE = 'female'
GENDER = (MALE, FEMALE)


def yaml_load(file_path, mode='r'):
    f = open(file_path, mode)
    return yaml.load(f)



class Gimei(object):
    NAMES = yaml_load('./data/names.yml')
    ADDRESSES = yaml_load('./data/addresses.yml')

    def __init__(self, gender=None):
        if gender is None:
            gender = random.choice(GENDER)
        self.gender = gender


    @property
    def name(self):
        return Name(self.gender)

    @property
    def address(self):
        return Address()
<commit_msg>recommend to use a libyaml CLoader<commit_after># -*- coding: utf-8 -*-
import random
import yaml
try:
    from yaml import CLoader as Loader
except ImportError:
    from yaml import Loader


from address import Address
from name import Name

MALE = 'male'
FEMALE = 'female'
GENDER = (MALE, FEMALE)


def yaml_load(file_path, mode='r'):
    try:
        f = open(file_path, mode)
    except IOError:
        raise("Can not open {}".format(file_path))
    return yaml.load(f, Loader=Loader)



class Gimei(object):
    NAMES = yaml_load('./data/names.yml')
    ADDRESSES = yaml_load('./data/addresses.yml')

    def __init__(self, gender=None):
        if gender is None:
            gender = random.choice(GENDER)
        self.gender = gender


    @property
    def name(self):
        return Name(self.gender)

    @property
    def address(self):
        return Address()

{'fraction_non_alphanumeric': 0.11638491547464239, 'fraction_numerical': 0.0013003901170351106, 'mean_word_length': 2.7720588235294117, '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': '2303522', 'n_tokens_mistral': 533, 'n_tokens_neox': 491, 'n_words': 140}