// splitByPeriods.js
(function() {
/*global adventurejs A*/
"use strict";
var p = adventurejs.Parser.prototype;
/**
* Split distinct sentences by period.
* @memberOf adventurejs.Parser
* @method adventurejs.Parser#splitByPeriods
* @param {String} input
* @returns {Array}
*/
p.splitByPeriods = function Parser_splitByPeriods( input )
{
var inputArray = input.split('.');
for( var i = inputArray.length - 1; i > -1; i-- )
{
inputArray[i] = inputArray[i].trim();
if( " " === inputArray[i]
|| "" === inputArray[i] )
{
inputArray.splice( i, 1 );
}
}
inputArray.forEach(function(clause,index)
{
var thenArray = this.splitByThens(clause);
if(thenArray.length>1)
{
var arrayFront = inputArray.slice(0,index);
var arrayBack = inputArray.slice(index+1,inputArray.length+1);
inputArray = arrayFront.concat(thenArray.concat(arrayBack));
}
}, this );
return inputArray;
}
}());