<commit_before>#include <Codegen.h>
#include <Python.h>
#include <stdio.h>

static PyObject * echoprint_codegen(PyObject *self, PyObject *args) {
    PyObject *py_samples;
    int start_offset = 0;
    PyObject *item;
    float *samples;
    uint num_samples;
    uint i;
    Codegen *pCodegen;
    PyObject *result;
    
    if (!PyArg_ParseTuple(args, "O|i", &py_samples, &start_offset)) {
        return NULL;
    }
    if (!PySequence_Check(py_samples)) {
        PyErr_SetString(PyExc_TypeError, "expected sequence");
        return NULL;
    }
    num_samples = PySequence_Size(py_samples);
    samples = new float[num_samples];
    for (i = 0; i < num_samples; i++) {
        item = PySequence_GetItem(py_samples, i);
        if (!PyFloat_Check(item)) {
            delete[] samples;
            PyErr_SetString(PyExc_TypeError, "expected sequence of floats");
            return NULL;
        }
        samples[i] = (float)PyFloat_AsDouble(item);
        Py_DECREF(item);
    }
    pCodegen = new Codegen(samples, num_samples, start_offset);
    result = Py_BuildValue("{s:s,s:s}",
        "code", pCodegen->getCodeString().c_str(),
        "version", pCodegen->getVersion()
    );
    delete pCodegen;
    delete[] samples;
    return result;
}

static PyMethodDef echoprint_methods[] = {
    {"codegen", echoprint_codegen, METH_VARARGS,
     "Generates a echoprint code for a list of floating point PCM data sampled at 11025 Hz and mono. Optionally takes a second integer argument to hint the server on where the sample is taken from in the original file if known."},
    {NULL, NULL, 0, NULL}
};

PyMODINIT_FUNC
initechoprint(void)
{
    (void) Py_InitModule("echoprint", echoprint_methods);
}


<commit_msg>Making sure the version number is passed over correctly, as a float<commit_after>#include <Codegen.h>
#include <Python.h>
#include <stdio.h>

static PyObject * echoprint_codegen(PyObject *self, PyObject *args) {
    PyObject *py_samples;
    int start_offset = 0;
    PyObject *item;
    float *samples;
    uint num_samples;
    uint i;
    Codegen *pCodegen;
    PyObject *result;
    
    if (!PyArg_ParseTuple(args, "O|i", &py_samples, &start_offset)) {
        return NULL;
    }
    if (!PySequence_Check(py_samples)) {
        PyErr_SetString(PyExc_TypeError, "expected sequence");
        return NULL;
    }
    num_samples = PySequence_Size(py_samples);
    samples = new float[num_samples];

    for (i = 0; i < num_samples; i++) {
        item = PySequence_GetItem(py_samples, i);
        if (!PyFloat_Check(item)) {
            delete[] samples;
            PyErr_SetString(PyExc_TypeError, "expected sequence of floats");
            return NULL;
        }
        samples[i] = (float)PyFloat_AsDouble(item);
        Py_DECREF(item);
    }
    pCodegen = new Codegen(samples, num_samples, start_offset);
    result = Py_BuildValue("{s:s,s:f}",
        "code", pCodegen->getCodeString().c_str(),
        "version", pCodegen->getVersion()
    );
    delete pCodegen;
    delete[] samples;
    return result;
}

static PyMethodDef echoprint_methods[] = {
    {"codegen", echoprint_codegen, METH_VARARGS,
     "Generates a echoprint code for a list of floating point PCM data sampled at 11025 Hz and mono. Optionally takes a second integer argument to hint the server on where the sample is taken from in the original file if known."},
    {NULL, NULL, 0, NULL}
};

PyMODINIT_FUNC
initechoprint(void)
{
    (void) Py_InitModule("echoprint", echoprint_methods);
}



{'fraction_non_alphanumeric': 0.11136558831949614, 'fraction_numerical': 0.004580589750930432, 'mean_word_length': 3.204572803850782, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '1491004', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1147, 'n_words': 299}