unindex

unindex(index: dict[Triple, list[Annotated[ReasonedEvidence | SimpleEvidence, FieldInfo(annotation=NoneType, required=True, discriminator='evidence_type')]]], *, progress: bool = True) list[Mapping][source]

Convert a mapping index into a list of mapping objects.

Parameters:
  • index – A mapping from subject-predicate-object triples to lists of evidence objects

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

Returns:

A list of mapping objects

In the following example, a very simple index for a single mapping is used to reconstruct a mapping list.

>>> from semra.api import get_test_reference, get_test_evidence, unindex
>>> s, p, o = get_test_reference(3)
>>> e1 = get_test_evidence()
>>> index = {(s, p, o): [e1]}
>>> assert unindex(index) == [Mapping(subject=s, predicate=p, object=o, evidence=[e1])]