unique keys
Browse files- pubchem_selfies.py +3 -1
pubchem_selfies.py
CHANGED
@@ -16,6 +16,7 @@
|
|
16 |
import json
|
17 |
import glob
|
18 |
import gzip
|
|
|
19 |
|
20 |
import datasets
|
21 |
|
@@ -473,9 +474,10 @@ class PubchemSelfies(datasets.GeneratorBasedBuilder):
|
|
473 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
474 |
for filepath in subdirs:
|
475 |
with gzip.open(open(filepath, "rb"), "rt", encoding="utf-8") as f:
|
476 |
-
for
|
477 |
data = json.loads(row)
|
478 |
properties = data["molecules"][0]["properties"]
|
|
|
479 |
yield key, {
|
480 |
"PUBCHEM_COMPOUND_CID": properties["PUBCHEM_COMPOUND_CID"],
|
481 |
"PUBCHEM_OPENEYE_CAN_SMILES": properties[
|
|
|
16 |
import json
|
17 |
import glob
|
18 |
import gzip
|
19 |
+
import os
|
20 |
|
21 |
import datasets
|
22 |
|
|
|
474 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
475 |
for filepath in subdirs:
|
476 |
with gzip.open(open(filepath, "rb"), "rt", encoding="utf-8") as f:
|
477 |
+
for row_idx, row in enumerate(f):
|
478 |
data = json.loads(row)
|
479 |
properties = data["molecules"][0]["properties"]
|
480 |
+
key = f"{os.path.basename(filepath)}_{row_idx}"
|
481 |
yield key, {
|
482 |
"PUBCHEM_COMPOUND_CID": properties["PUBCHEM_COMPOUND_CID"],
|
483 |
"PUBCHEM_OPENEYE_CAN_SMILES": properties[
|