<commit_before>(function(Logoot, EventEmitter, window) {

    /**
     * @param @optional {String} agent
     * @param @optional {Logoot} logoot
     */
    function LogootText(agent, logoot) {
        EventEmitter.apply(this);

        this.agent = agent;
        this.logoot = logoot = logoot || new Logoot;
        var self = this;

        logoot.on("ins", function(index, chr) {
            var str = self.str;
            self.str = str.substring(0, index) + chr + str.substring(index, str.length);
        });

        logoot.on("del", function(index) {
            var str = self.str;
            self.str = str.substring(0, index) + str.substring(index + 1, str.length);
        });

        this.str = logoot.reduce(function(str, chr) {
            return str + chr;
        }, "");
    }

    LogootText.prototype = Object.create(EventEmitter.prototype);

    /**
     * Inserts characters `chars` just before `index` in the given string
     * represented by this LogootText. The update implicitly records that `agent`
     * authored the update.
     *
     * Examples:
     * With string 'abc', ins(1, 'x') results in 'axbc'
     * With string 'abc', ins(3, 'z') results in 'abcz'
     * With string ''   , ins(0, 'a') results in 'a'
     *
     * @param {Number} index inside the string to insert the chars
     * @param {String} chars is the sequence of characters to insert
     * @param {String} agent is the author id
     */
    LogootText.prototype.ins = function(index, chars, agent) {
        var logoot = this.logoot;
        var ids = logoot.ids;
        agent || (agent = this.agent);
        for (var i = 0, l = chars.length; i < l; i++) {
            var id = logoot.genId(ids[index + i], ids[index + i + 1], agent);
            var op = logoot.ins(id, chars.charAt(i), agent, index + i);
            this.emit("logoot.op", op);
        }

        var str = this.str;
        this.str = str.substring(0, index) + chars + str.substring(index, str.length);
    };

    /**
     * Deletes the character in the string located at `index`. The update
     * implicitly records that `agent` authored the update.
     *
     * @param {Number} index
     * @param {String} agent
     */<commit_msg>Normalization of line breaks in the input text<commit_after>(function(Logoot, EventEmitter, window) {

    /**
     * @param @optional {String} agent
     * @param @optional {Logoot} logoot
     */
    function LogootText(agent, logoot) {
        EventEmitter.apply(this);

        this.agent = agent;
        this.logoot = logoot = logoot || new Logoot;
        var self = this;

        logoot.on("ins", function(index, chr) {
            var str = self.str;
            self.str = str.substring(0, index) + chr + str.substring(index, str.length);
        });

        logoot.on("del", function(index) {
            var str = self.str;
            self.str = str.substring(0, index) + str.substring(index + 1, str.length);
        });

        this.str = logoot.reduce(function(str, chr) {
            return str + chr;
        }, "");
    }

    LogootText.prototype = Object.create(EventEmitter.prototype);

    /**
     * Inserts characters `chars` just before `index` in the given string
     * represented by this LogootText. The update implicitly records that `agent`
     * authored the update.
     *
     * Examples:
     * With string 'abc', ins(1, 'x') results in 'axbc'
     * With string 'abc', ins(3, 'z') results in 'abcz'
     * With string ''   , ins(0, 'a') results in 'a'
     *
     * @param {Number} index inside the string to insert the chars
     * @param {String} chars is the sequence of characters to insert
     * @param {String} agent is the author id
     */
    LogootText.prototype.ins = function(index, chars, agent) {
        var logoot = this.logoot;
        var ids = logoot.ids;
        agent || (agent = this.agent);
        chars = chars.replace(/[\r\n]{1,2}/g, "\n");
        for (var i = 0, l = chars.length; i < l; i++) {
            var id = logoot.genId(ids[index + i], ids[index + i + 1], agent);
            var op = logoot.ins(id, chars.charAt(i), agent, index + i);
            this.emit("logoot.op", op);
        }

        var str = this.str;
        this.str = str.substring(0, index) + chars + str.substring(index, str.length);
    };

    /**
     * Deletes the character in the string located at `index`. The update
     * implicitly records that `agent` authored the update.
     *
     * @param {Number} index
     * @param {String} agent
     */
{'fraction_non_alphanumeric': 0.13584070796460176, 'fraction_numerical': 0.004424778761061947, 'mean_word_length': 2.1395833333333334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4211001', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1366, 'n_words': 414}