Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Commit 8b693b5

Browse files
urvashikCopybara-Service
authored andcommitted
Improve error message for unrecognized vocab type for text problems.
PiperOrigin-RevId: 202169649
1 parent 03871e6 commit 8b693b5

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

tensor2tensor/data_generators/imdb.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,6 @@ def generate_samples(self, data_dir, tmp_dir, dataset_split):
101101
class SentimentIMDBCharacters(SentimentIMDB):
102102
"""IMDB Sentiment classification, character level."""
103103

104+
@property
104105
def vocab_type(self):
105106
return text_problems.VocabType.CHARACTER

tensor2tensor/data_generators/text_problems.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ def get_or_create_vocab(self, data_dir, tmp_dir, force_get=False):
226226
encoder = text_encoder.TokenTextEncoder(vocab_filename,
227227
replace_oov=self.oov_token)
228228
else:
229-
raise ValueError("Unrecognized VocabType")
229+
raise ValueError(
230+
"Unrecognized VocabType: %s" % str(self.vocab_type))
230231
return encoder
231232

232233
def _maybe_pack_examples(self, generator):

0 commit comments

Comments
 (0)