Skip to content

Commit

Permalink
Adding value normalization to ensure all values bound to slots are lo…
Browse files Browse the repository at this point in the history
…wercase and trimmed. More work will be done in the future for handling the stripping or conversion of various special characters such as # or percent.
  • Loading branch information
scottbea committed Sep 2, 2015
1 parent 56fa477 commit b6b5bf4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ var spoken = require('spoken-numbers');
function GrammarGenerator() {
//(function constructor(self) {})(this);
}
GrammarGenerator.prototype.normalizeTextValue = function (value) {
return (value + '').toLocaleLowerCase().trim();
};
GrammarGenerator.prototype.replaceTopicReferenceWithValue = function (model, topicReference, value) {
var self = this;
var topicReferenceToken = '{' + topicReference + '}';
var valueToken = '{' + value + '|' + topicReference + '}';
var valueToken = '{' + self.normalizeTextValue(value) + ' | ' + topicReference + '}';
return model.replace(topicReferenceToken, valueToken);
};
GrammarGenerator.prototype.getNextTopicReference = function (model) {
Expand Down

0 comments on commit b6b5bf4

Please sign in to comment.