Skip to content

Commit e19d476

Browse files
committed
Update tokenizer.py
1 parent fed0ce1 commit e19d476

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

nfp/preprocessing/tokenizer.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
class Tokenizer(object):
2-
""" A class to turn arbitrary inputs into integer classes. """
2+
"""A class to turn arbitrary inputs into integer classes."""
33

44
def __init__(self):
55
# the default class for an unseen entry during test-time
6-
self._data = {'unk': 1}
7-
self._num_classes = 1
6+
self._data = {"unk": 1}
7+
self.num_classes = 1
88
self.train = True
99
self.unknown = []
1010

1111
def __call__(self, item):
12-
""" Check to see if the Tokenizer has seen `item` before, and if so,
12+
"""Check to see if the Tokenizer has seen `item` before, and if so,
1313
return the integer class associated with it. Otherwise, if we're
1414
training, create a new integer class, otherwise return the 'unknown'
1515
class.
@@ -26,13 +26,8 @@ def __call__(self, item):
2626
else:
2727
# Record the unknown item, then return the unknown label
2828
self.unknown += [item]
29-
return self._data['unk']
30-
31-
@property
32-
def num_classes(self) -> int:
33-
"""The maximum number of assigned classes"""
34-
return self._num_classes
29+
return self._data["unk"]
3530

3631
def _add_token(self, item):
37-
self._num_classes += 1
38-
self._data[item] = self._num_classes
32+
self.num_classes += 1
33+
self._data[item] = self.num_classes

0 commit comments

Comments
 (0)