"""Ground calendar expressions in a predicted fact's literal source clause. Only interval fields are changed. Ambiguity, calendar periods and an invalid source cause abstention. A date elsewhere in the call is never borrowed. """ from copy import deepcopy from collections import Counter from datetime import datetime import re from .dates import normalize_dates, parse_anchor VERSION = "source-calendar-v2" ATTRIBUTES = frozenset({"service_state", "tariff", "ticket_status", "agreement"}) _BOUNDARY = re.compile(r"[!?;\n,]|(?