(texts: list[str], *, repeat=1)
| 296 | |
| 297 | |
| 298 | def _text_ds(texts: list[str], *, repeat=1) -> tf.data.Dataset: |
| 299 | dataset = { |
| 300 | "text": [], |
| 301 | "index": [], |
| 302 | "is_valid": [], |
| 303 | } |
| 304 | |
| 305 | for index, text in enumerate(texts): |
| 306 | dataset["index"].append(tf.constant(index, dtype=tf.int32)) |
| 307 | dataset["text"].append(tf.constant(text, dtype=tf.string)) |
| 308 | dataset["is_valid"].append(tf.constant(True, dtype=tf.bool)) |
| 309 | |
| 310 | return tf.data.Dataset.from_tensor_slices(dataset).repeat(repeat) |
| 311 | |
| 312 | |
| 313 | def _tokens_ds(tokens: list[list[int]], *, repeat=1) -> tf.data.Dataset: |
no outgoing calls
no test coverage detected