transform
transform¶
- class hanlp.common.transform.VocabDict(*args, **kwargs)[source]¶
A dict holding
hanlp.common.vocab.Vocab
instances. When used as a transform, it transforms the field corresponding to eachhanlp.common.vocab.Vocab
into indices.- Parameters
*args – A list of vocab names.
**kwargs – Names and corresponding
hanlp.common.vocab.Vocab
instances.
- load_vocabs(save_dir, filename='vocabs.json', vocab_cls=<class 'hanlp.common.vocab.Vocab'>)[source]¶
Load vocabularies from a directory.
- Parameters
save_dir – The directory to load vocabularies.
filename – The name for vocabularies.
- put(**kwargs)[source]¶
Put names and corresponding
hanlp.common.vocab.Vocab
instances into self.- Parameters
**kwargs – Names and corresponding
hanlp.common.vocab.Vocab
instances.
- save_vocabs(save_dir, filename='vocabs.json')[source]¶
Save vocabularies to a directory.
- Parameters
save_dir – The directory to save vocabularies.
filename – The name for vocabularies.
- summary(logger: Optional[logging.Logger] = None)[source]¶
Log a summary of vocabs using a given logger.
- Parameters
logger – The logger to use.