<commit_before>// Copyright 2011 Google Inc. All Rights Reserved.

/**
 * @fileoverview General Input Method Module
 * @author <EMAIL> (<NAME>)
 */

// init for IME, ex. Zhuyin, Array
GenInp = function(name, conf) {
  this.name = name;

  var conf = conf || jscin.getTableData(name);
  if (!conf) {
    trace('failed to load data');
    return;
  }

  var default_conf = {
    'AUTO_COMPOSE': true,
    'AUTO_UPCHAR': true,
    'AUTO_FULLUP': false,
    'SPACE_AUTOUP': false,
    'SELKEY_SHIFT': false,
    'SPACE_RESET': true,
    'AUTO_RESET': false,
    'WILD_ENABLE': true,
    'SINMD_IN_LINE1': false,
    'END_KEY': false,
    'QPHRASE_MODE': 0,
    'DISABLE_SEL_LIST': '',
    'KEYSTROKE_REMAP': {},
    'BEEP_WRONG': true,
    'BEEP_DUPCHAR': true,
  };

  var conf_mapping = {
    'AUTO_COMPOSE': 'INP_MODE_AUTOCOMPOSE',
    'AUTO_UPCHAR': 'INP_MODE_AUTOUPCHAR',
    'SPACE_AUTOUP': 'INP_MODE_SPACEAUTOUP',
    'SELKEY_SHIFT': 'INP_MODE_SELKEYSHIFT',
    'AUTO_FULLUP': 'INP_MODE_AUTOFULLUP',
    'SPACE_IGNORE': 'INP_MODE_SPACEIGNOR',
    'AUTO_RESET': 'INP_MODE_AUTORESET',
    'SPACE_RESET': 'INP_MODE_SPACERESET',
    'WILD_ENABLE': 'INP_MODE_WILDON',
    'BEEP_WRONG': 'INP_MODE_BEEPWRONG',
    'BEEP_DUPCHAR': 'INP_MODE_BEEPDUP',
    'END_KEY': 'INP_MODE_ENDKEY',
  };
  this.conf = { 'mode': {} };
  for (var k in conf_mapping) {
    if (!(k in conf)) {
      this.conf.mode[conf_mapping[k]] = default_conf[k];
    } else {
      this.conf.mode[conf_mapping[k]] = conf[k];
    }
  }
  this.conf.modesc = conf.QPHRASE_MODE;  // not support
  this.conf.disable_sel_list = conf.DISABLE_SEL_LIST;
  if (this.conf.disable_sel_list) {
    this.conf.disable_sel_list = this.conf.disable_sel_list.toUpperCase();
  }
  this.conf.kremap = conf.KEYSTROKE_REMAP;
  this.conf.keygroups = conf.KEYGROUPS;

  // load table
  // TODO(kcwu) dirty hack now
  this.header = conf;
  this.table = conf.chardef;
  this.header.max_keystroke = parseInt(this.header.max_keystroke);

  if (this.header.endkey == undefined)
    this.header.endkey = '';
  if (this.header.endkey) {
    this.conf.mode.INP_MODE_ENDKEY = true;<commit_msg>Support space_style in gen_inp v1.<commit_after>// Copyright 2011 Google Inc. All Rights Reserved.

/**
 * @fileoverview General Input Method Module
 * @author <EMAIL> (<NAME>)
 */

// init for IME, ex. Zhuyin, Array
GenInp = function(name, conf) {
  this.name = name;

  var conf = conf || jscin.getTableData(name);
  if (!conf) {
    trace('failed to load data');
    return;
  }

  var default_conf = {
    'AUTO_COMPOSE': true,
    'AUTO_UPCHAR': true,
    'AUTO_FULLUP': false,
    'SPACE_AUTOUP': false,
    'SELKEY_SHIFT': false,
    'SPACE_RESET': true,
    'AUTO_RESET': false,
    'WILD_ENABLE': true,
    'SINMD_IN_LINE1': false,
    'END_KEY': false,
    'QPHRASE_MODE': 0,
    'DISABLE_SEL_LIST': '',
    'KEYSTROKE_REMAP': {},
    'BEEP_WRONG': true,
    'BEEP_DUPCHAR': true,
  };

  var conf_mapping = {
    'AUTO_COMPOSE': 'INP_MODE_AUTOCOMPOSE',
    'AUTO_UPCHAR': 'INP_MODE_AUTOUPCHAR',
    'SPACE_AUTOUP': 'INP_MODE_SPACEAUTOUP',
    'SELKEY_SHIFT': 'INP_MODE_SELKEYSHIFT',
    'AUTO_FULLUP': 'INP_MODE_AUTOFULLUP',
    'SPACE_IGNORE': 'INP_MODE_SPACEIGNOR',
    'AUTO_RESET': 'INP_MODE_AUTORESET',
    'SPACE_RESET': 'INP_MODE_SPACERESET',
    'WILD_ENABLE': 'INP_MODE_WILDON',
    'BEEP_WRONG': 'INP_MODE_BEEPWRONG',
    'BEEP_DUPCHAR': 'INP_MODE_BEEPDUP',
    'END_KEY': 'INP_MODE_ENDKEY',
  };
  this.conf = { 'mode': {} };
  for (var k in conf_mapping) {
    if (!(k in conf)) {
      this.conf.mode[conf_mapping[k]] = default_conf[k];
    } else {
      this.conf.mode[conf_mapping[k]] = conf[k];
    }
  }
  // GCIN space_style
  switch (parseInt(conf.space_style || "-1")) {
    // Boshiamy
    case 1: this.conf.mode.INP_MODE_SELKEYSHIFT = true;
            this.conf.mode.INP_MODE_SPACEAUTOUP = true;
            break;
    // Simplex
    case 2: this.conf.mode.INP_MODE_AUTOFULLUP = true;
            break;
    // Dayi
    case 8: this.conf.mode.INP_MODE_SELKEYSHIFT = true;
            break;
  }
  this.conf.modesc = conf.QPHRASE_MODE;  // not support
  this.conf.disable_sel_list = conf.DISABLE_SEL_LIST;
  if (this.conf.disable_sel_list) {
    this.conf.disable_sel_list = this.conf.disable_sel_list.toUpperCase();
  }
  this.conf.kremap = conf.KEYSTROKE_REMAP;
  this.conf.keygroups = conf.KEYGROUPS;

  // load table
  // TODO(kcwu) dirty hack now
  this.header = conf;
  this.table = conf.chardef;
  this.header.max_keystroke = parseInt(this.header.max_keystroke);

  if (this.header.endkey == undefined)
    this.header.endkey = '';
  if (this.header.endkey) {
    this.conf.mode.INP_MODE_ENDKEY = true;
{'fraction_non_alphanumeric': 0.14717223650385605, 'fraction_numerical': 0.003641816623821765, 'mean_word_length': 3.388157894736842, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5153837', 'n_tokens_mistral': 1868, 'n_tokens_neox': 1860, 'n_words': 316}