abdellaouic commited on
Commit
4d866f0
·
verified ·
1 Parent(s): ac5b8e3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +13 -27
README.md CHANGED
@@ -155,35 +155,21 @@ One dataset instance corresponds to **one report**.
155
 
156
  ### Hugging Face dataset
157
 
158
- To facilitate machine learning workflows and easy filtering, the Hugging Face representation is organized into three distinct configurations. This allows for efficient filtering and relational access without parsing the original nested JSON:
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
- from datasets import load_dataset
171
-
172
- # Load document metadata and access the first report
173
- ds_meta = load_dataset("HealthDataHub/PARHAF-pseudo-annotated", name="document_metadata")
174
- first_doc = ds_meta["train"][0]
175
- print(f"Report ID: {first_doc['report']}")
176
-
177
- # Load annotations and iterate through the first samples
178
- ds_spans = load_dataset("HealthDataHub/PARHAF-pseudo-annotated", name="spans")
179
- for span in ds_spans["train"].select(range(5)):
180
- print(f"Type: {span['span_type']} | Text: {span['span_text']}")
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