| | """
|
| | Test script to load and verify the converted JSONL dataset.
|
| |
|
| | Author: Amir Safari
|
| | Date: 17.10.2025
|
| |
|
| | This script loads the converted JSONL files (train.jsonl, dev.jsonl, test.jsonl)
|
| | and verifies they can be properly loaded with the HuggingFace datasets library.
|
| | """
|
| | from datasets import load_dataset, Features, Value, Sequence, ClassLabel
|
| |
|
| | print("Attempting to load the converted JSONL dataset...")
|
| |
|
| |
|
| | NER_TAGS = [
|
| | "O", "B-Taxon", "I-Taxon", "B-Geographical_Location", "I-Geographical_Location",
|
| | "B-Habitat", "I-Habitat", "B-Temporal_Expression", "I-Temporal_Expression",
|
| | "B-Person", "I-Person",
|
| | ]
|
| |
|
| |
|
| | features = Features({
|
| | 'id': Value('string'),
|
| | 'tokens': Sequence(Value('string')),
|
| | 'ner_tags': Sequence(ClassLabel(names=NER_TAGS))
|
| | })
|
| |
|
| | try:
|
| |
|
| | dataset = load_dataset("json", data_files={
|
| | "train": "train.jsonl",
|
| | "validation": "dev.jsonl",
|
| | "test": "test.jsonl"
|
| | }, features=features)
|
| |
|
| | print("\n✅ Success! The dataset was loaded correctly.")
|
| | print("Here is the loaded dataset info:")
|
| | print(dataset)
|
| |
|
| | print("\nHere's the first training example:")
|
| | print(dataset["train"][0])
|
| |
|
| | except Exception as e:
|
| | print(f"\n❌ An error occurred: {e}")
|
| | print("Please make sure the 'train.jsonl', 'dev.jsonl', and 'test.jsonl' files exist.") |