|
|
|
|
|
""" |
|
|
Test script to debug the rapid fix logic with detailed step logging |
|
|
""" |
|
|
|
|
|
|
|
|
SAMPLE_INVALID_RDF = """<?xml version="1.0" encoding="UTF-8"?> |
|
|
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
|
|
xmlns:bf="http://id.loc.gov/ontologies/bibframe/"> |
|
|
<bf:Work rdf:about="http://example.org/work/invalid-1"> |
|
|
<rdf:type rdf:resource="http://id.loc.gov/ontologies/bibframe/Text"/> |
|
|
<bf:title>Incomplete Title</bf:title> |
|
|
</bf:Work> |
|
|
</rdf:RDF>""" |
|
|
|
|
|
|
|
|
SAMPLE_VALIDATION_ERRORS = """ |
|
|
=== Module: MonographDCTAP/Monograph_Work_Text.tsv === |
|
|
Overridden Conforms: False |
|
|
Results (4): |
|
|
|
|
|
Validation Result: |
|
|
Message: Less than 1 values on Work->bf:language |
|
|
|
|
|
Validation Result: |
|
|
Message: Less than 1 values on Work->bf:content |
|
|
|
|
|
Validation Result: |
|
|
Message: Less than 1 values on Work->bf:adminMetadata |
|
|
|
|
|
Validation Result: |
|
|
Message: Less than 1 values on Title->bf:mainTitle |
|
|
""" |
|
|
|
|
|
print("=" * 80) |
|
|
print("π§ͺ TESTING RAPID FIX LOGIC") |
|
|
print("=" * 80) |
|
|
print("\nπ INPUT RDF:") |
|
|
print(SAMPLE_INVALID_RDF) |
|
|
print("\nβ VALIDATION ERRORS:") |
|
|
print(SAMPLE_VALIDATION_ERRORS) |
|
|
print("\n" + "=" * 80) |
|
|
print("π§ RUNNING RAPID FIX WITH DEBUG LOGGING") |
|
|
print("=" * 80) |
|
|
|
|
|
|
|
|
import sys |
|
|
import os |
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) |
|
|
|
|
|
try: |
|
|
from app import rapid_fix_missing_properties |
|
|
|
|
|
steps_log = [] |
|
|
|
|
|
result = rapid_fix_missing_properties( |
|
|
SAMPLE_INVALID_RDF, |
|
|
SAMPLE_VALIDATION_ERRORS, |
|
|
'monograph', |
|
|
steps_log=steps_log |
|
|
) |
|
|
|
|
|
print("\nπ STEP-BY-STEP LOG:") |
|
|
print("-" * 80) |
|
|
for step in steps_log: |
|
|
print(step) |
|
|
|
|
|
print("\n" + "=" * 80) |
|
|
if result: |
|
|
print("β
RAPID FIX PRODUCED OUTPUT:") |
|
|
print("=" * 80) |
|
|
print(result) |
|
|
print("\n" + "=" * 80) |
|
|
print("π ANALYSIS:") |
|
|
print("=" * 80) |
|
|
|
|
|
|
|
|
if "<bf:language>" in result and "<bf:language>" not in SAMPLE_INVALID_RDF: |
|
|
print("β
Added bf:language") |
|
|
if "<bf:content>" in result and "<bf:content>" not in SAMPLE_INVALID_RDF: |
|
|
print("β
Added bf:content") |
|
|
if "<bf:adminMetadata>" in result and "<bf:adminMetadata>" not in SAMPLE_INVALID_RDF: |
|
|
print("β
Added bf:adminMetadata") |
|
|
|
|
|
if "<bf:assigner>" in result: |
|
|
print(" β
AdminMetadata includes bf:assigner") |
|
|
else: |
|
|
print(" β AdminMetadata MISSING bf:assigner!") |
|
|
else: |
|
|
print("β RAPID FIX RETURNED None") |
|
|
print("=" * 80) |
|
|
|
|
|
except Exception as e: |
|
|
print(f"\nβ ERROR: {e}") |
|
|
import traceback |
|
|
traceback.print_exc() |
|
|
|