<commit_before>var registerNamespaces = {
    html: "http://www.w3.org/1999/xhtml",
    mathml: "http://www.w3.org/1998/Math/MathML",
    svg: "http://www.w3.org/2000/svg",
    xlink: "http://www.w3.org/1999/xlink",
    xml: "http://www.w3.org/XML/1998/namespace",
    xsl: "http://www.w3.org/1999/XSL/Transform",
    xmlns: "http://www.w3.org/2000/xmlns/",
    soap: "http://schemas.xmlsoap.org/wsdl/soap/",
    wsdl: "http://schemas.xmlsoap.org/wsdl/"
}

/**
 * Bind a document and return the eleminate function.  Optionally, register
 * namespace prefixes.
 * @param {HTMLDocument} document
 * @param {object} [namepsaces]
 * @return {function}
 */
function eleminate(document, namespaces) {
    namespaces = namespaces || {};
    for (var prefix in registerNamespaces) if (!(prefix in namespaces))
        namespaces[prefix] = registerNamespaces[prefix];

    /**
     * Read a name or QName and return an object containing the namespace URI,
     * local name, and prefix.
     * @param {string} name
     * @return {{ns:string, prefix:string, local:string}}
     */
    function readQName(name) {
        var pos = name.indexOf(":");
        if (pos < 0) return {ns: null, prefix: null, local: name};
        else return {
            ns: namespaces[name.substr(0, pos)],
            prefix: name.substr(0, pos),
            local: name.substr(pos + 1)
        };
    }

    /**
     * Create a new element.  If text and children are provided, the text
     * will be used as a delimiter between the child elements.
     * @param {string} name
     * @param {object} [attrs]
     * @param {array} [children]
     * @param {string} [text]
     * @return {HTMLElement}
     */
    return function(name, attrs, children, text) {
        // process optional args
        switch (arguments.length) {
            case 2:
                if (attrs instanceof Array)
                    children = attrs, attrs = {};
                else if (typeof attrs === "string")
                    text = attrs, attrs = {};
            case 3:
                if (attrs instanceof Array)
                    text = children, children = attrs, attrs = {};
                else if (typeof children === "string")
                    text = children, children = [];
        }
        
        // fallbacks for missing args
        attrs = attrs || {};
        children = children || [];
        text = text || "";

        var el, qname,
            childAdded = false;

        // create the new element
        qname = readQName(name);
        el = qname.ns
            ? document.createElementNS(qname.ns, name)
            : document.createElement(name);

        // set attributes
        for (var attr in attrs) {
            qname = readQName(attr);
            qname[0]
                ? el.setAttributeNS(qname[0], qname[1], attrs[attr])
                : el.setAttribute(attr, attrs[attr]);
        }
        
        // append children, with text between
        children.forEach(function(child) {
            // add intermediary text nodes between children
            if (childAdded && text)
                el.appendChild(document.createTextNode(text));
            
            // add the child and set flag so we know to add intermediary text<commit_msg>style tweak<commit_after>var registerNamespaces = {
    html: "http://www.w3.org/1999/xhtml",
    mathml: "http://www.w3.org/1998/Math/MathML",
    svg: "http://www.w3.org/2000/svg",
    xlink: "http://www.w3.org/1999/xlink",
    xml: "http://www.w3.org/XML/1998/namespace",
    xsl: "http://www.w3.org/1999/XSL/Transform",
    xmlns: "http://www.w3.org/2000/xmlns/",
    soap: "http://schemas.xmlsoap.org/wsdl/soap/",
    wsdl: "http://schemas.xmlsoap.org/wsdl/"
}

/**
 * Bind a document and return the eleminate function.  Optionally, register
 * namespace prefixes.
 * @param {HTMLDocument} document
 * @param {object} [namepsaces]
 * @return {function}
 */
function eleminate(document, namespaces) {
    namespaces = namespaces || {};
    for (var prefix in registerNamespaces) if (!(prefix in namespaces))
        namespaces[prefix] = registerNamespaces[prefix];

    /**
     * Read a name or QName and return an object containing the namespace URI,
     * local name, and prefix.
     * @param {string} name
     * @return {{ns:string, prefix:string, local:string}}
     */
    function readQName(name) {
        var pos = name.indexOf(":");
        if (pos < 0) return {ns: null, prefix: null, local: name};
        else return {
            ns: namespaces[name.substr(0, pos)],
            prefix: name.substr(0, pos),
            local: name.substr(pos + 1)
        };
    }

    /**
     * Create a new element.  If text and children are provided, the text
     * will be used as a delimiter between the child elements.
     * @param {string} name
     * @param {object} [attrs]
     * @param {array} [children]
     * @param {string} [text]
     * @return {HTMLElement}
     */
    return function(name, attrs, children, text) {
        // process optional args
        switch (arguments.length) {
            case 2:
                if (attrs instanceof Array)
                    children = attrs, attrs = {};
                else if (typeof attrs === "string")
                    text = attrs, attrs = {};
            case 3:
                if (attrs instanceof Array)
                    text = children, children = attrs, attrs = {};
                else if (typeof children === "string")
                    text = children, children = [];
        }
        
        // fallbacks for missing args
        attrs = attrs || {};
        children = children || [];
        text = text || "";

        var el, qname,
            childAdded = false;

        // create the new element
        qname = readQName(name);
        el = qname.ns
            ? document.createElementNS(qname.ns, name)
            : document.createElement(name);

        // set attributes
        for (var attr in attrs) {
            qname = readQName(attr);
            if(qname.ns) el.setAttributeNS(qname.ns, qname.local, attrs[attr])
            else el.setAttribute(attr, attrs[attr]);
        }
        
        // append children, with text between
        children.forEach(function(child) {
            // add intermediary text nodes between children
            if (childAdded && text)
                el.appendChild(document.createTextNode(text));
            
            // add the child and set flag so we know to add intermediary text
{'fraction_non_alphanumeric': 0.12854064039408866, 'fraction_numerical': 0.013084975369458128, 'mean_word_length': 1.9004464285714286, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 14, 'xml': 10}, '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': '4898166', 'n_tokens_mistral': 1924, 'n_tokens_neox': 1850, 'n_words': 517}