23 lines
693 B
Python
23 lines
693 B
Python
from collections.abc import Collection, Mapping
|
|
from typing import Any
|
|
|
|
|
|
def build_answer_info(
|
|
scores: Mapping[str, str],
|
|
present_labels: Collection[str],
|
|
rendered_labels: Collection[str],
|
|
touched: Mapping[str, bool] | None = None,
|
|
) -> dict[str, dict[str, Any]]:
|
|
"""Describe every question using the answers actually compiled for a copy."""
|
|
present = set(present_labels)
|
|
rendered = set(rendered_labels)
|
|
return {
|
|
label: {
|
|
"present": label in present,
|
|
"not_empty": label in rendered,
|
|
"touched": (touched or {}).get(label, False),
|
|
"score": score,
|
|
}
|
|
for label, score in scores.items()
|
|
}
|