Requirement Extraction
The extractor turns a renter message into RentalRequirements. It uses known
locations from the real cache so extraction does not invent unsupported places.
- class app.alba_core.extraction.ExtractionOutput(requirements: RentalRequirements, confidence: float, notes: list[str])[source]
Result returned by
RequirementExtractor.The output keeps requirements and explanation notes together so demos, tests, and future channel wrappers can show what Alba Core understood.
- class app.alba_core.extraction.RequirementExtractor(known_locations: Iterable[str])[source]
Deterministic extraction for common renter wording.
AI can be added later as a helper, but this class keeps the baseline repeatable and easy to test.
- extract(message: str, current: RentalRequirements | None = None) ExtractionOutput[source]
Extract requirements from a single message and merge prior state.
This method is intentionally a readable sequence of small extraction steps. When adding a new field, add the helper below and then call it in this flow so new contributors can see the full order at a glance.
Example
from app.alba_core.extraction import RequirementExtractor
from app.propertyme.cache import load_property_cache
properties = load_property_cache("data/propertyme_property_seed_latest.json")
known_locations = {
value
for item in properties
for value in [item.city, item.suburb, item.region]
if value
}
extractor = RequirementExtractor(known_locations)
output = extractor.extract("Auckland house, 4 bedrooms, budget 5k, move ASAP")
print(output.requirements.to_dict())
print(output.notes)
print(output.to_dict()["missing_required_fields"])
Continuing a conversation
from app.alba_core.models import RentalRequirements
current = RentalRequirements(city="Auckland", budget_max=5000)
output = extractor.extract("make it 4 bedrooms and a house", current=current)
print(output.requirements.to_dict())