<commit_before>function createTypeDefinition(obj) {
  var tempObj = {},
    tempTypeObj = {},
    tempResultObj = {},
    tempTypeArr = [],
    tempResultArr = [],
    tempTypeArrLen = 0,
    len = 0,
    rest = 1,
    mergedObject = {},
    returnObj = {typeDef:{}, result: {}};

  if (_.isArray(obj)) {
    len = obj.length;

    for (var i = 0; i < len; i++) {
      if (obj[i].type == 'map' || obj[i].type == 'list') {
        tempObj = createTypeDefinition(obj[i].value);
        tempTypeArr[i] = tempObj.typeDef;
        tempResultArr[i] = tempObj.result;
      } else {
        tempTypeArr.push(obj[i].type);
        tempResultArr.push(obj[i].value);
      }

      if(i > 0) {
        //If type is map or list need to do deep compare
        //to ascertain whether equal or not
        //determine if the array has same types
        //then only show the type upto that index
        if (obj[i].type !== obj[i - 1].type) {
            rest = i + 1;
        }
      }
    }

    if(rest > 1 && _.isObject(tempTypeArr[rest])){
      //merge remaining objects
      tempTypeArrLen = tempTypeArr.length;
      mergedObject = tempTypeArr[rest - 1];

      for(var j = rest;j < tempTypeArrLen; j++){
        mergedObject = merge(mergedObject, tempTypeArr[j]);
      }

      tempResultArr[rest - 1] = mergedObject;
    }

    tempTypeArr.length = rest;
    returnObj.typeDef = tempTypeArr;
    returnObj.result = tempResultArr;
  } else {
    _.forOwn(obj, function(v, k) {
      if (v.type == 'map' || v.type == 'list'){
        tempObj = createTypeDefinition(v.value);
        tempTypeObj[k] = tempObj.typeDef;
        tempResultObj[k] = tempObj.result;
      } else {
        tempTypeObj[k] = v.type;
        tempResultObj[k] = v.value;
      }
    });

    returnObj.typeDef = tempTypeObj;
    returnObj.result = tempResultObj;
  }

  return returnObj;
}<commit_msg>Fix export of createTypeDefinition. Fix stuffs in function.<commit_after>var _ = require('lodash');

module.exports = function createTypeDefinition(obj) {
  var tempObject = {},
    tempTypeObj = {},
    tempResultObj = {},
    tempTypeArray = [],
    tempResultArr = [],
    tempTypeArrLen = 0,
    rest = 1,
    mergedObject = {},
    returnObj = {
      typeDefinition: {},
      result: {}
    };

  if (_.isArray(obj)) {

    _.each(obj, function(property, i) {
      if (property.type == 'map' || property.type == 'list') {
        tempObject = createTypeDefinition(property.value);
        tempTypeArray[i] = tempObject.typeDefinition;
        tempResultArr[i] = tempObject.result;
      } else {
        tempTypeArray.push(property.type);
        tempResultArr.push(property.value);
      }

      if (i > 0) {
        //If type is map or list need to do deep compare
        //to ascertain whether equal or not
        //determine if the array has same types
        //then only show the type upto that index
        if (property.type !== obj[i - 1].type) {
            rest = i + 1;
        }
      }
    });

    if(rest > 1 && _.isObject(tempTypeArray[rest])){
      //merge remaining objects
      tempTypeArrLen = tempTypeArray.length;
      mergedObject = tempTypeArray[rest - 1];

      for(var j = rest; j < tempTypeArrLen; j++){
        mergedObject = _.extend(mergedObject, tempTypeArray[j]);
      }

      tempResultArr[rest - 1] = mergedObject;
    }

    tempTypeArray.length = rest;
    returnObj.typeDefinition = tempTypeArray;
    returnObj.result = tempResultArr;
  } else {
    _.forOwn(obj, function(property, k) {
      if (property.type == 'map' || property.type == 'list') {
        tempObject = createTypeDefinition(property.value);
        tempTypeObj[k] = tempObject.typeDefinition;
        tempResultObj[k] = tempObject.result;
      } else {
        tempTypeObj[k] = property.type;
        tempResultObj[k] = property.value;
      }
    });

    returnObj.typeDefinition = tempTypeObj;
    returnObj.result = tempResultObj;
  }

  return returnObj;
};
{'fraction_non_alphanumeric': 0.13308080808080808, 'fraction_numerical': 0.004545454545454545, 'mean_word_length': 2.298084929225645, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, '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': '3800526', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1230, 'n_words': 280}