<commit_before>

/**
 * Load all external dependencies
 * We use var so it's global available : ) ( not let,const)
 */
var fs      = require('fs');
var _ = require('lodash');


/**
 * Load all internal dependencies
 */
const cfg     = require('../config.js');
var pkg     = require('../package.json');
var piJS     = require('./modules/pi-js-module');

let pi = new piJS(cfg);

var io = require('socket.io')(9090);

io.on('connection', function(socket) {
  var isDriving = false;
  console.info('socket connected. (' + socket.id + ')');

  socket.on('forward', function() {
    if (isDriving) {
      return;
    }
    isDriving = true;
    pi.handleAnswer('move forward');
    socket.emit('forward');
    console.info('forward');
  });

  socket.on('backward', function() {
    if (isDriving) {
      return;
    }
    isDriving = true;
    pi.handleAnswer('move backward');
    socket.emit('backward');
    console.info('backward');
  });

  socket.on('left', function() {
    if (isDriving) {
      return;
    }
    isDriving = true;
    pi.handleAnswer('turn left');
    socket.emit('left');
    console.info('left');
    setTimeout(function () {
      pi.handleAnswer('stop');
    }, 100)
  });

  socket.on('right', function() {
    if (isDriving) {
      return;
    }
    isDriving = true;
    pi.handleAnswer('turn right');
    socket.emit('right');
    console.info('right');
    setTimeout(function () {
      pi.handleAnswer('stop');
    }, 100)
  });

  socket.on('stop', function() {
    isDriving = false;
    pi.handleAnswer('stop');
    socket.emit('stop');
    console.info('stop');
  });
});<commit_msg>Stop after turning immediately<commit_after>

/**
 * Load all external dependencies
 * We use var so it's global available : ) ( not let,const)
 */
var fs      = require('fs');
var _ = require('lodash');


/**
 * Load all internal dependencies
 */
const cfg     = require('../config.js');
var pkg     = require('../package.json');
var piJS     = require('./modules/pi-js-module');

let pi = new piJS(cfg);

var io = require('socket.io')(9090);

io.on('connection', function(socket) {
  var isDriving = false;
  console.info('socket connected. (' + socket.id + ')');

  socket.on('forward', function() {
    if (isDriving) {
      return;
    }
    isDriving = true;
    pi.handleAnswer('move forward');
    socket.emit('forward');
    console.info('forward');
  });

  socket.on('backward', function() {
    if (isDriving) {
      return;
    }
    isDriving = true;
    pi.handleAnswer('move backward');
    socket.emit('backward');
    console.info('backward');
  });

  socket.on('left', function() {
    if (isDriving) {
      return;
    }
    isDriving = true;
    pi.handleAnswer('turn left');
    socket.emit('left');
    console.info('left');
    pi.handleAnswer('stop');
  });

  socket.on('right', function() {
    if (isDriving) {
      return;
    }
    isDriving = true;
    pi.handleAnswer('turn right');
    socket.emit('right');
    console.info('right');
    pi.handleAnswer('stop');
  });

  socket.on('stop', function() {
    isDriving = false;
    pi.handleAnswer('stop');
    socket.emit('stop');
    console.info('stop');
  });
});
{'fraction_non_alphanumeric': 0.18822788794460182, 'fraction_numerical': 0.004406672961913755, 'mean_word_length': 2.8850855745721273, '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': '4391983', 'n_tokens_mistral': 1064, 'n_tokens_neox': 1023, 'n_words': 207}