<commit_before>﻿/*
	JsonML_DOM.js

	Created: 2007-02-15-2235

	Released under an open-source license:
	http://jsonml.org/License.htm
*/

if ("undefined" === typeof window.JsonML) {
	window.JsonML = {};
}
/*JsonML*/ JsonML.parseDOM = function(/*DOM*/ elem) {
	if (!elem) {
		return null;
	}

	var i;
	switch (elem.nodeType) {
		case 1: // element
			var jml = [elem.tagName];
			var a = elem.attributes;
			var att = {};
			var hasAttrib = false;
			for (i=0; i<a.length; i++) {
				if (a[i].specified) {
					if (a[i].name === "style") {
						att["style"] = elem.style.cssText ? elem.style.cssText : a[i].value;
					} else if ("string" === typeof a[i].value) {
						att[a[i].name] = a[i].value;
					}
					hasAttrib = true;
				}
			}
			if (hasAttrib) {
				jml.push(att);
			}
			if (elem.hasChildNodes()) {
				for (i=0; i<elem.childNodes.length; i++) {
					var c = elem.childNodes[i];
					c = JsonML.parseDOM(c);
					if (c) {
						jml.push(c);
					}
				}
			}
			return jml;
		case 3: // text node
			return elem.nodeValue;
		default: // comments, etc.
			return null;
	}
};<commit_msg>- adding document fragment support<commit_after>﻿/*
	JsonML_DOM.js

	Created: 2007-02-15-2235
	Modified: 2008-08-31-1813

	Released under an open-source license:
	http://jsonml.org/License.htm
*/

if ("undefined" === typeof window.JsonML) {
	window.JsonML = {};
}
/*JsonML*/ JsonML.parseDOM = function(/*DOM*/ elem) {
	if (!elem) {
		return null;
	}

	var i;
	switch (elem.nodeType) {
		case 1: // element
		case 11: // documentFragment
			var jml = [elem.tagName||""];
			var a = elem.attributes;
			var att = {};
			var hasAttrib = false;
			for (i=0; i<a.length; i++) {
				if (a[i].specified) {
					if (a[i].name === "style") {
						att["style"] = elem.style.cssText ? elem.style.cssText : a[i].value;
					} else if ("string" === typeof a[i].value) {
						att[a[i].name] = a[i].value;
					}
					hasAttrib = true;
				}
			}
			if (hasAttrib) {
				jml.push(att);
			}
			if (elem.hasChildNodes()) {
				for (i=0; i<elem.childNodes.length; i++) {
					var c = elem.childNodes[i];
					c = JsonML.parseDOM(c);
					if (c) {
						jml.push(c);
					}
				}
			}
			return jml;
		case 3: // text node
			return elem.nodeValue;
		default: // comments, etc.
			return null;
	}
};

/*JsonML*/ JsonML.parseHTML = function(/*string*/ html) {
	var elem = document.createElement("div");
	elem.innerHTML = html;
	var jml = JsonML.parseDOM(elem);
	if (jml.length === 2) {
		return jml[1];
	}

	// make wrapper a document fragment
	jml[0] = "";
	return jml;
};
{'fraction_non_alphanumeric': 0.18544600938967137, 'fraction_numerical': 0.01917057902973396, 'mean_word_length': 2.5027397260273974, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6877991', 'n_tokens_mistral': 1216, 'n_tokens_neox': 992, 'n_words': 220}