Datasets:
Update README.md
Browse files
README.md
CHANGED
|
@@ -260,35 +260,21 @@ One dataset instance corresponds to **one report**.
|
|
| 260 |
|
| 261 |
### Hugging Face dataset
|
| 262 |
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
- document_metadata: For accessing full texts and global identifiers.
|
| 266 |
-
|
| 267 |
-
- spans: For extracting specific annotations and entities.
|
| 268 |
-
|
| 269 |
-
- relations: For analyzing links and dependencies between spans (if they exist).
|
| 270 |
-
|
| 271 |
-
You can easily load and explore these different parts using the datasets library, as shown in the following example:
|
| 272 |
-
|
| 273 |
|
| 274 |
```python
|
|
|
|
| 275 |
from datasets import load_dataset
|
| 276 |
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
# Load and display a relation between entities (if they exist)
|
| 288 |
-
ds_rel = load_dataset("HealthDataHub/PARHAF-biomarkers-annotated", name="relations")
|
| 289 |
-
if len(ds_rel["train"]) > 0:
|
| 290 |
-
rel = ds_rel["train"][0]
|
| 291 |
-
print(f"Relation: {rel['source_text']} -> {rel['target_text']}")
|
| 292 |
```
|
| 293 |
### Data Fields
|
| 294 |
|
|
|
|
| 260 |
|
| 261 |
### Hugging Face dataset
|
| 262 |
|
| 263 |
+
This snippet shows how to extract and iterate over medical report information per patient using the datasets library.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
|
| 265 |
```python
|
| 266 |
+
import pandas as pd
|
| 267 |
from datasets import load_dataset
|
| 268 |
|
| 269 |
+
dfs = {cfg: load_dataset("HealthDataHub/PARHAF-biomarkers-annotated", cfg, split="train").to_pandas()
|
| 270 |
+
for cfg in ["document_metadata", "spans", "relations"]}
|
| 271 |
+
|
| 272 |
+
for patient_raw in dfs["document_metadata"].itertuples():
|
| 273 |
+
report_id = patient_raw.report
|
| 274 |
+
text = patient_raw.full_text
|
| 275 |
+
report_spans = dfs["spans"][dfs["spans"]["report"] == report_id]
|
| 276 |
+
report_relations = dfs["relations"][dfs["relations"]["report"] == report_id]
|
| 277 |
+
...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
```
|
| 279 |
### Data Fields
|
| 280 |
|