<commit_before>/**
* Copyright 2016 <NAME>
*
**/


module.exports = function(RED) {
  "use strict";

  var fs = require('fs');
  var child_process = require('child_process');

  function ThsenseNode(n) {
    RED.nodes.createNode(this,n);

    var node = this;

    var readth = __dirname + '/../bin/readth.sh';
    fs.access(readth, fs.X_OK, (err) => {
      console.log(err ? 'No execution access to ' + readth : 'ReadTH access OK');
    });

    this.on('input', function (msg) {
      node.log(__dirname);

      child_process.execFile(readth, (err, stdout, stderr) => {
        if (err) {
          node.error(err);
          return null;
        }

        node.log(stdout);
        node.send(msg);
      });
    });

    this.on("close", function() {

    });
  }

  RED.nodes.registerType("thsense",ThsenseNode);

}
<commit_msg>Send measurement data as msg.payload<commit_after>/**
* Copyright 2016 <NAME>
*
**/


module.exports = function(RED) {
  "use strict";

  var fs = require('fs');
  var child_process = require('child_process');

  function ThsenseNode(n) {
    RED.nodes.createNode(this,n);

    var node = this;

    var readth = __dirname + '/../bin/readth.sh';
    fs.access(readth, fs.X_OK, (err) => {
      console.log(err ? 'No execution access to ' + readth : 'ReadTH access OK');
    });

    this.on('input', function (msg) {
      node.log(__dirname);

      child_process.execFile(readth, (err, stdout, stderr) => {
        if (err) {
          node.error(err);
          return null;
        }

        // node.log(stdout);
        msg.payload = JSON.parse(stdout);
        node.send(msg);
      });
    });

    this.on("close", function() {

    });
  }

  RED.nodes.registerType("thsense",ThsenseNode);

}

{'fraction_non_alphanumeric': 0.1720368239355581, 'fraction_numerical': 0.004602991944764097, 'mean_word_length': 2.423228346456693, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5130719', 'n_tokens_mistral': 620, 'n_tokens_neox': 581, 'n_words': 114}