Skip to content
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

Python - Pretty json saving defaults to true #793

Merged
merged 2 commits into from
Sep 2, 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
6 changes: 5 additions & 1 deletion bindings/python/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [Unreleased]

### Added
- [#657]: Add SplitDelimiterBehavior customization to Punctuation constructor

### Changed
- [#793]: Saving a pretty JSON file by default when saving a tokenizer

## [0.10.3]

### Fixed
Expand Down Expand Up @@ -326,6 +329,7 @@ delimiter (Works like `.split(delimiter)`)
- Fix a bug that was causing crashes in Python 3.5


[#793]: https://github.com/huggingface/tokenizers/pull/793
[#714]: https://github.com/huggingface/tokenizers/pull/714
[#707]: https://github.com/huggingface/tokenizers/pull/707
[#693]: https://github.com/huggingface/tokenizers/pull/693
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/py_src/tokenizers/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1006,15 +1006,15 @@ class Tokenizer:
The `optional` :class:`~tokenizers.pre_tokenizers.PreTokenizer` in use by the Tokenizer
"""
pass
def save(self, pretty=False):
def save(self, pretty=True):
"""
Save the :class:`~tokenizers.Tokenizer` to the file at the given path.

Args:
path (:obj:`str`):
A path to a file in which to save the serialized tokenizer.

pretty (:obj:`bool`, defaults to :obj:`False`):
pretty (:obj:`bool`, defaults to :obj:`True`):
Whether the JSON file should be pretty formatted.
"""
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def save_model(self, directory: str, prefix: Optional[str] = None):
"""
return self._tokenizer.model.save(directory, prefix=prefix)

def save(self, path: str, pretty: bool = False):
def save(self, path: str, pretty: bool = True):
"""Save the current Tokenizer at the given path

Args:
Expand Down
6 changes: 3 additions & 3 deletions bindings/python/src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,10 @@ impl PyTokenizer {
/// path (:obj:`str`):
/// A path to a file in which to save the serialized tokenizer.
///
/// pretty (:obj:`bool`, defaults to :obj:`False`):
/// pretty (:obj:`bool`, defaults to :obj:`True`):
/// Whether the JSON file should be pretty formatted.
#[args(pretty = false)]
#[text_signature = "(self, pretty=False)"]
#[args(pretty = true)]
#[text_signature = "(self, pretty=True)"]
fn save(&self, path: &str, pretty: bool) -> PyResult<()> {
ToPyResult(self.tokenizer.save(path, pretty)).into()
}
Expand Down