remove_redundant_internal

remove_redundant_internal(mappings: Iterable[MappingTypeVar], *, key: Hasher[MappingTypeVar, HashTarget] | None = None, scorer: Scorer[MappingTypeVar] | None = None) list[MappingTypeVar][source]

Remove redundant mappings.

Parameters:
  • mappings – An iterable of mappings

  • key – A function that hashes the mappings. If not given, will only use the subject/object to has the mapping.

  • scorer – A function that gives a score to a given mapping, where a higher score means it’s more likely to be kept. Any function returning a comparable value can be used, but int/float are the easiest to understand.

Returns:

A list of mappings that have had duplicates dropped. This does not necessarily maintain order, since dictionary-based aggregation happens in the implementation.