Skip to content

Commit

Permalink
fix selfies reader file creation
Browse files Browse the repository at this point in the history
  • Loading branch information
sfluegel committed Nov 29, 2023
1 parent 5f50d8f commit fe6c3f0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions chebai/preprocessing/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
dirname = os.path.dirname(__file__)
os.makedirs(os.path.join(dirname, "bin", self.name()), exist_ok=True)

self.tokens_path = os.path.join(dirname, "bin", self.name(), "tokens.txt")
with open(self.tokens_path, "r+") as pk:
with open(self.tokens_path, "a+") as pk:
self.cache = [x.strip() for x in pk]

def _get_token_index(self, token):
Expand Down Expand Up @@ -183,7 +184,7 @@ def _read_data(self, raw_data):
tokenized = sf.split_selfies(sf.encoder(raw_data, strict=True))
tokenized = [self._get_token_index(v) for v in tokenized]
except Exception as e:
print(f'could not process {raw_data}')
print(f'could not process {raw_data} (type: {type(raw_data)}')
print(f'\t{e}')
self.error_count += 1
print(f'\terror count: {self.error_count}')
Expand Down

0 comments on commit fe6c3f0

Please sign in to comment.