<commit_before>var assign = require('lodash.assign');
var isEqual = require('lodash.isequal');
var pick = require('lodash.pick');
var util = require('util');
var uuid = require('node-uuid');

var Part = require('./part');
var templates = require('./templates');
var utilities = require('../utilities');

function SharedStrings(parent) {
    Part.call(this, {spreadsheetml: '__main'}, templates.sharedStrings);
    this.parent = parent;
};
module.exports = SharedStrings;
util.inherits(SharedStrings, Part);

assign(SharedStrings.prototype, {
    add: function (raw) {
        this.count++;
        var str = String(raw || '');
        var s = this.stringMap[str];
        if (s !== undefined ) {
            return s;
        }

        var index = this.strings.length;
        this.strings.push(str);
        return (this.stringMap[str] = index);
    }
});

Object.defineProperties(SharedStrings.prototype, utilities.defineProps({
    constant: {
        filename: 'sharedStrings.xml'
    },
    unsettable: {
        data: {
            getter: function () {
                return pick(this, 'count', 'strings');
            }
        },
        path: {
            getter: function () {
                var path = this.parent ? utilities.dirname(this.parent.path) : '';
                return path ? path + '/' + this.filename : this.filename;
            },
        },
        strings: { ctor: Array },
        stringMap: { ctor: Object }
    }
},
{
    count: {
        get: function () { return ('_count' in this) ? this._count : (this._count = 0); },
        set: function (val) { this._count = val; }
    }
}));<commit_msg>clean up code; make parent a writeOnce<commit_after>var assign = require('lodash.assign');
var isEqual = require('lodash.isequal');
var pick = require('lodash.pick');
var util = require('util');

var Part = require('./part');
var templates = require('./templates');
var utilities = require('../utilities');

function SharedStrings(parent) {
    Part.call(this, {spreadsheetml: '__main'}, templates.sharedStrings);
    this.parent = parent;
};
module.exports = SharedStrings;
util.inherits(SharedStrings, Part);

assign(SharedStrings.prototype, {
    add: function (raw) {
        this.count++;
        var str = String(raw || '');
        var s = this.stringMap[str];
        if (s !== undefined ) {
            return s;
        }

        var index = this.strings.length;
        this.strings.push(str);
        return (this.stringMap[str] = index);
    }
});

Object.defineProperties(SharedStrings.prototype, utilities.defineProps({
    constant: {
        filename: 'sharedStrings.xml',
        type: 'sharedStrings'
    },
    unsettable: {
        data: {
            getter: function () {
                return pick(this, 'count', 'strings');
            }
        },
        path: {
            getter: function () {
                var path = this.parent ? utilities.dirname(this.parent.path) : '';
                return path ? (path + '/' + this.filename) : this.filename;
            },
        },
        strings: { ctor: Array },
        stringMap: { ctor: Object }
    },
    writeOnce: {
        parent: 1
    }
},
{
    count: {
        get: function () { return ('_count' in this) ? this._count : (this._count = 0); },
        set: function (val) { this._count = val; }
    }
}));
{'fraction_non_alphanumeric': 0.15520864605223655, 'fraction_numerical': 0.0009006304413089162, 'mean_word_length': 2.238095238095238, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2981428', 'n_tokens_mistral': 984, 'n_tokens_neox': 957, 'n_words': 218}