adaptai / platform /aiml /etl /test_emergency_knowledge.py
ADAPT-Chase's picture
Add files using upload-large-folder tool
42bba47 verified
#!/usr/bin/env python3
"""
TEST EMERGENCY KNOWLEDGE - ELIZABETH READY
Verify scraped knowledge is test-ready
Aurora - ETL Systems Specialist
"""
import json
from pathlib import Path
def test_emergency_knowledge():
"""Test the emergency scraped knowledge"""
knowledge_dir = Path("/data/adaptai/corpus-data/emergency-knowledge")
print("πŸ§ͺ TESTING EMERGENCY KNOWLEDGE ACQUISITION")
print("=" * 50)
# Find latest files
json_files = list(knowledge_dir.glob("emergency_*.json"))
if not json_files:
print("❌ No emergency knowledge files found!")
return False
# Load and test each file
total_items = 0
categories = set()
for file_path in json_files:
if 'summary' in file_path.name:
continue
print(f"\nπŸ“„ Testing: {file_path.name}")
try:
with open(file_path, 'r', encoding='utf-8') as f:
data = json.load(f)
if isinstance(data, list):
# Multiple items
item_count = len(data)
print(f" Items: {item_count}")
total_items += item_count
if data:
# Check first item structure
first_item = data[0]
if 'title' in first_item and 'content' in first_item:
print(f" βœ… Structure: Valid")
print(f" πŸ“– Sample: {first_item.get('title', 'No title')[:50]}...")
categories.add(first_item.get('category', 'unknown'))
else:
print(f" ❌ Structure: Invalid")
else:
# Single item
total_items += 1
print(f" Items: 1")
if 'title' in data and 'content' in data:
print(f" βœ… Structure: Valid")
print(f" πŸ“– Sample: {data.get('title', 'No title')[:50]}...")
categories.add(data.get('category', 'unknown'))
else:
print(f" ❌ Structure: Invalid")
except Exception as e:
print(f" ❌ Error loading {file_path}: {e}")
# Load latest summary dynamically
summary_files = sorted(knowledge_dir.glob("emergency_summary_*.json"), key=lambda p: p.stat().st_mtime, reverse=True)
if summary_files:
try:
with open(summary_files[0], 'r', encoding='utf-8') as f:
summary = json.load(f)
print(f"\nπŸ“Š SUMMARY: {summary.get('total_items', 'n/a')} total items")
cats = summary.get('categories_scraped') or summary.get('categories') or []
if isinstance(cats, dict):
cats = list(cats.keys())
if isinstance(cats, list):
print(f" Categories: {', '.join(cats)}")
except Exception as e:
print(f"\n⚠️ Failed to load summary: {e}")
print(f"\n🎯 KNOWLEDGE DOMAINS ACQUIRED:")
for category in categories:
print(f" β€’ {category.replace('_', ' ').title()}")
# Test readiness
print(f"\nβœ… TEST READINESS ASSESSMENT:")
if total_items >= 10:
print(" πŸ“ˆ Sufficient volume: YES")
else:
print(" πŸ“ˆ Sufficient volume: NO")
if any('payment' in cat for cat in categories):
print(" πŸ’³ Payment processing: YES")
else:
print(" πŸ’³ Payment processing: NO")
if any('tech' in cat or 'trend' in cat for cat in categories):
print(" πŸ€– Tech trends: YES")
else:
print(" πŸ€– Tech trends: NO")
print(f"\nπŸš€ ELIZABETH TEST READY: {'YES' if total_items >= 10 else 'NO'}")
return total_items >= 10
def main():
success = test_emergency_knowledge()
if success:
print("\nπŸŽ‰ EMERGENCY KNOWLEDGE VALIDATION PASSED")
print("=" * 50)
print("Elizabeth can now be tested with real-world knowledge!")
print("\nNext steps:")
print("1. Integrate with Elizabeth's knowledge base")
print("2. Run autonomous operation tests")
print("3. Verify payment processing understanding")
print("4. Test technical trend awareness")
else:
print("\n❌ EMERGENCY KNOWLEDGE VALIDATION FAILED")
print("Need more diverse knowledge acquisition")
if __name__ == "__main__":
main()