Commit
·
bb7c706
1
Parent(s):
5e85dd9
standardize db ids (#1)
Browse files- standardize db ids (d444ce4f6f9825aaced40ad3c376fc3b42c041f5)
- ncbi_disease.py +12 -2
ncbi_disease.py
CHANGED
|
@@ -230,14 +230,24 @@ class NCBIDiseaseDataset(datasets.GeneratorBasedBuilder):
|
|
| 230 |
# We need a unique identifier for this entity, so build it from the document id and entity id
|
| 231 |
unified_entity_id = "_".join([doc.pmid, entity.id, str(i)])
|
| 232 |
# The user can provide a callable that returns the database name.
|
| 233 |
-
db_name = "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
unified_entities.append(
|
| 235 |
{
|
| 236 |
"id": unified_entity_id,
|
| 237 |
"type": entity.type,
|
| 238 |
"text": [entity.text],
|
| 239 |
"offsets": [[entity.start, entity.end]],
|
| 240 |
-
"normalized":
|
| 241 |
}
|
| 242 |
)
|
| 243 |
|
|
|
|
| 230 |
# We need a unique identifier for this entity, so build it from the document id and entity id
|
| 231 |
unified_entity_id = "_".join([doc.pmid, entity.id, str(i)])
|
| 232 |
# The user can provide a callable that returns the database name.
|
| 233 |
+
db_name = "OMIM" if "OMIM" in entity.id else "MESH"
|
| 234 |
+
normalized = []
|
| 235 |
+
|
| 236 |
+
for x in entity.id.split("|"):
|
| 237 |
+
if x.startswith("OMIM") or x.startswith("omim"):
|
| 238 |
+
normalized.append(
|
| 239 |
+
{"db_name": "OMIM", "db_id": x.strip().split(":")[-1]}
|
| 240 |
+
)
|
| 241 |
+
else:
|
| 242 |
+
normalized.append({"db_name": "MESH", "db_id": x.strip()})
|
| 243 |
+
|
| 244 |
unified_entities.append(
|
| 245 |
{
|
| 246 |
"id": unified_entity_id,
|
| 247 |
"type": entity.type,
|
| 248 |
"text": [entity.text],
|
| 249 |
"offsets": [[entity.start, entity.end]],
|
| 250 |
+
"normalized": normalized,
|
| 251 |
}
|
| 252 |
)
|
| 253 |
|