* Constructor of TextData. * * @param {string} dataIdentifier An identifier for this instance of TextData. * @param {string} textString The training text data. * @param {number} sampleLen Length of each training example, i.e., the input * sequence length expected by the LSTM model.
(dataIdentifier, textString, sampleLen, sampleStep)
| 62 | * example of the training data (in `textString`) to the next. |
| 63 | */ |
| 64 | constructor(dataIdentifier, textString, sampleLen, sampleStep) { |
| 65 | tf.util.assert( |
| 66 | sampleLen > 0, |
| 67 | `Expected sampleLen to be a positive integer, but got ${sampleLen}`); |
| 68 | tf.util.assert( |
| 69 | sampleStep > 0, |
| 70 | `Expected sampleStep to be a positive integer, but got ${sampleStep}`); |
| 71 | |
| 72 | if (!dataIdentifier) { |
| 73 | throw new Error('Model identifier is not provided.'); |
| 74 | } |
| 75 | |
| 76 | this.dataIdentifier_ = dataIdentifier; |
| 77 | |
| 78 | this.textString_ = textString; |
| 79 | this.textLen_ = textString.length; |
| 80 | this.sampleLen_ = sampleLen; |
| 81 | this.sampleStep_ = sampleStep; |
| 82 | |
| 83 | this.getCharSet_(); |
| 84 | this.convertAllTextToIndices_(); |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Get data identifier. |
nothing calls this directly
no test coverage detected