assemble_evidences

assemble_evidences(mappings: list[Mapping], *, progress: bool = True) list[Mapping][source]

Assemble evidences.

More specifically, this aggregates evidences for all subject-predicate-object triples into a single semra.Mapping instance.

Parameters:
  • mappings – An iterable of mappings

  • progress – Should a progress bar be shown? Defaults to true.

Returns:

A processed list of mappings, that is guaranteed to have exactly 1 Mapping object for each subject-predicate-object triple. Note that if the predicate is different, evidences are not assembled into the same Mapping object.

>>> from semra import Mapping, Reference, EXACT_MATCH
>>> from semra.api import get_test_evidence, get_test_reference
>>> r1, r2 = get_test_reference(2)
>>> e1, e2 = get_test_evidence(2)
>>> m1 = Mapping(subject=r1, predicate=EXACT_MATCH, object=r2, evidence=[e1])
>>> m2 = Mapping(subject=r1, predicate=EXACT_MATCH, object=r2, evidence=[e2])
>>> m = assemble_evidences([m1, m2])
>>> assert m == [Mapping(subject=r1, predicate=EXACT_MATCH, object=r2, evidence=[e1, e2])]