<commit_before>#!/usr/bin/env python

import os
import scipy.io as sio

PYTHON_DIR = os.path.dirname(os.path.realpath(__file__))
DATA_DIR = os.path.join(os.path.dirname(PYTHON_DIR), 'pmtkdataCopy')


def load_mat(matName):
    """look for the .mat file in pmtk3/pmtkdataCopy/
    currently only support .mat files create by Matlab 5,6,7~7.2,
    """
    try:
        data = sio.loadmat(os.path.join(DATA_DIR, matName))
    except NotImplementedError:
        raise
    except FileNotFoundError:
        raise
    return data<commit_msg>add function gengerate_rst() to genetate chX.rst<commit_after>#!/usr/bin/env python

import os
import scipy.io as sio
import glob

PYTHON_DIR = os.path.dirname(os.path.realpath(__file__))
DATA_DIR = os.path.join(os.path.dirname(PYTHON_DIR), 'pmtkdataCopy')


def load_mat(matName):
    """look for the .mat file in pmtk3/pmtkdataCopy/
    currently only support .mat files create by Matlab 5,6,7~7.2,
    """
    try:
        data = sio.loadmat(os.path.join(DATA_DIR, matName))
    except NotImplementedError:
        raise
    except FileNotFoundError:
        raise
    return data


def generate_rst():
    """generate chX.rst in current working directory"""
    scripts = glob.glob('*.py')
    chapter = os.path.basename(os.getcwd())
    rst_file = chapter + '.rst'
    with open(rst_file, 'w') as f:
        f.write(chapter)
        f.write('\n========================================\n')
        for script in scripts:
            f.write('\n' + script[:-3])
            f.write('\n----------------------------------------\n')
            for img in glob.glob(script[:-3] + '*.png'):
                f.write(".. image::" + img + "\n")
            f.write(".. literalinclude:: " + script + "\n")
{'fraction_non_alphanumeric': 0.17857142857142858, 'fraction_numerical': 0.008064516129032258, 'mean_word_length': 2.5888429752066116, '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': '4690446', 'n_tokens_mistral': 597, 'n_tokens_neox': 578, 'n_words': 134}