Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
amaiya committed Aug 11, 2020
2 parents 413e4f8 + 541f978 commit 3d6e0c6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ Most recent releases are shown at the top. Each release shows:
- **Changed**: Additional parameters, changes to inputs or outputs, etc
- **Fixed**: Bug fixes that don't change documented behaviour

## 0.19.5 (2020-08-11)

### New:
- N/A

### Changed
-N/A

### Fixed:
- Ensure transition to `YTransform` is backwards compatibility for `StandardTextPreprocessor` and `BertPreprocessor`


## 0.19.4 (2020-08-10)

### New:
Expand Down
33 changes: 33 additions & 0 deletions ktrain/text/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,21 @@ def __init__(self, maxlen, max_features, class_names=[], classes=[],
self.ngram_range = ngram_range


def __getstate__(self):
return {k: v for k, v in self.__dict__.items()}


def __setstate__(self, state):
"""
For backwards compatibility with pre-ytransform versions
"""
self.__dict__.update(state)
if not hasattr(self, 'ytransform'):
le = self.label_encoder if hasattr(self, 'label_encoder') else None
self.ytransform = U.YTransform(class_names=self.get_classes(), label_encoder=le)



def get_preprocessor(self):
return (self.tok, self.tok_dct)

Expand Down Expand Up @@ -711,6 +726,20 @@ def __init__(self, maxlen, max_features, class_names=[], classes=[],
self.ngram_range = 1 # ignored


def __getstate__(self):
return {k: v for k, v in self.__dict__.items()}


def __setstate__(self, state):
"""
For backwards compatibility with pre-ytransform versions
"""
self.__dict__.update(state)
if not hasattr(self, 'ytransform'):
le = self.label_encoder if hasattr(self, 'label_encoder') else None
self.ytransform = U.YTransform(class_names=self.get_classes(), label_encoder=le)


def get_preprocessor(self):
return (self.tok, self.tok_dct)

Expand Down Expand Up @@ -806,6 +835,10 @@ def __getstate__(self):


def __setstate__(self, state):
"""
For backwards compatibility with previous versions of ktrain
that saved tokenizer and did not use ytransform
"""
self.__dict__.update(state)
if not hasattr(self, 'tok'): self.tok = None
if not hasattr(self, 'ytransform'):
Expand Down
2 changes: 1 addition & 1 deletion ktrain/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__all__ = ['__version__']
__version__ = '0.19.4'
__version__ = '0.19.5'

0 comments on commit 3d6e0c6

Please sign in to comment.