Datasets:
Update README.md
Browse files
README.md
CHANGED
|
@@ -155,35 +155,21 @@ One dataset instance corresponds to **one report**.
|
|
| 155 |
|
| 156 |
### Hugging Face dataset
|
| 157 |
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
- document_metadata: For accessing full texts and global identifiers.
|
| 161 |
-
|
| 162 |
-
- spans: For extracting specific annotations and entities.
|
| 163 |
-
|
| 164 |
-
- relations: For analyzing links and dependencies between spans (if they exist).
|
| 165 |
-
|
| 166 |
-
You can easily load and explore these different parts using the datasets library, as shown in the following example:
|
| 167 |
-
|
| 168 |
|
| 169 |
```python
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
# Load and display a relation between entities (if they exist)
|
| 183 |
-
ds_rel = load_dataset("HealthDataHub/PARHAF-pseudo-annotated", name="relations")
|
| 184 |
-
if len(ds_rel["train"]) > 0:
|
| 185 |
-
rel = ds_rel["train"][0]
|
| 186 |
-
print(f"Relation: {rel['source_text']} -> {rel['target_text']}")
|
| 187 |
```
|
| 188 |
### Data Fields
|
| 189 |
|
|
|
|
| 155 |
|
| 156 |
### Hugging Face dataset
|
| 157 |
|
| 158 |
+
This snippet shows how to extract and iterate over medical report information per patient using the datasets library.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
|
| 160 |
```python
|
| 161 |
+
import pandas as pd
|
| 162 |
+
from datasets import load_dataset
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
dfs = {cfg: load_dataset("HealthDataHub/PARHAF-pseudo-annotated", cfg, split="train").to_pandas()
|
| 166 |
+
for cfg in ["document_metadata", "spans"]}
|
| 167 |
+
|
| 168 |
+
for patient_raw in dfs["document_metadata"].itertuples():
|
| 169 |
+
report_id = patient_raw.report
|
| 170 |
+
text = patient_raw.full_text
|
| 171 |
+
report_spans = dfs["spans"][dfs["spans"]["report"] == report_id]
|
| 172 |
+
...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
```
|
| 174 |
### Data Fields
|
| 175 |
|