36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
"""Compatibility imports for callers of the former Relative-only module.
|
|
|
|
All projection is now performed by :mod:`adapter`; this file has no separate
|
|
alignment calculation.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import numpy as np
|
|
|
|
from adapter import adapt_official_split
|
|
|
|
|
|
def project_modality(values: np.ndarray, modality: str, *, reported_length: int | None = None,
|
|
attention_mask: np.ndarray | None = None):
|
|
"""Legacy single-modality call, delegated to the unified projection kernel."""
|
|
from adapter.core import _relative_modality
|
|
from adapter.coordinates import relative_targets
|
|
from adapter.projection import project_intervals
|
|
|
|
record = {modality: values}
|
|
if modality == "text":
|
|
record["attention_mask"] = attention_mask
|
|
else:
|
|
record[f"{modality}_length"] = reported_length
|
|
item = _relative_modality(record, modality)
|
|
view = project_intervals(item.values, item.intervals, relative_targets(50),
|
|
item.observed, item.quality)
|
|
view.source_span = len(item.values)
|
|
view.reported_length = item.reported_length
|
|
view.length_conflict = item.length_conflict
|
|
view.tail_ambiguous = item.tail_ambiguous
|
|
return view
|
|
|
|
|
|
adapt_split = adapt_official_split
|