<commit_before>import isPlainObject from 'lodash/isPlainObject';
import mapValues from 'lodash/mapValues';
import get from 'lodash/get';
import set from 'lodash/set';
import cloneDeep from 'lodash/cloneDeep';
import { toNumber } from '../util/common';
import CommonUtils from '../util/common';

class dmetTable {
    constructor(array = [], id) {
        this.#id = id;
        this.from(array);
    }

    _id = undefined;
    __isUpdate = false;
    #id = '';
    #key = CommonUtils.generateId();
    #object = {};
    #array = [];
    #origin = [];
    #fields = [];
    #info = {};
    #maxRow = 100;
    #maxCol = 100;
    #variableType = 'table';
    #keyDelimter = '_';

    get fields() {
        return this.#fields;
    }

    get value() {
        return this.#object;
    }

    get array() {
        return this.#array;
    }

    get isDmet() {
        return true;
    }

    get variableType() {
        return this.#variableType;
    }

    get origin() {
        return this.#origin;
    }

    setLabel(index, name) {
        this.#fields[index] = name;
    }

    from(data) {
        const { list = [], data: array = [], value, _id, id = this.#id, fields, ...info } = data;
        this.#object = {};
        this.#array = [];
        this.#origin = [];
        if (Array.isArray(array)) {
            array.forEach((row = []) => {
                if (Array.isArray(row)) {
                    const key = CommonUtils.generateId();
                    const value = row.map(toNumber);
                    this.#array.push({ key, value });
                    this.#object[key] = value;
                    this.#origin.push(cloneDeep(value));
                } else if (typeof row === 'object' && row.key) {
                    const newRow = {
                        key: row.key,
                        value: row.value.map(toNumber)
                    };
                    this.#array.push(newRow);
                    this.#object[row.key] = newRow.value;
                    this.#origin.push(cloneDeep(newRow.value));
                }
            });
        }
        this._id = _id;
        this.#id = id;
        this.#fields = fields;
        this.#info = info;
    }

    toJSON() {
        return {
            _id: this._id || undefined,
            id: this.#id,
            key: this.#key,
            data: this.#array,
            origin: this.#origin,
            fields: this.#fields,<commit_msg>dmet 생성 시 빈값 0으로 채우고 field 길이에 맞춰서 row생성하도록 변경.<commit_after>import isPlainObject from 'lodash/isPlainObject';
import mapValues from 'lodash/mapValues';
import get from 'lodash/get';
import set from 'lodash/set';
import cloneDeep from 'lodash/cloneDeep';
import { toNumber } from '../util/common';
import CommonUtils from '../util/common';

class dmetTable {
    constructor(array = [], id) {
        this.#id = id;
        this.from(array);
    }

    _id = undefined;
    __isUpdate = false;
    #id = '';
    #key = CommonUtils.generateId();
    #object = {};
    #array = [];
    #origin = [];
    #fields = [];
    #info = {};
    #maxRow = 100;
    #maxCol = 100;
    #variableType = 'table';
    #keyDelimter = '_';

    get fields() {
        return this.#fields;
    }

    get value() {
        return this.#object;
    }

    get array() {
        return this.#array;
    }

    get isDmet() {
        return true;
    }

    get variableType() {
        return this.#variableType;
    }

    get origin() {
        return this.#origin;
    }

    setLabel(index, name) {
        this.#fields[index] = name;
    }

    #fillArray(array, length) {
        const start = array.length;
        array.length = length;
        array.fill(0, start, length);
    }

    from(data) {
        const { list = [], data: array = [], value, _id, id = this.#id, fields, ...info } = data;
        this.#object = {};
        this.#array = [];
        this.#origin = [];
        if (Array.isArray(array)) {
            array.forEach((row = []) => {
                if (Array.isArray(row)) {
                    const key = CommonUtils.generateId();
                    const value = row.map(toNumber);
                    this.#fillArray(value, fields.length);
                    this.#array.push({ key, value });
                    this.#object[key] = value;
                    this.#origin.push(cloneDeep(value));
                } else if (typeof row === 'object' && row.key) {
                    const newRow = {
                        key: row.key,
                        value: row.value.map(toNumber)
                    };
                    this.#array.push(newRow);
                    this.#object[row.key] = newRow.value;
                    this.#origin.push(cloneDeep(newRow.value));
                }
            });
        }
        this._id = _id;
        this.#id = id;
        this.#fields = fields;
        this.#info = info;
    }

    toJSON() {
        return {
            _id: this._id || undefined,
            id: this.#id,
            key: this.#key,
            data: this.#array,
            origin: this.#origin,
            fields: this.#fields,
{'fraction_non_alphanumeric': 0.14528412419449327, 'fraction_numerical': 0.0027338410466705722, 'mean_word_length': 1.47678916827853, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3912467', 'n_tokens_mistral': 1611, 'n_tokens_neox': 1550, 'n_words': 327}