Skip to content

Fix typo in documentation #743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion bindings/python/py_src/tokenizers/models/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,28 @@ class WordLevel(Model):

def __init__(self, vocab, unk_token):
pass
@staticmethod
def from_file(vocab, unk_token):
"""
Instantiate a WordLevel model from the given file

This method is roughly equivalent to doing::

vocab = WordLevel.read_file(vocab_filename)
wordlevel = WordLevel(vocab)

If you don't need to keep the :obj:`vocab` values lying around, this method is
more optimized than manually calling :meth:`~tokenizers.models.WordLevel.read_file` to
initialize a :class:`~tokenizers.models.WordLevel`

Args:
vocab (:obj:`str`):
The path to a :obj:`vocab.json` file

Returns:
:class:`~tokenizers.models.WordLevel`: An instance of WordLevel loaded from file
"""
pass
def id_to_token(self, id):
"""
Get the token associated to an ID
Expand Down Expand Up @@ -403,7 +425,7 @@ class WordPiece(Model):
The path to a :obj:`vocab.txt` file

Returns:
:class:`~tokenizers.models.WordPiece`: And instance of WordPiece loaded from file
:class:`~tokenizers.models.WordPiece`: An instance of WordPiece loaded from file
"""
pass
def id_to_token(self, id):
Expand Down
5 changes: 3 additions & 2 deletions bindings/python/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ impl PyWordPiece {
/// The path to a :obj:`vocab.txt` file
///
/// Returns:
/// :class:`~tokenizers.models.WordPiece`: And instance of WordPiece loaded from file
/// :class:`~tokenizers.models.WordPiece`: An instance of WordPiece loaded from file
#[classmethod]
#[args(kwargs = "**")]
#[text_signature = "(vocab, **kwargs)"]
Expand Down Expand Up @@ -748,9 +748,10 @@ impl PyWordLevel {
/// The path to a :obj:`vocab.json` file
///
/// Returns:
/// :class:`~tokenizers.models.WordLevel`: And instance of WordLevel loaded from file
/// :class:`~tokenizers.models.WordLevel`: An instance of WordLevel loaded from file
#[classmethod]
#[args(unk_token = "None")]
#[text_signature = "(vocab, unk_token)"]
fn from_file(
_cls: &PyType,
py: Python,
Expand Down