<commit_before>'use strict';

var _ = require('lodash'),
    AlexaSkill = require('./AlexaSkill'),
    Request = require('./Request'),
    Reply = require('alexa-helpers').reply,
    MessageRenderer = require('alexa-helpers').messageRenderer,
    messageRenderer = null,
    Promise = require('bluebird'),
    universalAnalytics = require('universal-analytics'),
    verbose = true
    ;

var StateMachineSkill = module.exports = function (appId,
  StateMachine,
  responses,
  variables,
  config) {
  var _this = this;
  _this._StateMachine = StateMachine;
  _this._responses = responses || {};
  _this._variables = variables || {};
  _this._config = config || { verbose: verbose };
  if (typeof _this._config.verbose !== undefined) verbose = _this._config.verbose;
  messageRenderer = MessageRenderer(_this._responses, _this._variables);
  AlexaSkill.call(_this, appId);
};

module.exports.verbose = verbose;

// Extend AlexaSkill
StateMachineSkill.prototype = Object.create(AlexaSkill.prototype);
StateMachineSkill.prototype.constructor = StateMachineSkill;

var ERRORS = module.exports.ERRORS = {
  AUTHORIZATION: 'Authorization Error',
  BAD_RESPONSE: 'Bad Response Error',
};

StateMachineSkill.prototype.eventHandlers.onSessionStarted = function (sessionStartedRequest,
  session) {
  var _this = this;
  if (_this._config.verbose) console.log('onSessionStarted requestId: ' +
    sessionStartedRequest.requestId + ', sessionId: ' + session.sessionId);
  var handler = _this._StateMachine.onSessionStart;
  if (handler) return handler(new Request(sessionStartedRequest, session));
};

StateMachineSkill.prototype.eventHandlers.onLaunch = function (launchRequest, session,
  response, context) {
  var _this = this;
  if (_this._config.verbose)
    console.log('onLaunch requestId: ' + launchRequest.requestId + ', sessionId: ' +
      session.sessionId);
  var intent = _this._StateMachine.openIntent;
  _this.eventHandlers.onIntent.call(_this, {
    type: 'IntentRequest',
    requestId: launchRequest.requestId,
    timestamp: launchRequest.timestamp,
    intent: {
        name: intent,
        slots: {},
    },

  }, session, response, context);
};

StateMachineSkill.prototype.eventHandlers.onSessionEnded = function (sessionEndedRequest, session) {
  var _this = this;
  if (_this._config.verbose)
    console.log('onSessionEnded requestId: ' + sessionEndedRequest.requestId + ', sessionId: ' +
      session.sessionId);
  var handler = _this._StateMachine.onSessionEnd;
  if (handler) handler(new Request(sessionEndedRequest, session));
};

StateMachineSkill.prototype.eventHandlers.onIntent = function (request, session,
  response, context) {
  var _this = this;
  request = new Request(request, session);
  if (_this._config.verbose) console.log('Got intent ' + request.intent.name);

  var fromState = session.new ? 'entry' : session.attributes.state || 'entry',
      stateMachine = _this._StateMachine(fromState);

  if (stateMachine.onRequestStart) stateMachine.onRequestStart(request);

  return stateMachine.transition(request).then(function (trans) {
    return transitionEndingInterceptor.call(_this, trans, stateMachine, request);
  }).then(function (trans) {<commit_msg>Fixed issue from last commit<commit_after>'use strict';

var _ = require('lodash'),
    AlexaSkill = require('./AlexaSkill'),
    Request = require('./Request'),
    Reply = require('alexa-helpers').reply,
    MessageRenderer = require('alexa-helpers').messageRenderer,
    messageRenderer = null,
    Promise = require('bluebird'),
    universalAnalytics = require('universal-analytics'),
    verbose = true
    ;

var StateMachineSkill = module.exports = function (appId,
  StateMachine,
  responses,
  variables,
  config) {
  var _this = this;
  _this._StateMachine = StateMachine;
  _this._responses = responses || {};
  _this._variables = variables || {};
  _this._config = config || { verbose: verbose };
  if (typeof _this._config.verbose !== undefined) verbose = _this._config.verbose;
  messageRenderer = MessageRenderer(_this._responses, _this._variables);
  AlexaSkill.call(_this, appId);
};

module.exports.verbose = verbose;

// Extend AlexaSkill
StateMachineSkill.prototype = Object.create(AlexaSkill.prototype);
StateMachineSkill.prototype.constructor = StateMachineSkill;

var ERRORS = module.exports.ERRORS = {
  AUTHORIZATION: 'Authorization Error',
  BAD_RESPONSE: 'Bad Response Error',
};

StateMachineSkill.prototype.eventHandlers.onSessionStarted = function (sessionStartedRequest,
  session) {
  var _this = this;
  if (_this._config.verbose) console.log('onSessionStarted requestId: ' +
    sessionStartedRequest.requestId + ', sessionId: ' + session.sessionId);
  var handler = _this._StateMachine.onSessionStart;
  if (handler) return handler(new Request(sessionStartedRequest, session));
};

StateMachineSkill.prototype.eventHandlers.onLaunch = function (launchRequest, session,
  response, context) {
  var _this = this;
  if (_this._config.verbose)
    console.log('onLaunch requestId: ' + launchRequest.requestId + ', sessionId: ' +
      session.sessionId);
  var intent = _this._StateMachine.openIntent;
  _this.eventHandlers.onIntent.call(_this, {
    type: 'IntentRequest',
    requestId: launchRequest.requestId,
    timestamp: launchRequest.timestamp,
    intent: {
        name: intent,
        slots: {},
    },

  }, session, response, context);
};

StateMachineSkill.prototype.eventHandlers.onSessionEnded = function (sessionEndedRequest, session) {
  var _this = this;
  if (_this._config.verbose)
    console.log('onSessionEnded requestId: ' + sessionEndedRequest.requestId + ', sessionId: ' +
      session.sessionId);
  var handler = _this._StateMachine.onSessionEnd;
  if (handler) handler(new Request(sessionEndedRequest, session));
};

StateMachineSkill.prototype.eventHandlers.onIntent = function (request, session,
  response, context) {
  var _this = this;
  request = new Request(request, session);
  if (_this._config.verbose) console.log('Got intent ' + request.intent.name);

  var fromState = session.new ? 'entry' : session.attributes.state || 'entry',
      stateMachine = _this._StateMachine(fromState);

  if (stateMachine.onRequestStart) stateMachine.onRequestStart(request);

  return stateMachine.transition(request, context).then(function (trans) {
    return transitionEndingInterceptor.call(_this, trans, stateMachine, request);
  }).then(function (trans) {
{'fraction_non_alphanumeric': 0.12161320460915602, 'fraction_numerical': 0.0, 'mean_word_length': 4.765709156193896, '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': '5076022', 'n_tokens_mistral': 1897, 'n_tokens_neox': 1870, 'n_words': 381}