Skip to content

Instantly share code, notes, and snippets.

@oscar-defelice
Created November 4, 2020 08:33
Show Gist options
  • Save oscar-defelice/3c1e8c90610b466d19129375fbe1715f to your computer and use it in GitHub Desktop.
Save oscar-defelice/3c1e8c90610b466d19129375fbe1715f to your computer and use it in GitHub Desktop.
function tokenise(text) {
text = text.toLowerCase();
var splitted_text = text.split(' ');
var tokens = [];
splitted_text.forEach(element => {
if (word2index[element] != undefined) {
tokens.push(word2index[element]);
}
});
while (tokens.length < maxLen) {
tokens.push(0);
}
return tokens.slice(0,maxLen);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment