Files
arsam 7ce14a3d2f Import source: axon/services/citations
Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality.
2026-09-18 23:06:30 +03:30

12 lines
429 B
Python

import re
from axon.models import SearchResult
_CITATION_RE = re.compile(r"\[(\d+)\]")
def validate_citations(report: str, sources: list[SearchResult]) -> tuple[int, list[int], bool]:
citations = sorted({int(match) for match in _CITATION_RE.findall(report)})
missing = [citation for citation in citations if citation < 1 or citation > len(sources)]
return len(citations), missing, not missing and bool(citations)