<commit_before>import { HelSchema } from './schema';

export class HelDictionary<ValueSchema extends HelSchema<any>> implements HelSchema<{[key:string]:ValueSchema['identity']}> {
    public readonly identity:{[key:string]:ValueSchema['identity']};
    
    public readonly helType = 'dictionary';
    public readonly helData:ValueSchema;

    constructor (id:{[key:string]:ValueSchema['identity']}, valueSchema:ValueSchema) {
        this.identity = id;
        this.helData = valueSchema;
    }

    alloc () { return {}; }

    free (x:{[key:string]:ValueSchema['identity']}) {}

    clone (x:{[key:string]:ValueSchema['identity']}):{[key:string]:ValueSchema['identity']} {
        const result:{[key:string]:ValueSchema['identity']} = {};
        const props = Object.keys(x);
        for (let i = 0; i < props.length; ++i) {
            result[props[i]] = x[props[i]];
        }
        return result;
    }

    diff (base:{[key:string]:ValueSchema['identity']}, target:{[key:string]:ValueSchema['identity']}) {
        const remove:string[] = [];
        const patch:{ [prop:string]:any } = {};
    
        Object.keys(base).forEach((prop) => {
            if (prop in target) {
                const delta = this.helData.diff(base[prop], target[prop]);
                if (delta !== undefined) {
                    patch[prop] = delta;
                }
            } else {
                remove.push(prop);
            }
        });
    
        Object.keys(target).forEach((prop) => {<commit_msg>fix bug in dictionary clone<commit_after>import { HelSchema } from './schema';

export class HelDictionary<ValueSchema extends HelSchema<any>> implements HelSchema<{[key:string]:ValueSchema['identity']}> {
    public readonly identity:{[key:string]:ValueSchema['identity']};
    
    public readonly helType = 'dictionary';
    public readonly helData:ValueSchema;

    constructor (id:{[key:string]:ValueSchema['identity']}, valueSchema:ValueSchema) {
        this.identity = id;
        this.helData = valueSchema;
    }

    alloc () { return {}; }

    free (x:{[key:string]:ValueSchema['identity']}) {}

    clone (x:{[key:string]:ValueSchema['identity']}):{[key:string]:ValueSchema['identity']} {
        const result:{[key:string]:ValueSchema['identity']} = {};
        const props = Object.keys(x);
        const schema = this.helData;
        for (let i = 0; i < props.length; ++i) {
            result[props[i]] = schema.clone(x[props[i]]);
        }
        return result;
    }

    diff (base:{[key:string]:ValueSchema['identity']}, target:{[key:string]:ValueSchema['identity']}) {
        const remove:string[] = [];
        const patch:{ [prop:string]:any } = {};
    
        Object.keys(base).forEach((prop) => {
            if (prop in target) {
                const delta = this.helData.diff(base[prop], target[prop]);
                if (delta !== undefined) {
                    patch[prop] = delta;
                }
            } else {
                remove.push(prop);
            }
        });
    
        Object.keys(target).forEach((prop) => {
{'fraction_non_alphanumeric': 0.1685575364667747, 'fraction_numerical': 0.0006482982171799027, 'mean_word_length': 2.6009334889148192, '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': '4412511', 'n_tokens_mistral': 883, 'n_tokens_neox': 853, 'n_words': 157}