Update knowledge_base.py
Browse files- knowledge_base.py +208 -62
knowledge_base.py
CHANGED
|
@@ -1,110 +1,234 @@
|
|
| 1 |
# knowledge_base.py
|
| 2 |
|
| 3 |
-
import logging
|
| 4 |
-
|
| 5 |
-
# Configure logging
|
| 6 |
-
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 7 |
-
|
| 8 |
-
# Knowledge base containing structural damage information
|
| 9 |
KNOWLEDGE_BASE = {
|
| 10 |
"spalling": [
|
| 11 |
{
|
| 12 |
"severity": "Critical",
|
| 13 |
-
"description": "Severe concrete spalling with exposed reinforcement and section loss",
|
| 14 |
"repair_method": [
|
| 15 |
-
"Install temporary support",
|
| 16 |
"Remove deteriorated concrete",
|
| 17 |
"Clean and treat reinforcement",
|
| 18 |
-
"Apply
|
|
|
|
| 19 |
"Apply bonding agent",
|
| 20 |
-
"
|
|
|
|
| 21 |
],
|
| 22 |
-
"estimated_cost": "Very High ($15,000
|
| 23 |
"timeframe": "3-4 weeks",
|
| 24 |
"location": "Primary structural elements",
|
| 25 |
"required_expertise": "Structural Engineer + Specialist Contractor",
|
| 26 |
"immediate_action": "Evacuate area, install temporary support, prevent access",
|
| 27 |
-
"prevention": "Regular inspections, waterproofing, chloride protection"
|
| 28 |
},
|
| 29 |
{
|
| 30 |
-
"severity": "
|
| 31 |
-
"description": "Surface spalling with
|
| 32 |
"repair_method": [
|
| 33 |
-
"Remove
|
| 34 |
-
"
|
| 35 |
-
"Apply
|
|
|
|
| 36 |
"Surface treatment"
|
| 37 |
],
|
| 38 |
-
"estimated_cost": "
|
| 39 |
-
"timeframe": "
|
| 40 |
-
"location": "
|
| 41 |
-
"required_expertise": "
|
| 42 |
-
"immediate_action": "
|
| 43 |
-
"prevention": "
|
| 44 |
}
|
| 45 |
],
|
|
|
|
| 46 |
"reinforcement_corrosion": [
|
| 47 |
{
|
| 48 |
"severity": "Critical",
|
| 49 |
-
"description": "Severe corrosion with >30% section loss",
|
| 50 |
"repair_method": [
|
| 51 |
-
"
|
| 52 |
-
"Remove concrete",
|
| 53 |
-
"Replace reinforcement",
|
| 54 |
-
"
|
| 55 |
-
"
|
|
|
|
| 56 |
],
|
| 57 |
-
"estimated_cost": "Critical ($20,000
|
| 58 |
"timeframe": "4-6 weeks",
|
| 59 |
"location": "Load-bearing elements",
|
| 60 |
-
"required_expertise": "Senior Structural Engineer",
|
| 61 |
-
"immediate_action": "Immediate evacuation, emergency shoring",
|
| 62 |
-
"prevention": "Waterproofing, cathodic protection"
|
| 63 |
}
|
| 64 |
],
|
|
|
|
| 65 |
"structural_crack": [
|
| 66 |
{
|
| 67 |
"severity": "High",
|
| 68 |
-
"description": "
|
| 69 |
"repair_method": [
|
| 70 |
"Structural analysis",
|
|
|
|
| 71 |
"Epoxy injection",
|
| 72 |
"Carbon fiber reinforcement",
|
| 73 |
-
"
|
| 74 |
],
|
| 75 |
-
"estimated_cost": "High ($10,000-$
|
| 76 |
"timeframe": "2-4 weeks",
|
| 77 |
"location": "Primary structure",
|
| 78 |
"required_expertise": "Structural Engineer",
|
| 79 |
-
"immediate_action": "Install crack monitors,
|
| 80 |
-
"prevention": "Load management, joint maintenance"
|
| 81 |
}
|
| 82 |
],
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
{
|
| 85 |
"severity": "Medium",
|
| 86 |
-
"description": "Active water
|
| 87 |
"repair_method": [
|
| 88 |
-
"
|
| 89 |
-
"
|
| 90 |
-
"
|
| 91 |
-
"
|
|
|
|
| 92 |
],
|
| 93 |
-
"estimated_cost": "Medium ($5,000-$
|
| 94 |
-
"timeframe": "1-
|
| 95 |
"location": "Various",
|
| 96 |
"required_expertise": "Waterproofing Specialist",
|
| 97 |
-
"immediate_action": "
|
| 98 |
-
"prevention": "
|
| 99 |
}
|
| 100 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
"no_damage": [
|
| 102 |
{
|
| 103 |
"severity": "Low",
|
| 104 |
-
"description": "No significant structural issues",
|
| 105 |
"repair_method": [
|
| 106 |
"Regular inspection",
|
| 107 |
-
"
|
|
|
|
| 108 |
],
|
| 109 |
"estimated_cost": "Low ($500-$2,000)",
|
| 110 |
"timeframe": "1-2 days",
|
|
@@ -116,21 +240,43 @@ KNOWLEDGE_BASE = {
|
|
| 116 |
]
|
| 117 |
}
|
| 118 |
|
| 119 |
-
# Damage type metadata
|
| 120 |
DAMAGE_TYPES = {
|
| 121 |
0: {'name': 'spalling', 'risk': 'High', 'color': '#ff4d4d'},
|
| 122 |
1: {'name': 'reinforcement_corrosion', 'risk': 'Critical', 'color': '#800000'},
|
| 123 |
2: {'name': 'structural_crack', 'risk': 'High', 'color': '#ff6b6b'},
|
| 124 |
-
3: {'name': '
|
| 125 |
-
4: {'name': '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
}
|
| 127 |
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
|
|
|
| 1 |
# knowledge_base.py
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
KNOWLEDGE_BASE = {
|
| 4 |
"spalling": [
|
| 5 |
{
|
| 6 |
"severity": "Critical",
|
| 7 |
+
"description": "Severe concrete spalling with exposed reinforcement and significant section loss",
|
| 8 |
"repair_method": [
|
| 9 |
+
"Install temporary structural support",
|
| 10 |
"Remove deteriorated concrete",
|
| 11 |
"Clean and treat reinforcement",
|
| 12 |
+
"Apply rust inhibitor",
|
| 13 |
+
"Install additional reinforcement if needed",
|
| 14 |
"Apply bonding agent",
|
| 15 |
+
"Use high-strength repair mortar",
|
| 16 |
+
"Apply protective coating"
|
| 17 |
],
|
| 18 |
+
"estimated_cost": "Very High ($15,000-$25,000)",
|
| 19 |
"timeframe": "3-4 weeks",
|
| 20 |
"location": "Primary structural elements",
|
| 21 |
"required_expertise": "Structural Engineer + Specialist Contractor",
|
| 22 |
"immediate_action": "Evacuate area, install temporary support, prevent access",
|
| 23 |
+
"prevention": "Regular inspections, waterproofing, chloride protection, proper drainage"
|
| 24 |
},
|
| 25 |
{
|
| 26 |
+
"severity": "Moderate",
|
| 27 |
+
"description": "Surface spalling with minor reinforcement exposure",
|
| 28 |
"repair_method": [
|
| 29 |
+
"Remove loose concrete",
|
| 30 |
+
"Clean reinforcement",
|
| 31 |
+
"Apply rust inhibitor",
|
| 32 |
+
"Patch with repair mortar",
|
| 33 |
"Surface treatment"
|
| 34 |
],
|
| 35 |
+
"estimated_cost": "Moderate ($5,000-$15,000)",
|
| 36 |
+
"timeframe": "1-2 weeks",
|
| 37 |
+
"location": "Non-critical elements",
|
| 38 |
+
"required_expertise": "Concrete Repair Specialist",
|
| 39 |
+
"immediate_action": "Restrict access, document damage extent",
|
| 40 |
+
"prevention": "Surface sealants, regular maintenance"
|
| 41 |
}
|
| 42 |
],
|
| 43 |
+
|
| 44 |
"reinforcement_corrosion": [
|
| 45 |
{
|
| 46 |
"severity": "Critical",
|
| 47 |
+
"description": "Severe corrosion with >30% section loss and delamination",
|
| 48 |
"repair_method": [
|
| 49 |
+
"Install structural support",
|
| 50 |
+
"Remove contaminated concrete",
|
| 51 |
+
"Replace corroded reinforcement",
|
| 52 |
+
"Apply migrating corrosion inhibitor",
|
| 53 |
+
"Install cathodic protection",
|
| 54 |
+
"Reconstruct with high-performance concrete"
|
| 55 |
],
|
| 56 |
+
"estimated_cost": "Critical ($20,000-$50,000)",
|
| 57 |
"timeframe": "4-6 weeks",
|
| 58 |
"location": "Load-bearing elements",
|
| 59 |
+
"required_expertise": "Senior Structural Engineer + Corrosion Specialist",
|
| 60 |
+
"immediate_action": "Immediate evacuation, emergency shoring, detailed assessment",
|
| 61 |
+
"prevention": "Waterproofing, cathodic protection, chloride testing"
|
| 62 |
}
|
| 63 |
],
|
| 64 |
+
|
| 65 |
"structural_crack": [
|
| 66 |
{
|
| 67 |
"severity": "High",
|
| 68 |
+
"description": "Active cracks >5mm with possible structural implications",
|
| 69 |
"repair_method": [
|
| 70 |
"Structural analysis",
|
| 71 |
+
"Install crack monitors",
|
| 72 |
"Epoxy injection",
|
| 73 |
"Carbon fiber reinforcement",
|
| 74 |
+
"Surface sealing"
|
| 75 |
],
|
| 76 |
+
"estimated_cost": "High ($10,000-$30,000)",
|
| 77 |
"timeframe": "2-4 weeks",
|
| 78 |
"location": "Primary structure",
|
| 79 |
"required_expertise": "Structural Engineer",
|
| 80 |
+
"immediate_action": "Install crack monitors, restrict loads",
|
| 81 |
+
"prevention": "Load management, movement joint maintenance"
|
| 82 |
}
|
| 83 |
],
|
| 84 |
+
|
| 85 |
+
"foundation_settlement": [
|
| 86 |
+
{
|
| 87 |
+
"severity": "Critical",
|
| 88 |
+
"description": "Differential settlement causing structural distress",
|
| 89 |
+
"repair_method": [
|
| 90 |
+
"Geotechnical investigation",
|
| 91 |
+
"Underpinning",
|
| 92 |
+
"Pressure grouting",
|
| 93 |
+
"Install piles",
|
| 94 |
+
"Level structure",
|
| 95 |
+
"Repair resulting damage"
|
| 96 |
+
],
|
| 97 |
+
"estimated_cost": "Very High ($50,000-$150,000)",
|
| 98 |
+
"timeframe": "8-12 weeks",
|
| 99 |
+
"location": "Foundation",
|
| 100 |
+
"required_expertise": "Geotechnical Engineer + Structural Engineer",
|
| 101 |
+
"immediate_action": "Monitor movement, assess stability, restrict occupancy",
|
| 102 |
+
"prevention": "Soil investigation, proper drainage, regular monitoring"
|
| 103 |
+
}
|
| 104 |
+
],
|
| 105 |
+
|
| 106 |
+
"water_damage": [
|
| 107 |
{
|
| 108 |
"severity": "Medium",
|
| 109 |
+
"description": "Active water infiltration with material deterioration",
|
| 110 |
"repair_method": [
|
| 111 |
+
"Identify water source",
|
| 112 |
+
"Repair waterproofing",
|
| 113 |
+
"Improve drainage",
|
| 114 |
+
"Replace damaged materials",
|
| 115 |
+
"Install moisture barriers"
|
| 116 |
],
|
| 117 |
+
"estimated_cost": "Medium ($5,000-$15,000)",
|
| 118 |
+
"timeframe": "1-3 weeks",
|
| 119 |
"location": "Various",
|
| 120 |
"required_expertise": "Waterproofing Specialist",
|
| 121 |
+
"immediate_action": "Contain water, protect assets, document damage",
|
| 122 |
+
"prevention": "Regular maintenance, proper drainage, waterproofing inspection"
|
| 123 |
}
|
| 124 |
],
|
| 125 |
+
|
| 126 |
+
"delamination": [
|
| 127 |
+
{
|
| 128 |
+
"severity": "High",
|
| 129 |
+
"description": "Concrete layer separation with hollow areas",
|
| 130 |
+
"repair_method": [
|
| 131 |
+
"Remove delaminated concrete",
|
| 132 |
+
"Prepare surface",
|
| 133 |
+
"Apply bonding agent",
|
| 134 |
+
"Install repair material",
|
| 135 |
+
"Surface treatment"
|
| 136 |
+
],
|
| 137 |
+
"estimated_cost": "High ($8,000-$20,000)",
|
| 138 |
+
"timeframe": "2-3 weeks",
|
| 139 |
+
"location": "Concrete elements",
|
| 140 |
+
"required_expertise": "Concrete Repair Specialist",
|
| 141 |
+
"immediate_action": "Remove loose material, protect area",
|
| 142 |
+
"prevention": "Quality control during construction, proper curing"
|
| 143 |
+
}
|
| 144 |
+
],
|
| 145 |
+
|
| 146 |
+
"alkali_silica_reaction": [
|
| 147 |
+
{
|
| 148 |
+
"severity": "High",
|
| 149 |
+
"description": "Concrete deterioration due to ASR gel formation",
|
| 150 |
+
"repair_method": [
|
| 151 |
+
"Assess extent of ASR",
|
| 152 |
+
"Control moisture",
|
| 153 |
+
"Apply lithium treatment",
|
| 154 |
+
"Repair cracks",
|
| 155 |
+
"Install expansion joints"
|
| 156 |
+
],
|
| 157 |
+
"estimated_cost": "High ($15,000-$40,000)",
|
| 158 |
+
"timeframe": "3-5 weeks",
|
| 159 |
+
"location": "Concrete structure",
|
| 160 |
+
"required_expertise": "Materials Engineer + Structural Engineer",
|
| 161 |
+
"immediate_action": "Monitor expansion, assess strength",
|
| 162 |
+
"prevention": "Use non-reactive aggregates, low-alkali cement"
|
| 163 |
+
}
|
| 164 |
+
],
|
| 165 |
+
|
| 166 |
+
"freeze_thaw_damage": [
|
| 167 |
+
{
|
| 168 |
+
"severity": "Medium",
|
| 169 |
+
"description": "Surface scaling and internal cracking from freeze-thaw cycles",
|
| 170 |
+
"repair_method": [
|
| 171 |
+
"Remove damaged concrete",
|
| 172 |
+
"Install air-entrained concrete",
|
| 173 |
+
"Apply surface sealers",
|
| 174 |
+
"Improve drainage"
|
| 175 |
+
],
|
| 176 |
+
"estimated_cost": "Medium ($6,000-$12,000)",
|
| 177 |
+
"timeframe": "1-2 weeks",
|
| 178 |
+
"location": "Exposed concrete",
|
| 179 |
+
"required_expertise": "Concrete Repair Specialist",
|
| 180 |
+
"immediate_action": "Remove loose material, protect from moisture",
|
| 181 |
+
"prevention": "Air-entrained concrete, proper drainage, sealers"
|
| 182 |
+
}
|
| 183 |
+
],
|
| 184 |
+
|
| 185 |
+
"chemical_attack": [
|
| 186 |
+
{
|
| 187 |
+
"severity": "High",
|
| 188 |
+
"description": "Concrete deterioration from chemical exposure",
|
| 189 |
+
"repair_method": [
|
| 190 |
+
"Neutralize chemicals",
|
| 191 |
+
"Remove contaminated concrete",
|
| 192 |
+
"Install chemical-resistant coating",
|
| 193 |
+
"Apply protective overlay"
|
| 194 |
+
],
|
| 195 |
+
"estimated_cost": "High ($12,000-$25,000)",
|
| 196 |
+
"timeframe": "2-4 weeks",
|
| 197 |
+
"location": "Exposed surfaces",
|
| 198 |
+
"required_expertise": "Chemical Resistance Specialist",
|
| 199 |
+
"immediate_action": "Stop chemical exposure, neutralize area",
|
| 200 |
+
"prevention": "Chemical-resistant coatings, proper containment"
|
| 201 |
+
}
|
| 202 |
+
],
|
| 203 |
+
|
| 204 |
+
"fire_damage": [
|
| 205 |
+
{
|
| 206 |
+
"severity": "Critical",
|
| 207 |
+
"description": "Structural damage from high temperature exposure",
|
| 208 |
+
"repair_method": [
|
| 209 |
+
"Structural assessment",
|
| 210 |
+
"Remove damaged material",
|
| 211 |
+
"Reinforce structure",
|
| 212 |
+
"Replace fire protection",
|
| 213 |
+
"Reconstruct affected areas"
|
| 214 |
+
],
|
| 215 |
+
"estimated_cost": "Very High ($30,000-$100,000)",
|
| 216 |
+
"timeframe": "4-8 weeks",
|
| 217 |
+
"location": "Fire-affected areas",
|
| 218 |
+
"required_expertise": "Fire Damage Specialist + Structural Engineer",
|
| 219 |
+
"immediate_action": "Assess stability, prevent access",
|
| 220 |
+
"prevention": "Fire protection systems, regular inspections"
|
| 221 |
+
}
|
| 222 |
+
],
|
| 223 |
+
|
| 224 |
"no_damage": [
|
| 225 |
{
|
| 226 |
"severity": "Low",
|
| 227 |
+
"description": "No significant structural issues identified",
|
| 228 |
"repair_method": [
|
| 229 |
"Regular inspection",
|
| 230 |
+
"Routine maintenance",
|
| 231 |
+
"Document condition"
|
| 232 |
],
|
| 233 |
"estimated_cost": "Low ($500-$2,000)",
|
| 234 |
"timeframe": "1-2 days",
|
|
|
|
| 240 |
]
|
| 241 |
}
|
| 242 |
|
|
|
|
| 243 |
DAMAGE_TYPES = {
|
| 244 |
0: {'name': 'spalling', 'risk': 'High', 'color': '#ff4d4d'},
|
| 245 |
1: {'name': 'reinforcement_corrosion', 'risk': 'Critical', 'color': '#800000'},
|
| 246 |
2: {'name': 'structural_crack', 'risk': 'High', 'color': '#ff6b6b'},
|
| 247 |
+
3: {'name': 'foundation_settlement', 'risk': 'Critical', 'color': '#8b0000'},
|
| 248 |
+
4: {'name': 'water_damage', 'risk': 'Medium', 'color': '#4dabf7'},
|
| 249 |
+
5: {'name': 'delamination', 'risk': 'High', 'color': '#ff8c00'},
|
| 250 |
+
6: {'name': 'alkali_silica_reaction', 'risk': 'High', 'color': '#9932cc'},
|
| 251 |
+
7: {'name': 'freeze_thaw_damage', 'risk': 'Medium', 'color': '#20b2aa'},
|
| 252 |
+
8: {'name': 'chemical_attack', 'risk': 'High', 'color': '#dc143c'},
|
| 253 |
+
9: {'name': 'fire_damage', 'risk': 'Critical', 'color': '#b22222'},
|
| 254 |
+
10: {'name': 'no_damage', 'risk': 'Low', 'color': '#40c057'}
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
# Additional metadata for enhanced analysis
|
| 258 |
+
DAMAGE_METADATA = {
|
| 259 |
+
'spalling': {
|
| 260 |
+
'common_causes': ['Reinforcement corrosion', 'Freeze-thaw cycles', 'Poor concrete quality'],
|
| 261 |
+
'test_methods': ['Hammer sounding', 'GPR scanning', 'Core sampling'],
|
| 262 |
+
'environmental_factors': ['Chloride exposure', 'Carbonation', 'Moisture'],
|
| 263 |
+
'inspection_frequency': 'Every 6-12 months'
|
| 264 |
+
},
|
| 265 |
+
'reinforcement_corrosion': {
|
| 266 |
+
'common_causes': ['Chloride penetration', 'Carbonation', 'Poor concrete cover'],
|
| 267 |
+
'test_methods': ['Half-cell potential', 'Chloride testing', 'Resistivity measurement'],
|
| 268 |
+
'environmental_factors': ['Marine environment', 'De-icing salts', 'Industrial pollution'],
|
| 269 |
+
'inspection_frequency': 'Every 3-6 months'
|
| 270 |
+
},
|
| 271 |
+
# Add metadata for other damage types...
|
| 272 |
}
|
| 273 |
|
| 274 |
+
def get_damage_severity(damage_type: str, confidence: float) -> str:
|
| 275 |
+
"""Calculate damage severity based on type and confidence"""
|
| 276 |
+
base_risk = DAMAGE_TYPES[damage_type]['risk']
|
| 277 |
+
if confidence > 80:
|
| 278 |
+
return f"High {base_risk}"
|
| 279 |
+
elif confidence > 50:
|
| 280 |
+
return base_risk
|
| 281 |
+
else:
|
| 282 |
+
return f"Low {base_risk}"
|