MCPcopy Index your code
hub / github.com/tensorflow/tfjs-examples / textToIndices

Method textToIndices

lstm-text-generation/data.js:168–174  ·  view source on GitHub ↗

* Convert text string to integer indices. * * @param {string} text Input text. * @returns {number[]} Indices of the characters of `text`.

(text)

Source from the content-addressed store, hash-verified

166 * @returns {number[]} Indices of the characters of `text`.
167 */
168 textToIndices(text) {
169 const indices = [];
170 for (let i = 0; i < text.length; ++i) {
171 indices.push(this.charSet_.indexOf(text[i]));
172 }
173 return indices;
174 }
175
176 /**
177 * Get a random slice of text data.

Callers 3

getRandomSliceMethod · 0.95
generateTextFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected