56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script for Canadian ISIL parser.
|
|
|
|
Tests parsing of Canadian library records from LAC JSON files.
|
|
"""
|
|
|
|
import sys
|
|
import json
|
|
from pathlib import Path
|
|
from datetime import datetime
|
|
|
|
# Add src to Python path
|
|
sys.path.insert(0, str(Path(__file__).parent / "src"))
|
|
|
|
from glam_extractor.parsers.canadian_isil import CanadianISILParser
|
|
|
|
|
|
def main():
|
|
"""Test the Canadian ISIL parser"""
|
|
|
|
# Input file
|
|
input_file = Path("data/isil/canada/canadian_libraries_all.json")
|
|
|
|
if not input_file.exists():
|
|
print(f"Error: Input file not found: {input_file}")
|
|
return 1
|
|
|
|
# Parse records
|
|
parser = CanadianISILParser()
|
|
|
|
print(f"Parsing {input_file}...")
|
|
print("Testing with first 10 records...\n")
|
|
|
|
records = parser.parse_and_collect(input_file, max_records=10)
|
|
|
|
print(f"Successfully parsed {len(records)} records\n")
|
|
|
|
# Display samples
|
|
for i, record in enumerate(records[:3], 1):
|
|
print(f"--- Record {i} ---")
|
|
print(f"Name: {record.name}")
|
|
print(f"Type: {record.institution_type}")
|
|
print(f"Location: {record.locations[0].city}, {record.locations[0].region}")
|
|
print(f"GHCID: {record.ghcid_current}")
|
|
print(f"UUID: {record.ghcid_uuid}")
|
|
print(f"ISIL: {record.identifiers[0].identifier_value}")
|
|
print(f"Status: {record.organization_status}")
|
|
print(f"Data Tier: {record.provenance.data_tier}")
|
|
print()
|
|
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|