gateway/modules/features/realEstate/bzoRuleTaxonomy.py

111 lines
3.7 KiB
Python

"""
Rule taxonomy for BZO extraction.
Defines fixed rule types and their patterns for deterministic rule detection.
"""
RULE_TAXONOMY = {
"max_building_height": {
"patterns": ["fassadenhöhe", "fassadenhöhen", "gebäudehöhe", "firsthöhe", "traufhöhe", "höchsthöhe", "gesamt höhe", "gesamt höhen"],
"units": ["m", "meter", "metern"],
"value_type": "numeric",
"keywords": ["max", "maximal", "höchstens"]
},
"max_floors": {
"patterns": ["vollgeschosse", "vollgeschoss", "geschosse", "geschosszahl"],
"units": [],
"value_type": "integer",
"keywords": ["max", "maximal", "höchstens"]
},
"max_attachable_attics": {
"patterns": ["anrechenbare dachgeschosse", "anrechenbares attikageschoss", "dachgeschosse", "attikageschoss"],
"units": [],
"value_type": "integer",
"keywords": ["max", "maximal"]
},
"max_attachable_basement": {
"patterns": ["anrechenbares untergeschoss", "untergeschoss"],
"units": [],
"value_type": "integer",
"keywords": ["max", "maximal"]
},
"density": {
"patterns": ["ausnützungsziffer", "az", "ausnützung"],
"units": ["%", "prozent"],
"value_type": "numeric",
"keywords": ["max", "maximal"]
},
"building_coverage": {
"patterns": ["überbauungsziffer", "überbauungsziffer max", "uz"],
"units": ["%", "prozent"],
"value_type": "numeric",
"keywords": ["max", "maximal"]
},
"building_mass_index": {
"patterns": ["baumassenziffer", "bmz"],
"units": [],
"value_type": "numeric",
"keywords": ["max", "maximal"]
},
"green_space_index": {
"patterns": ["grünflächenziffer", "gfz"],
"units": ["%", "prozent"],
"value_type": "numeric",
"keywords": ["min", "mindestens"]
},
"boundary_distance": {
"patterns": ["grenzabstand", "grundabstand", "abstand"],
"units": ["m", "meter", "metern"],
"value_type": "numeric",
"keywords": ["min", "mindestens", "max", "maximal"]
},
"boundary_distance_length_surcharge": {
"patterns": ["mehrlängenzuschlag", "längenzuschlag"],
"units": [],
"value_type": "fraction", # e.g., "1/3", "1/5"
"keywords": []
},
"boundary_distance_max": {
"patterns": ["höchstmass", "höchstmass grenzabstand", "höchstmass abstand"],
"units": ["m", "meter"],
"value_type": "numeric",
"keywords": ["max", "maximal"]
},
"building_length": {
"patterns": ["gebäudelänge"],
"units": ["m", "meter"],
"value_type": "numeric",
"keywords": ["min", "mindestens", "max", "maximal"]
},
"building_width": {
"patterns": ["gebäudebreite"],
"units": ["m", "meter"],
"value_type": "numeric",
"keywords": ["min", "mindestens", "max", "maximal"]
},
"residential_area_share": {
"patterns": ["wohnflächenanteil", "wohnanteil"],
"units": ["%", "prozent"],
"value_type": "numeric",
"keywords": ["min", "mindestens", "max", "maximal"]
}
}
def get_rule_taxonomy() -> dict:
"""Get the rule taxonomy dictionary."""
return RULE_TAXONOMY
def get_rule_types() -> list:
"""Get list of all rule types."""
return list(RULE_TAXONOMY.keys())
def get_rule_patterns(rule_type: str) -> list:
"""Get patterns for a specific rule type."""
return RULE_TAXONOMY.get(rule_type, {}).get("patterns", [])
def get_rule_units(rule_type: str) -> list:
"""Get units for a specific rule type."""
return RULE_TAXONOMY.get(rule_type, {}).get("units", [])