<commit_before>import {isObject} from 'd3-let';
import {viewWarn} from 'd3-view';
import {formatters, parsers} from './formatters';


// Create table columns from schema
export default function (model, schema) {
	if (!schema) return;
    if (!isObject(schema.properties))
        return viewWarn('schema properties should be an object');

    var columns = model.columns;
    let col;
    for (let key in schema.properties) {
        col = schema.properties[key];
        if (isObject(col)) {
            if (!col.name) col.name = key;
            if (!col.label) col.label = col.name;
            if (!col.hidden) col.hidden = false;
            if (!col.$parse) col.$parse = parsers[col.type] || parsers.string;
            if (!col.$html) col.$html = formatters[col.type] || $html;
            columns.push(model.$new(col));
        }
    }
}


function $html (value) {
    return value;
}
<commit_msg>flexible columns<commit_after>import {isObject, isArray} from 'd3-let';
import {viewWarn} from 'd3-view';
import {formatters, parsers} from './formatters';


// Create table columns from schema
export default function (model, schema) {
	if (!schema) return;
    if (isArray(schema))
        schema = {properties: schema};

    if (isObject(schema.properties)) {
        var columns = [];
        for (let key in schema.properties) {
            col = schema.properties[key];
            if (isObject(col)) {
                if (!col.name) col.name = key;
                columns.push(col);
            }
        }
        schema.columns = columns;
    } else {
        schema.columns = schema.properties;
    }

    if (!isArray(schema.columns))
        return viewWarn('schema columns should be an array');

    var columns = model.columns;
    let col;
    model.columns = schema.columns.map((col) => {
        if (!isObject(col)) col = {name: col};
        if (!col.label) col.label = col.name;
        if (!col.hidden) col.hidden = false;
        if (!col.$parse) col.$parse = parsers[col.type] || parsers.string;
        if (!col.$html) col.$html = formatters[col.type] || $html;
        return col;
    });
}


function $html (value) {
    return value;
}

{'fraction_non_alphanumeric': 0.14397784956160592, 'fraction_numerical': 0.0018458698661744347, 'mean_word_length': 2.3769470404984423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4842877', 'n_tokens_mistral': 662, 'n_tokens_neox': 651, 'n_words': 179}