* Get a random slice of text data. * * @returns {[string, number[]} The string and index representation of the * same slice.
()
| 180 | * same slice. |
| 181 | */ |
| 182 | getRandomSlice() { |
| 183 | const startIndex = |
| 184 | Math.round(Math.random() * (this.textLen_ - this.sampleLen_ - 1)); |
| 185 | const textSlice = this.slice_(startIndex, startIndex + this.sampleLen_); |
| 186 | return [textSlice, this.textToIndices(textSlice)]; |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * Get a slice of the training text data. |
no test coverage detected