RandomizedCleaner

class RandomizedCleaner[source]

Bases: Cleaner

Cleanup a triples array by randomly selecting testing triples and recalculate to minimize moves.

  1. Calculate move_id_mask as in _prepare_cleanup()

  2. Choose a triple to move, recalculate move_id_mask

  3. Continue until move_id_mask has no true bits

Methods Summary

cleanup_pair(reference, other, random_state)

Clean up one set of triples with respect to a reference set.

Methods Documentation

cleanup_pair(reference: Tensor, other: Tensor, random_state: None | int | Generator) tuple[Tensor, Tensor][source]

Clean up one set of triples with respect to a reference set.

Parameters:
  • reference (Tensor) – the reference set of triples, which shall contain triples for all entities

  • other (Tensor) – the other set of triples

  • random_state (None | int | Generator) – the random state to use, if any randomized operations take place

Returns:

a pair (reference, other), where some triples of other may have been moved into reference

Return type:

tuple[Tensor, Tensor]