Get rid of hardcoded Vocabulary class name.
In case of inheriting Vocabulary, the method `from_params` calls the
same method of the registered class if `type` is given. If
`from_params` is not overridden (even if it is), the default
implementation calls hardcoded `Vocabulary.from_instances` and
`Vocabulary.from_files` which makes overriding these methods in
subclass unreachable.
@@ -460,7 +460,7 @@ class Vocabulary(Registrable):
logger.info("Loading Vocab from files instead of dataset.")
if vocabulary_directory:
- vocab = Vocabulary.from_files(vocabulary_directory)
+ vocab = cls.from_files(vocabulary_directory)
if not extend:
params.assert_empty("Vocabulary - from files")
return vocab
@@ -475,7 +475,7 @@ class Vocabulary(Registrable):
only_include_pretrained_words = params.pop_bool("only_include_pretrained_words", False)
tokens_to_add = params.pop("tokens_to_add", None)
params.assert_empty("Vocabulary - from dataset")
- return Vocabulary.from_instances(instances=instances,
+ return cls.from_instances(instances=instances,
min_count=min_count,
max_vocab_size=max_vocab_size,
non_padded_namespaces=non_padded_namespaces,
