Datasets:

Languages:
English
DOI:
License:
arminmehrabian commited on
Commit
87308e5
·
verified ·
1 Parent(s): 907ebf1

Update READM for version v1.0.1

Browse files
Files changed (1) hide show
  1. README.md +169 -26
README.md CHANGED
@@ -24,9 +24,9 @@ Each file in the dataset has a SHA-256 checksum to verify its integrity:
24
 
25
  | File Name | SHA-256 Checksum |
26
  |----------------------------|---------------------------------------------------------------------------|
27
- | `graph.cypher` | `9159a04d385ccbd53858eaf21f4f80c9ce17b52ff997c410400ecc085bfbe010` |
28
- | `graph.graphml` | `2ca75302371f6be9fee1a051948144ba26147c1eebaea1e7a00dd1eb86ba2031` |
29
- | `graph.json` | `1dbeef75206edc3f893819589461b2a2ed9c1a14311dcc8aca304fb58c005ca1` |
30
 
31
  ### Verification
32
 
@@ -181,23 +181,38 @@ The knowledge graph includes several relationship types that define how nodes ar
181
 
182
  ## Statistics
183
 
184
- - **Total Nodes**: **135,764**
185
- - **Publication**: 125,939
186
- - **Dataset**: 6,390
187
- - **ScienceKeyword**: 1,609
188
- - **Instrument**: 867
189
- - **Platform**: 442
190
- - **Project**: 333
191
- - **DataCenter**: 184
192
- - **Total Relationships**: **344,525**
193
- - **CITES**: 208,670
194
- - **HAS_APPLIED_RESEARCH_AREA**: 89,039
195
- - **HAS_SCIENCEKEYWORD**: 20,436
196
- - **HAS_PLATFORM**: 9,884
197
- - **HAS_DATASET**: 9,017
198
- - **OF_PROJECT**: 6,049
199
- - **HAS_INSTRUMENT**: 2,469
200
- - **HAS_SUBCATEGORY**: *(Count not provided)*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
 
202
  ## Data Formats
203
 
@@ -211,12 +226,140 @@ The Knowledge Graph Dataset is available in three formats:
211
 
212
  #### Loading the JSON Format
213
 
214
- To load the JSON file into a graph database that supports Cypher and the APOC library, use the following command:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
216
- ```cypher
217
- CALL apoc.load.json("path/to/graph.json") YIELD value
218
- MERGE (n {id: value.id, label: value.label})
219
- SET n += value.properties
220
  ```
221
 
222
  ### 2. GraphML
