Enforce population estimate wording
This commit is contained in:
@@ -108,13 +108,27 @@ class GeoAssistantService:
|
||||
answer: str,
|
||||
metrics: list[AssistantContextMetric],
|
||||
) -> str:
|
||||
estimated_themes = {metric.theme for metric in metrics if metric.is_estimate}
|
||||
if "population" in estimated_themes:
|
||||
answer = re.sub(
|
||||
r"\bde officiële telling\b",
|
||||
"de van de officiële bron afgeleide schatting",
|
||||
answer,
|
||||
flags=re.IGNORECASE,
|
||||
)
|
||||
answer = re.sub(
|
||||
r"\bofficieel geteld aantal inwoners\b",
|
||||
"uit een officiële bron afgeleid aantal inwoners",
|
||||
answer,
|
||||
flags=re.IGNORECASE,
|
||||
)
|
||||
normalized = answer.casefold()
|
||||
if "schat" in normalized:
|
||||
return answer
|
||||
disclosed_themes = {
|
||||
metric.theme
|
||||
for metric in metrics
|
||||
if metric.is_estimate
|
||||
if metric.theme in estimated_themes
|
||||
and any(
|
||||
term in normalized
|
||||
for term in cls.ESTIMATE_TOPIC_TERMS.get(metric.theme, (metric.label.casefold(),))
|
||||
|
||||
Reference in New Issue
Block a user