/**
 * Code to read python script
 */
const _ = require('lodash');
const spawn = require('child_process').spawn;
let py, dataString, input_data, prob, length;

exports.getHello = (bot, trigger) => {
    bot.say("Hello %s! How may i help you today. To know list of commands you can type <b>Help</b>.", trigger.personDisplayName);
};

exports.getHelp = (bot, trigger) => {
    let str = "Please find below a list of commands you can use: <br/>" +
        "- Search \<Query\>.";

    bot.say(str);
};

exports.getSearch = (bot, trigger) => {
  py = spawn('python', ['./document_prediction.py']);
  dataString = '';
  prob = [];
  length = -1;

  input_data = _.drop(trigger.args);
  input_data = _.join(input_data, ' ');

  let inputData = JSON.stringify([input_data]);
  main(inputData)
    .then(result => {

            result = JSON.parse(result);

            _.forEach(result, function(value, key) {
                prob.push(value[1])
            });
            var length = (_.uniq(prob)).length
            if(length == 1){
                bot.say("Sorry i could not find any relevant information");
            }else{
                title = 'Please find below a list of top 5 results i found: \n <br/> - '
                result = _.join(result, '<br> - ');
                result = title + result;
                bot.say(result);
            }
        })
};

const main = (inputData) => {
  return new Promise(function(resolve, reject){

    py.stdout.on('data', function(data){
        dataString += data.toString();
    });
    py.stdout.on('end', function(){
        console.log(dataString);
        resolve(dataString);
    });
    py.stdout.on('error', function(){
        console.log('error');
        reject('error');
    });

    py.stdin.write(inputData);
    py.stdin.end();
  })
}
@@ -150,18 +150,24 @@
 , length
+, info
 ;%0A
-
 %0Aexports
@@ -638,16 +638,29 @@
 th = -1;
+%0A  info = %5B%5D;
 %0A%0A  inpu
@@ -950,16 +950,54 @@
 alue%5B1%5D)
+;%0A                info.push(value%5B0%5D);
 %0A       
@@ -1260,16 +1260,21 @@
 %5Cn %3Cbr/%3E
+%3Cbr/%3E
  - '%0A   
@@ -1306,20 +1306,24 @@
 oin(
-result, '%3Cbr
+info, '%3Cbr/%3E%3Cbr/
 %3E - 

Remove probability from final response