<commit_before>// $dd.model
//		teh bones of any awesome web app. replaces the $dd.object paradigm
//		to reduce scope bugs and allow easier state migration through simple
//		objects.
;(function(factory){
	if(typeof define === 'function' && define.amd) {
		define(['../dd','../polyfill/keys'], factory);
	} else if (typeof exports === 'object') {
		module.exports = factory(require('../dd'));
	} else {
		factory($dd);
	}
})(function(lib){
	// stuff to exclude from the serialization
	var blacklist = /^(_.*|def|on_fill|on_out|fill|out|extend|attach|map|type|errors|validate)$/;

	// lets only add clean data to our models
	function _cleanNumbers(obj){
		var type = lib.type(obj),
			ni;

		if(/^(b.*|nu.*|f.*)$/.test(type)){
			return obj;
		}

		if(type === 'string'){
			if(!obj || obj === 'null'){
				obj = null;
			} else if(!isNaN(parseFloat(obj)) && isFinite(parseFloat(obj))){
				return parseFloat(obj);
			}

			return obj;
		}

		if(type === 'array'){
			for(ni = 0; ni < obj.length; ni++){
				obj[ni] = _cleanNumbers(obj[ni]);
			}
		}

		if(type === 'object'){
			for(ni in obj){
				obj[ni] = _cleanNumbers(obj[ni]);
			}
		}

		return obj;
	}

	// this bit of code, when called, returns a constructor for a model,
	// that loads all of the functions in ret.fns at the time of calling
	// this function
	var ret = function(){
		return function(def){
			var self = {},
				ni;

			for(ni in ret.fns){
				self[ni] = (function(fn){
					return function(){
						var args = Array.prototype.slice.call(arguments);
						args.unshift(self);
						return fn.apply(self,args);
					};
				})(ret.fns[ni]);
			}

			return self.extend(def);
		}
	};

	ret.fns = {
		fill: function(self,data){
			// does the heavy lifting for importing an object into a model

			data = data || {};

			var _pre = self._pre || [],
				def = self.def || {},
				ni, na, no, a;

			for(ni = 0; ni < _pre.length; ni++){
				if(!_pre[ni].after){
					_pre[ni].fun(data);
				}
			}

			for(ni in def){
				na = ni;
				for(no = 0; no < def[ni].external.length; no++){
					if(!data.hasOwnProperty(def[ni].external[no])){
						continue;
					}
					na = def[ni].external[no];
					break;
				}
				//catch when ni=na and !data[na]
				if(!data.hasOwnProperty(na)){
					continue;
				}

				a = null;
				if(!def[ni].type){
					self[ni] = _cleanNumbers(data[na]);
					continue;
				}<commit_msg>this was messing with addresses<commit_after>// $dd.model
//		teh bones of any awesome web app. replaces the $dd.object paradigm
//		to reduce scope bugs and allow easier state migration through simple
//		objects.
;(function(factory){
	if(typeof define === 'function' && define.amd) {
		define(['../dd','../polyfill/keys'], factory);
	} else if (typeof exports === 'object') {
		module.exports = factory(require('../dd'));
	} else {
		factory($dd);
	}
})(function(lib){
	// stuff to exclude from the serialization
	var blacklist = /^(_.*|def|on_fill|on_out|fill|out|extend|attach|map|type|errors|validate)$/;

	// this bit of code, when called, returns a constructor for a model,
	// that loads all of the functions in ret.fns at the time of calling
	// this function
	var ret = function(){
		return function(def){
			var self = {},
				ni;

			for(ni in ret.fns){
				self[ni] = (function(fn){
					return function(){
						var args = Array.prototype.slice.call(arguments);
						args.unshift(self);
						return fn.apply(self,args);
					};
				})(ret.fns[ni]);
			}

			return self.extend(def);
		}
	};

	ret.fns = {
		fill: function(self,data){
			// does the heavy lifting for importing an object into a model

			data = data || {};

			var _pre = self._pre || [],
				def = self.def || {},
				ni, na, no, a;

			for(ni = 0; ni < _pre.length; ni++){
				if(!_pre[ni].after){
					_pre[ni].fun(data);
				}
			}

			for(ni in def){
				na = ni;
				for(no = 0; no < def[ni].external.length; no++){
					if(!data.hasOwnProperty(def[ni].external[no])){
						continue;
					}
					na = def[ni].external[no];
					break;
				}
				//catch when ni=na and !data[na]
				if(!data.hasOwnProperty(na)){
					continue;
				}

				a = null;
				if(!def[ni].type){
					self[ni] = data[na];
					continue;
				}
{'fraction_non_alphanumeric': 0.1785202863961814, 'fraction_numerical': 0.0011933174224343676, 'mean_word_length': 2.741964285714286, 'pattern_counts': {'":': 0, '<': 8, '<?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': '7208052', 'n_tokens_mistral': 1807, 'n_tokens_neox': 1450, 'n_words': 377}