Update pipe.py
Browse files
pipe.py
CHANGED
|
@@ -35,10 +35,14 @@ class SmilesDiffusionPipe(Pipeline):
|
|
| 35 |
|
| 36 |
def encode(self, char_list):
|
| 37 |
smiles_matrix = np.zeros(len(char_list), dtype=np.float32)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
for i, char in enumerate(char_list):
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
smiles_matrix[i] = self.voc.vocab[char]
|
| 42 |
return smiles_matrix
|
| 43 |
|
| 44 |
def decode(self, matrix):
|
|
|
|
| 35 |
|
| 36 |
def encode(self, char_list):
|
| 37 |
smiles_matrix = np.zeros(len(char_list), dtype=np.float32)
|
| 38 |
+
|
| 39 |
+
unk_id = self.voc.vocab.get("[UNK]")
|
| 40 |
+
if unk_id is None:
|
| 41 |
+
raise ValueError("[UNK] token not found in vocabulary.")
|
| 42 |
+
|
| 43 |
for i, char in enumerate(char_list):
|
| 44 |
+
smiles_matrix[i] = self.voc.vocab.get(char, unk_id)
|
| 45 |
+
|
|
|
|
| 46 |
return smiles_matrix
|
| 47 |
|
| 48 |
def decode(self, matrix):
|