<commit_before>/* vim: set expandtab tabstop=2 shiftwidth=2 foldmethod=marker: */

"use strict";

var net = require('net');
var util = require('util');
var Emitter = require('events').EventEmitter;
var listen2 = require(__dirname + '/common.js').listen2;

exports.create = function (options, PROCESS) {

  /**
   * @ 配置参数
   */
  var _options  = {
    'heartbeat_interval' : 2000,
    'terminate_timeout'  : 1000,
  };
  for (var i in options) {
    _options[i] = ~~Number(options[i]);
  }

  /**
   * @ 方便单元测试
   */
  PROCESS = PROCESS || process;

  /**
   * @ send message to master
   */
  var askmaster = function () {};
  if ('function' === (typeof PROCESS.send)) {
    askmaster = function (type, data) {
      try {
        PROCESS.send({'type' : type, 'data' : data});
      } catch (e) {
      }
    }
  }

  /**
   * @ 连接处理
   */
  var onconnect = function (socket, which) {
    socket.end();
  };

  /**<commit_msg>remove try ... catch in worker when send to master<commit_after>/* vim: set expandtab tabstop=2 shiftwidth=2 foldmethod=marker: */

"use strict";

var net = require('net');
var util = require('util');
var Emitter = require('events').EventEmitter;
var listen2 = require(__dirname + '/common.js').listen2;

exports.create = function (options, PROCESS) {

  /**
   * @ 配置参数
   */
  var _options  = {
    'heartbeat_interval' : 2000,
    'terminate_timeout'  : 1000,
  };
  for (var i in options) {
    _options[i] = ~~Number(options[i]);
  }

  /**
   * @ 方便单元测试
   */
  PROCESS = PROCESS || process;

  /**
   * @ send message to master
   */
  var askmaster = function () {};
  if ('function' === (typeof PROCESS.send)) {
    askmaster = function (type, data) {
      PROCESS.send({'type' : type, 'data' : data});
    }
  }

  /**
   * @ 连接处理
   */
  var onconnect = function (socket, which) {
    socket.end();
  };

  /**
{'fraction_non_alphanumeric': 0.17685235262303947, 'fraction_numerical': 0.012979989183342347, 'mean_word_length': 2.685258964143426, 'pattern_counts': {'":': 0, '<': 3, '<?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': '52821', 'n_tokens_mistral': 681, 'n_tokens_neox': 666, 'n_words': 151}