<commit_before>'use strict';
var chrono = require('chrono-node');

function chronoExtract(text) {
  var results = chrono.parse(text);
  var ts = results[0].start.date().getTime();
  return text.replace(results[0].text, 'TS' + ts);
}

module.exports = {
  use: function (controller) {
    return controller.middleware.receive.use(function (bot, message, next) {
      if (message.type === 'message') {
        message.text = chronoExtract(message.text);
      }
      next();
    });
  },
  extract: chronoExtract
};
<commit_msg>Leave text as is if time not found<commit_after>'use strict';
var chrono = require('chrono-node');

function chronoExtract(text) {
  var results = chrono.parse(text);
  if (results[0] && results[0].start) {
    var ts = results[0].start.date().getTime();
    text = text.replace(results[0].text, 'TS' + ts);
  }
  return text;
}

module.exports = {
  use: function (controller) {
    return controller.middleware.receive.use(function (bot, message, next) {
      if (message.type === 'message') {
        message.text = chronoExtract(message.text);
      }
      next();
    });
  },
  extract: chronoExtract
};

{'fraction_non_alphanumeric': 0.16403508771929826, 'fraction_numerical': 0.005263157894736842, 'mean_word_length': 3.4921259842519685, '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': '1488152', 'n_tokens_mistral': 371, 'n_tokens_neox': 374, 'n_words': 80}