<commit_before>///<reference path="../models/content_block.ts"/>
///<reference path="../models/ajax_content_blocks.ts"/>
///<reference path="../models/ajax_content_block.ts"/>

class DataConverter {
  convertJson(originalContentBlock:ContentBlock, cb:AjaxContentBlock):ContentBlock {
    return new ContentBlock(cb.content, cb.content_path, cb.api_key, originalContentBlock.apiHost,
      cb.created_at, cb.updated_at);
  }

  extractObjectFromHash(originalContentBlock:ContentBlock, rawAjaxArray:AjaxContentBlocksHash):ContentBlock {
    const rawData = rawAjaxArray[originalContentBlock.contentPath];
    return rawData ? this.convertJson(originalContentBlock, rawData) : originalContentBlock;
  }

  convertJsonObjectToHash(rawJsonObject:AjaxContentBlocks):AjaxContentBlocksHash {
    const hash:AjaxContentBlocksHash = {};

    return rawJsonObject.content_blocks.reduce(function (map, jsonContentBlock) {
      map[jsonContentBlock.content_path] = jsonContentBlock;
      return map;
    }, hash);
  }
}<commit_msg>refactoring<commit_after>///<reference path="../models/content_block.ts"/>
///<reference path="../models/ajax_content_blocks.ts"/>
///<reference path="../models/ajax_content_block.ts"/>

class DataConverter {
  convertJson(originalContentBlock:ContentBlock, cb:AjaxContentBlock):ContentBlock {
    return new ContentBlock(cb.content, cb.content_path, cb.api_key, originalContentBlock.apiHost,
      cb.created_at, cb.updated_at);
  }

  extractObjectFromHash(originalContentBlock:ContentBlock, rawAjaxArray:AjaxContentBlocksHash):ContentBlock {
    const rawData = rawAjaxArray[originalContentBlock.contentPath];
    return rawData ? this.convertJson(originalContentBlock, rawData) : originalContentBlock;
  }

  convertJsonObjectToHash(rawJsonObject:AjaxContentBlocks):AjaxContentBlocksHash {
    const hash:AjaxContentBlocksHash = {};

    return rawJsonObject.content_blocks.reduce((map, jsonContentBlock) => {
      map[jsonContentBlock.content_path] = jsonContentBlock;
      return map;
    }, hash);
  }
}
{'fraction_non_alphanumeric': 0.11614173228346457, 'fraction_numerical': 0.0, 'mean_word_length': 5.70957095709571, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, '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': '1774009', 'n_tokens_mistral': 586, 'n_tokens_neox': 578, 'n_words': 79}