<commit_before>import icdJson from 'icd-10-cm-parser';
import { Map } from 'immutable';
import _ from 'lodash';

class Core
{

  /**
   * Constructor
   * @return void
   */
  constructor() {
    this.defaultICD = this._initializeICD();
    this.defaultCondition = {
      pedestrian: undefined,
      pedestrianDetail: undefined,
      perpetrator: undefined,
      accitdentType: undefined,
      medical: undefined,
    }
    this.conditions = _.assign({}, this.defaultCondition);
    this._load();
  }

  /**
   * Initialize ICD-10 property
   * @return Map
   */
  _initializeICD() {
    const icdKey = [
      'data',
      'pedestrian',
      'pedestrianDetail',
      'perpetrator',
      'accitdentType',
      'medical',
    ];
    let icd = Map();
    _.each(icdKey, (value) => {
      icd = icd.set(value, Map());
    })
    return icd;
  }

  /**
   * Transform ICD-10-cm json to immutable-js Map
   * @return void
   */
  _load() {
    _.each(icdJson, (icds, key) => {
      let data = Map();
      switch (key) {
        case 'data':
          _.each(icds, (value) => {
            data = data.set(value.code, value);
          });
          break;
        case 'pedestrianDetail':
        case 'perpetrator':
        case 'accitdentType':
        case 'medical':
        case 'pedestrian':
          _.each(icds, (value, key) => {
            let tmp = {name: key === 'undefined' ? '' : key, enabled: true};
            data = data.set(value, tmp);
          });
          break;
      }
      this.defaultICD = this.defaultICD.set(key, data);
    });
    this._clone();
    this.menus = this.defaultICD.filterNot((value, key) => key === 'data');
  }

  /**
   * Clone default ICD to ICD property
   * @return void
   */
  _clone() {
    this.ICD = this.defaultICD.get('data');
  }

  /**
   * Filter ICD-10 data
   * @param  string key
   * @param  integer value
   * @return Map
   */
  _filter(key, value) {
    this.conditions[key] = value;
    let icds = this.defaultICD.get('data');
    _.each(this.conditions, (condition) => {
      if (condition !== undefined) {
        icds = icds.filter(icd => parseInt(icd[key]) === value);
      }
    });
    return icds;
  }



  /**
   * Concat all data
   * @param  object data
   * @return object
   */
  _concatAll(data) {
    return {
      code: data.code,
      pedestrian: this.defaultICD.get('pedestrian').get(data.pedestrian).name,
      pedestrianDetail: this.defaultICD.get('pedestrianDetail').get(data.pedestrianDetail).name,
      perpetrator: this.defaultICD.get('perpetrator').get(data.perpetrator).name,
      accitdentType: this.defaultICD.get('accitdentType').get(data.accitdentType).name,
      medical: this.defaultICD.get('medical').get(data.medical).name,
    };
  }

  /**
   * Set pedestrian condition
   * @param integer value
   */
  setPedestrian(value) {
    this.ICD = this._filter('pedestrian', value);
    return this;
  }

  /**
   * Set pedestrian detail condition
   * @param integer value
   */
  setPedestrianDetail(value) {
    this.ICD = this._filter('pedestrianDetail', value);
    return this;
  }

  /**
   * Set perpetrator condition
   * @param integer value
   */
  setPerpetrator(value) {
    this.ICD = this._filter('perpetrator', value);
    return this;
  }

  /**
   * Set accitdent type condition
   * @param integer value
   */
  setAccitdentType(value) {
    this.ICD = this._filter('accitdentType', value);
    return this;<commit_msg>Fix typo<commit_after>import icdJson from 'icd-10-cm-parser';
import { Map } from 'immutable';
import _ from 'lodash';

class Core
{

  /**
   * Constructor
   * @return void
   */
  constructor() {
    this.defaultICD = this._initializeICD();
    this.defaultCondition = {
      pedestrian: undefined,
      pedestrianDetail: undefined,
      perpetrator: undefined,
      accidentType: undefined,
      medical: undefined,
    }
    this.conditions = _.assign({}, this.defaultCondition);
    this._load();
  }

  /**
   * Initialize ICD-10 property
   * @return Map
   */
  _initializeICD() {
    const icdKey = [
      'data',
      'pedestrian',
      'pedestrianDetail',
      'perpetrator',
      'accidentType',
      'medical',
    ];
    let icd = Map();
    _.each(icdKey, (value) => {
      icd = icd.set(value, Map());
    })
    return icd;
  }

  /**
   * Transform ICD-10-cm json to immutable-js Map
   * @return void
   */
  _load() {
    _.each(icdJson, (icds, key) => {
      let data = Map();
      switch (key) {
        case 'data':
          _.each(icds, (value) => {
            data = data.set(value.code, value);
          });
          break;
        case 'pedestrianDetail':
        case 'perpetrator':
        case 'accidentType':
        case 'medical':
        case 'pedestrian':
          _.each(icds, (value, key) => {
            let tmp = {name: key === 'undefined' ? '' : key, enabled: true};
            data = data.set(value, tmp);
          });
          break;
      }
      this.defaultICD = this.defaultICD.set(key, data);
    });
    this._clone();
    this.menus = this.defaultICD.filterNot((value, key) => key === 'data');
  }

  /**
   * Clone default ICD to ICD property
   * @return void
   */
  _clone() {
    this.ICD = this.defaultICD.get('data');
  }

  /**
   * Filter ICD-10 data
   * @param  string key
   * @param  integer value
   * @return Map
   */
  _filter(key, value) {
    this.conditions[key] = value;
    let icds = this.defaultICD.get('data');
    _.each(this.conditions, (condition) => {
      if (condition !== undefined) {
        icds = icds.filter(icd => parseInt(icd[key]) === value);
      }
    });
    return icds;
  }



  /**
   * Concat all data
   * @param  object data
   * @return object
   */
  _concatAll(data) {
    return {
      code: data.code,
      pedestrian: this.defaultICD.get('pedestrian').get(data.pedestrian).name,
      pedestrianDetail: this.defaultICD.get('pedestrianDetail').get(data.pedestrianDetail).name,
      perpetrator: this.defaultICD.get('perpetrator').get(data.perpetrator).name,
      accidentType: this.defaultICD.get('accidentType').get(data.accidentType).name,
      medical: this.defaultICD.get('medical').get(data.medical).name,
    };
  }

  /**
   * Set pedestrian condition
   * @param integer value
   */
  setPedestrian(value) {
    this.ICD = this._filter('pedestrian', value);
    return this;
  }

  /**
   * Set pedestrian detail condition
   * @param integer value
   */
  setPedestrianDetail(value) {
    this.ICD = this._filter('pedestrianDetail', value);
    return this;
  }

  /**
   * Set perpetrator condition
   * @param integer value
   */
  setPerpetrator(value) {
    this.ICD = this._filter('perpetrator', value);
    return this;
  }

  /**
   * Set accitdent type condition
   * @param integer value
   */
  setAccidentType(value) {
    this.ICD = this._filter('accidentType', value);
    return this;
{'fraction_non_alphanumeric': 0.14971710430871898, 'fraction_numerical': 0.0023211954156390543, 'mean_word_length': 2.3304347826086955, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '3651645', 'n_tokens_mistral': 2361, 'n_tokens_neox': 2253, 'n_words': 458}