<commit_before>/*
 * Copyright (c) 2016 <NAME>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */


function Element(name, attributes) {
    this._name = name;
    this._attributes = attributes;
    this._children = [];
}

Element.prototype = {

    constructor: Element,

    name: function() {
        return this._name;
    },

    attributes: function() {
        return this._attributes;
    },

    children: function() {
        return this._children;
    },

}


function Text(content) {
    this._content = content;
}

Text.prototype = {

    constructor: Text,

    content: function() {
        return this._content;
    },

}


module.exports.Element = Element;
module.exports.Text = Text;
<commit_msg>Add findElementsByName and content methods to element nodes<commit_after>/*
 * Copyright (c) 2016 <NAME>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */


function Element(name, attributes) {
    this._name = name;
    this._attributes = attributes;
    this._children = [];
}

Element.prototype = {

    constructor: Element,

    name: function() {
        return this._name;
    },

    attributes: function() {
        return this._attributes;
    },

    children: function() {
        return this._children;
    },

    findElementsByName: function(name) {
        var elements = [];
        if (this._name == name) {
            elements.push(this);
        }
        for (var i = 0; i < this._children.length; i++)  {
            var child = this._children[i];
            if (child instanceof Element) {
                elements = elements.concat(child.findElementsByName(name));
            }
        }
        return elements;
    },

    content: function() {
        var content = "";
        for (var i = 0; i < this._children.length; i++)  {
            content += this._children[i].content();
        }
        return content;
    },

}


function Text(content) {
    this._content = content;
}

Text.prototype = {

    constructor: Text,

    content: function() {
        return this._content;
    },

}


module.exports.Element = Element;
module.exports.Text = Text;

{'fraction_non_alphanumeric': 0.12112443158329889, 'fraction_numerical': 0.007441091360066143, 'mean_word_length': 2.2266666666666666, 'pattern_counts': {'":': 0, '<': 7, '<?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': '304024', 'n_tokens_mistral': 724, 'n_tokens_neox': 687, 'n_words': 202}