Skip to content

Instantly share code, notes, and snippets.

@backupbrain
Created October 15, 2018 18:51
Show Gist options
  • Save backupbrain/e710544fe857870e59956e49e60ee638 to your computer and use it in GitHub Desktop.
Save backupbrain/e710544fe857870e59956e49e60ee638 to your computer and use it in GitHub Desktop.
Tokenizer.prototype.padTokens = function(text) {
tokenized = text.replace(/ ?([,\(\)\/\[\]\+\*\-]+) ?/g, " $1 ");
tokenized = tokenized.replace(/ ?([,]) ?/g, " $1 ");
tokenized = tokenized.replace(/- >/g, "->")
tokenized = tokenized.replace(/ ?(==) ?/g, " $1 ");
tokenized = tokenized.replace(/;/g, " ;");
tokenized = tokenized.replace(/\s{2,}/g, " ");
return tokenized;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment