ajdajd commited on
Commit
e469ff5
·
1 Parent(s): 0077dd0

Add loading dataset examples

Browse files
Files changed (1) hide show
  1. README.md +33 -0
README.md CHANGED
@@ -86,6 +86,39 @@ ai4data/data-snapshot/
86
  - PRWP
87
  - Refugee
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  ## Schema
90
 
91
  ### Annotations
 
86
  - PRWP
87
  - Refugee
88
 
89
+ ## Loading the dataset using HF's `datasets` library
90
+
91
+ ### Annotations
92
+
93
+ ```python
94
+ >>> from datasets import load_dataset
95
+ >>> annotations = load_dataset("ajdajd/data-snapshot", name="annotations", split="unhcr")
96
+ >>> annotations[0] # Inspect the first record
97
+ {'label_map': {'1': 'Figure', '2': 'Table'}, 'info': {'schema_version': '1.3', 'type': 'ground_truth', 'created_at': datetime.datetime(2026, 5, 20, 13, 44, 29), 'run_id': 'human-annotation-combined-e3432dce89', 'model': {'name': 'human annotation'}, 'coordinate_system': {'type': 'normalized_xyxy', 'range': [0.0, 1.0], 'origin': 'top_left'}}, 'documents': [{'doc_id': '06072015-baalbek-hermelgovernorateprofile.pdf', 'doc_name': '06072015-baalbek-hermelgovernorateprofile.pdf', 'doc_path': 'pdf_input/06072015-baalbek-hermelgovernorateprofile.pdf'}], 'predictions': [{'page_id': '06072015-baalbek-hermelgovernorateprofile.pdf::p000', 'doc_id': '06072015-baalbek-hermelgovernorateprofile.pdf', 'page_index': 0, 'objects': [{'id': '1d69f693', 'label': 'Figure', 'bbox': [0.029415499554572243, 0.1766403810171256, 0.5954839424856321, 0.7354445202645015], 'score': None}, ...}
98
+ ```
99
+
100
+ ### Metadata
101
+
102
+ ```python
103
+ >>> metadata = load_dataset("ajdajd/data-snapshot", name="metadata", split="unhcr")
104
+ >>> metadata[0] # Inspect the first record
105
+ {'type': 'document', 'metadata_information': {'title': 'Lebanon: Baalbek-Hermel Governorate Profile (June 2015)', 'idno': '06072015-baalbek-hermelgovernorateprofile', 'producers': [{'name': 'UNHCR', 'abbr': 'UNHCR', 'affiliation': 'UNHCR', 'role': 'Source'}], 'production_date': datetime.datetime(2026, 5, 21, 0, 0), ...}
106
+ ```
107
+
108
+ ### Documents
109
+
110
+ ```python
111
+ >>> docs = load_dataset("ajdajd/data-snapshot", data_dir="documents/unhcr") # Or simply data_dir="documents/" for all files
112
+ >>> docs.save_to_disk("path/to/docs_directory") # Files are saved as an Arrow file
113
+ ```
114
+
115
+ ### Snapshots
116
+
117
+ ```python
118
+ >>> snapshots = load_dataset("ajdajd/data-snapshot", data_dir="snapshots/unhcr") # Or simply data_dir="snapshots/" for all snapshots
119
+ >>> snapshots.save_to_disk("path/to/snapshots_directory") # Files are saved as an Arrow file
120
+ ```
121
+
122
  ## Schema
123
 
124
  ### Annotations