@@ -360,7 +503,7 @@ Please cite the dataset as follows:
360
  ```bibtex
361
  @misc {nasa_goddard_earth_sciences_data_and_information_services_center__(ges-disc)_2024,
362
  author = { {NASA Goddard Earth Sciences Data and Information Services Center (GES-DISC)} },
363
- title = { nasa-eo-knowledge-graph (Revision b8f650e) },
364
  year = 2024,
365
  url = { https://huggingface.co/datasets/nasa-gesdisc/nasa-eo-knowledge-graph },
366
  doi = { 10.57967/hf/3463 },
 
24
 
25
  | File Name | SHA-256 Checksum |
26
  |----------------------------|---------------------------------------------------------------------------|
27
+ | `graph.cypher` | `d78f7b166a86be3ceec16db75a1575dac95249af188b1d2e2adab7388a8e654a` |
28
+ | `graph.graphml` | `a781e358b338a181db5081a50127325febab67dcb283cb4124c877bf06de439e` |
29
+ | `graph.json` | `4794fd070953b3544ba3c841f13155f1cf8a1ca9abd1b240bbfaf482ce2cde32` |
30
 
31
  ### Verification
32
 
 
181
 
182
  ## Statistics
183
 
184
+ # Data Statistics
185
+
186
+ ## Total Counts
187
+ | Type | Count |
188
+ |----------------------|---------|
189
+ | **Total Nodes** | 135,764 |
190
+ | **Total Relationships** | 365,857 |
191
+
192
+ ## Node Label Counts
193
+ | Node Label | Count |
194
+ |-------------------|----------|
195
+ | Dataset | 6,390 |
196
+ | DataCenter | 184 |
197
+ | Project | 333 |
198
+ | Platform | 442 |
199
+ | Instrument | 867 |
200
+ | ScienceKeyword | 1,609 |
201
+ | Publication | 125,939 |
202
+
203
+ ## Relationship Label Counts
204
+ | Relationship Label | Count |
205
+ |---------------------------|-----------|
206
+ | HAS_DATASET | 9,017 |
207
+ | OF_PROJECT | 6,049 |
208
+ | HAS_PLATFORM | 9,884 |
209
+ | HAS_INSTRUMENT | 2,469 |
210
+ | HAS_SUBCATEGORY | 1,823 |
211
+ | HAS_SCIENCEKEYWORD | 20,436 |
212
+ | CITES | 208,670 |
213
+ | HAS_APPLIED_RESEARCH_AREA| 89,039 |
214
+ | USES_DATASET | 18,470 |
215
+
216
 
217
  ## Data Formats
218
 
 
226
 
227
  #### Loading the JSON Format
228
 
229
+ To load the JSON file into a graph database using Python and multiprocessing you can using the following script:
230
+
231
+ ```python
232
+ import json
233
+ from tqdm import tqdm
234
+ from collections import defaultdict
235
+ from multiprocessing import Pool, cpu_count
236
+ from neo4j import GraphDatabase
237
+
238
+ # Batch size for processing
239
+ BATCH_SIZE = 100
240
+
241
+ # Neo4j credentials (replace with environment variables or placeholders)
242
+ NEO4J_URI = "bolt://<your-neo4j-host>:<port>" # e.g., "bolt://localhost:7687"
243
+ NEO4J_USER = "<your-username>"
244
+ NEO4J_PASSWORD = "<your-password>"
245
+
246
+
247
+ def ingest_data(file_path):
248
+ # Initialize counters and label trackers
249
+ node_label_counts = defaultdict(int)
250
+ relationship_label_counts = defaultdict(int)
251
+ node_count = 0
252
+ relationship_count = 0
253
+
254
+ with open(file_path, "r") as f:
255
+ nodes = []
256
+ relationships = []
257
+
258
+ # Read and categorize nodes and relationships, and count labels
259
+ for line in tqdm(f, desc="Reading JSON Lines"):
260
+ obj = json.loads(line.strip())
261
+ if obj["type"] == "node":
262
+ nodes.append(obj)
263
+ node_count += 1
264
+ for label in obj["labels"]:
265
+ node_label_counts[label] += 1
266
+ elif obj["type"] == "relationship":
267
+ relationships.append(obj)
268
+ relationship_count += 1
269
+ relationship_label_counts[obj["label"]] += 1
270
+
271
+ # Print statistics
272
+ print("\n=== Data Statistics ===")
273
+ print(f"Total Nodes: {node_count}")
274
+ print(f"Total Relationships: {relationship_count}")
275
+ print("\nNode Label Counts:")
276
+ for label, count in node_label_counts.items():
277
+ print(f" {label}: {count}")
278
+ print("\nRelationship Label Counts:")
279
+ for label, count in relationship_label_counts.items():
280
+ print(f" {label}: {count}")
281
+ print("=======================")
282
+
283
+ # Multiprocess node ingestion
284
+ print("Starting Node Ingestion...")
285
+ node_batches = [nodes[i : i + BATCH_SIZE] for i in range(0, len(nodes), BATCH_SIZE)]
286
+ with Pool(processes=cpu_count()) as pool:
287
+ list(
288
+ tqdm(
289
+ pool.imap(ingest_nodes_batch, node_batches),
290
+ total=len(node_batches),
291
+ desc="Ingesting Nodes",
292
+ )
293
+ )
294
+
295
+ # Multiprocess relationship ingestion
296
+ print("Starting Relationship Ingestion...")
297
+ relationship_batches = [
298
+ relationships[i : i + BATCH_SIZE]
299
+ for i in range(0, len(relationships), BATCH_SIZE)
300
+ ]
301
+ with Pool(processes=cpu_count()) as pool:
302
+ list(
303
+ tqdm(
304
+ pool.imap(ingest_relationships_batch, relationship_batches),
305
+ total=len(relationship_batches),
306
+ desc="Ingesting Relationships",
307
+ )
308
+ )
309
+
310
+
311
+ def ingest_nodes_batch(batch):
312
+ with GraphDatabase.driver(NEO4J_URI, auth=(NEO4J_USER, NEO4J_PASSWORD)) as driver:
313
+ with driver.session() as session:
314
+ for node in batch:
315
+ try:
316
+ label = node["labels"][0] # Assumes a single label per node
317
+ query = f"""
318
+ MERGE (n:{label} {{globalId: $globalId}})
319
+ SET n += $properties
320
+ """
321
+ session.run(
322
+ query,
323
+ globalId=node["properties"]["globalId"],
324
+ properties=node["properties"],
325
+ )
326
+ except Exception as e:
327
+ print(
328
+ f"Error ingesting node with globalId {node['properties']['globalId']}: {e}"
329
+ )
330
+
331
+
332
+ def ingest_relationships_batch(batch):
333
+ with GraphDatabase.driver(NEO4J_URI, auth=(NEO4J_USER, NEO4J_PASSWORD)) as driver:
334
+ with driver.session() as session:
335
+ for relationship in batch:
336
+ try:
337
+ rel_type = relationship[
338
+ "label"
339
+ ] # Use the label for the relationship
340
+ query = f"""
341
+ MATCH (start {{globalId: $start_globalId}})
342
+ MATCH (end {{globalId: $end_globalId}})
343
+ MERGE (start)-[r:{rel_type}]->(end)
344
+ """
345
+ session.run(
346
+ query,
347
+ start_globalId=relationship["start"]["properties"]["globalId"],
348
+ end_globalId=relationship["end"]["properties"]["globalId"],
349
+ )
350
+ except Exception as e:
351
+ print(
352
+ f"Error ingesting relationship with label {relationship['label']}: {e}"
353
+ )
354
+
355
+
356
+ if __name__ == "__main__":
357
+ # Path to the JSON file
358
+ JSON_FILE_PATH = "<path-to-your-graph.json>"
359
+
360
+ # Run the ingestion process
361
+ ingest_data(JSON_FILE_PATH)
362
 
 
 
 
 
363
  ```
364
 
365
  ### 2. GraphML
 
503
  ```bibtex
504
  @misc {nasa_goddard_earth_sciences_data_and_information_services_center__(ges-disc)_2024,
505
  author = { {NASA Goddard Earth Sciences Data and Information Services Center (GES-DISC)} },
506
+ title = { nasa-eo-knowledge-graph },
507
  year = 2024,
508
  url = { https://huggingface.co/datasets/nasa-gesdisc/nasa-eo-knowledge-graph },
509
  doi = { 10.57967/hf/3463 },