GraphPairCombinator

class GraphPairCombinator[source]

Bases: ABC

A base class for combination of a graph pair into a single graph.

Methods Summary

__call__(left, right, alignment, **kwargs)

Combine two graphs using the alignment information.

process(mapped_triples, alignment, offsets)

Process the combined mapped triples.

Methods Documentation

__call__(left, right, alignment, **kwargs)[source]

Combine two graphs using the alignment information.

Parameters
  • left (TriplesFactory) – the triples of the left graph

  • right (TriplesFactory) – the triples of the right graph

  • alignment (DataFrame) – columns: LEFT | RIGHT the alignment, i.e., pairs of matching entities

  • kwargs – additional keyword-based parameters passed to TriplesFactory.__init__()

Return type

Tuple[TriplesFactory, LongTensor]

Returns

a single triples factory comprising the joint graph, as well as a tensor of pairs of matching IDs. The tensor of matching pairs has shape (2, num_alignments), where num_alignments can also be 0.

abstract process(mapped_triples, alignment, offsets)[source]

Process the combined mapped triples.

Parameters
  • mapped_triples (LongTensor) – shape: (n, 3) the id-based merged triples

  • alignment (LongTensor) – shape: (2, m) the id-based entity alignment

  • offsets (LongTensor) – shape: (2, 2) the entity and relation offsets from merging

Return type

ProcessedTuple

Returns

updated triples and alignment tensor, as well as parameters for updating label-to-id mappings