# knowledge_base.py import logging # Configure logging logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') # Knowledge base containing structural damage information KNOWLEDGE_BASE = { "spalling": [ { "severity": "Critical", "description": "Severe concrete spalling with exposed reinforcement and section loss", "repair_method": [ "Install temporary support", "Remove deteriorated concrete", "Clean and treat reinforcement", "Apply corrosion inhibitor", "Apply bonding agent", "High-strength repair mortar" ], "estimated_cost": "Very High ($15,000+)", "timeframe": "3-4 weeks", "location": "Primary structural elements", "required_expertise": "Structural Engineer + Specialist Contractor", "immediate_action": "Evacuate area, install temporary support, prevent access", "prevention": "Regular inspections, waterproofing, chloride protection" }, { "severity": "High", "description": "Surface spalling with visible reinforcement", "repair_method": [ "Remove damaged concrete", "Treat reinforcement", "Apply repair mortar", "Surface treatment" ], "estimated_cost": "High ($8,000-$15,000)", "timeframe": "2-3 weeks", "location": "Structural elements", "required_expertise": "Structural Engineer", "immediate_action": "Area isolation, temporary support assessment", "prevention": "Protective coatings, drainage improvement" } ], "reinforcement_corrosion": [ { "severity": "Critical", "description": "Severe corrosion with >30% section loss", "repair_method": [ "Structural support", "Remove concrete", "Replace reinforcement", "Corrosion protection", "Concrete repair" ], "estimated_cost": "Critical ($20,000+)", "timeframe": "4-6 weeks", "location": "Load-bearing elements", "required_expertise": "Senior Structural Engineer", "immediate_action": "Immediate evacuation, emergency shoring", "prevention": "Waterproofing, cathodic protection" } ], "structural_crack": [ { "severity": "High", "description": "Cracks >5mm in structural elements", "repair_method": [ "Structural analysis", "Epoxy injection", "Carbon fiber reinforcement", "Crack monitoring" ], "estimated_cost": "High ($10,000-$20,000)", "timeframe": "2-4 weeks", "location": "Primary structure", "required_expertise": "Structural Engineer", "immediate_action": "Install crack monitors, load restriction", "prevention": "Load management, joint maintenance" } ], "dampness": [ { "severity": "Medium", "description": "Active water penetration with efflorescence", "repair_method": [ "Water source identification", "Drainage improvement", "Waterproof membrane", "Ventilation" ], "estimated_cost": "Medium ($5,000-$10,000)", "timeframe": "1-2 weeks", "location": "Various", "required_expertise": "Waterproofing Specialist", "immediate_action": "Dehumidification, efflorescence cleaning", "prevention": "Proper drainage, vapor barriers" } ], "no_damage": [ { "severity": "Low", "description": "No significant structural issues", "repair_method": [ "Regular inspection", "Preventive maintenance" ], "estimated_cost": "Low ($500-$2,000)", "timeframe": "1-2 days", "location": "General", "required_expertise": "Building Inspector", "immediate_action": "Continue monitoring", "prevention": "Regular maintenance schedule" } ] } # Damage type metadata DAMAGE_TYPES = { 0: {'name': 'spalling', 'risk': 'High', 'color': '#ff4d4d'}, 1: {'name': 'reinforcement_corrosion', 'risk': 'Critical', 'color': '#800000'}, 2: {'name': 'structural_crack', 'risk': 'High', 'color': '#ff6b6b'}, 3: {'name': 'dampness', 'risk': 'Medium', 'color': '#4dabf7'}, 4: {'name': 'no_damage', 'risk': 'Low', 'color': '#40c057'} } # Validation for knowledge base required_keys = ['severity', 'description', 'repair_method', 'estimated_cost', 'timeframe', 'location', 'required_expertise', 'immediate_action', 'prevention'] for damage_type, cases in KNOWLEDGE_BASE.items(): for case in cases: for key in required_keys: if key not in case: logging.error(f"Missing required field '{key}' in {damage_type}") raise ValueError(f"Missing required field '{key}' in {damage_type}") logging.info("Knowledge base validation passed.")