File size: 1,516 Bytes
1f4dedc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""

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...")

# Define all possible NER tags for the 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",
]

# Manually define the features object for robustness
features = Features({
    'id': Value('string'),
    'tokens': Sequence(Value('string')),
    'ner_tags': Sequence(ClassLabel(names=NER_TAGS))
})

try:
    # Load the JSON files directly using the manually defined features
    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.")