Skip to content

Commit b59103b

Browse files
author
The TensorFlow Datasets Authors
committed
Add the "optional" argument for text features.
PiperOrigin-RevId: 689341027
1 parent 9cd4051 commit b59103b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tensorflow_datasets/core/features/text_feature.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def __init__(
4141
encoder_config=None,
4242
*,
4343
doc: feature_lib.DocArg = None,
44+
optional: bool = False,
4445
):
4546
"""Constructs a Text FeatureConnector.
4647
@@ -50,6 +51,7 @@ def __init__(
5051
encoder_config: `tfds.deprecated.text.TextEncoderConfig`, needed if
5152
restoring from a file with `load_metadata`.
5253
doc: Documentation of this feature (e.g. description).
54+
optional: Whether the feature is optional.
5355
"""
5456
if encoder and encoder_config:
5557
raise ValueError("If encoder is provided, encoder_config must be None.")
@@ -75,6 +77,7 @@ def __init__(
7577
shape=(None,) if has_encoder else (),
7678
dtype=np.int64 if has_encoder else np.object_,
7779
doc=doc,
80+
optional=optional,
7881
)
7982

8083
@property

0 commit comments

Comments
 (0)