<commit_before>var config = require('./config');

module.exports = function(stream, io){
  stream.on('data', function(data) {
    var blueKeyword = data['text'].indexOf(config.keywords.blue) > -1;
    var redKeyword = data['text'].indexOf(config.keywords.red) > -1;

    console.log(data['text']);
    console.log('_');

    var tweet = {
      twid: data['id'],
      author: data['user']['name'],
      avatar: data['user']['profile_image_url'],
      body: data['text'],
      date: data['created_at'],
      screenname: data['user']['screen_name'],
      blueKeyword: blueKeyword,
      redKeyword: redKeyword
    };

    io.emit('tweet', tweet);
  });
};
<commit_msg>Improve keyword match with Regex in `streamHandler`<commit_after>var config = require('./config');

module.exports = function(stream, io){
  stream.on('data', function(data) {

    var blueKeyword = new RegExp(config.keywords.blue,'i');
    var redKeyword = new RegExp(config.keywords.red,'i');

    console.log(data['text']);
    console.log('_');

    var tweet = {
      twid: data['id'],
      author: data['user']['name'],
      avatar: data['user']['profile_image_url'],
      body: data['text'],
      date: data['created_at'],
      screenname: data['user']['screen_name'],
      blueKeyword: blueKeyword.test(data['text']),
      redKeyword: redKeyword.test(data['text'])
    };

    io.emit('tweet', tweet);
  });
};

{'fraction_non_alphanumeric': 0.19442458899213724, 'fraction_numerical': 0.0014295925661186562, 'mean_word_length': 3.6357615894039736, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2062416', 'n_tokens_mistral': 450, 'n_tokens_neox': 445, 'n_words': 82}