register_tokenizer

opennmt.tokenizers.register_tokenizer(cls=None, name=None, alias=None)

Registers a class.

Parameters
  • cls – The class to register. If not set, this method returns a decorator for registration.

  • name – The class name. Defaults to cls.__name__.

  • alias – An optional alias or list of alias for this class.

Returns

cls if set, else a class decorator.

Raises
  • TypeError – if cls does not extend the expected base class.

  • ValueError – if the class name is already registered.