IdMapped

class sylloge.id_mapped.IdMappedEADataset(rel_triples_left, rel_triples_right, attr_triples_left, attr_triples_right, ent_links, entity_mapping, rel_mapping, attr_rel_mapping, attr_mapping, folds=None)[source]

Bases: object

Dataclass holding information of the alignment class with mapping of string to numerical id.

attr_mapping: Dict[str, int]

attribute to id mapping for all attributes

attr_rel_mapping: Dict[str, int]

label to id mapping for all attribute relations

attr_triples_left: ndarray

attribute triples of left knowledge graph

attr_triples_right: ndarray

attribute triples of right knowledge graph

gold standard entity links of alignment

entity_mapping: Dict[str, int]

label to id mapping for all entities

folds: Optional[Sequence[IdMappedTrainTestValSplit]] = None

optional pre-split folds of the gold standard

rel_mapping: Dict[str, int]

label to id mapping for all relations

rel_triples_left: ndarray

relation triples of left knowledge graph

rel_triples_right: ndarray

relation triples of right knowledge graph

class sylloge.id_mapped.IdMappedTrainTestValSplit(train, test, val)[source]

Bases: object

Dataclass holding split of gold standard entity links.

test: ndarray

entity links for testing

train: ndarray

entity links for training

val: ndarray

entity links for validation

class sylloge.id_mapped.PandasTrainTestValSplit(train, test, val)[source]

Bases: object

Dataclass holding split of gold standard entity links.

test: DataFrame

entity links for testing

train: DataFrame

entity links for training

val: DataFrame

entity links for validation

sylloge.id_mapped.enhance_mapping(labels, mapping=None)[source]

Map labels with given mapping and enhance mapping if unseen labels are encountered.

Parameters:
  • labels (Iterable) – Labels to map

  • mapping (Optional[Mapping[str, int]]) – Know mappings

Return type:

Dict[str, int]

Returns:

Enhanced mapping

sylloge.id_mapped.id_map_rel_triples(df, entity_mapping=None, rel_mapping=None)[source]

Map entity and relation labels to ids and create numpy array.

Parameters:
  • df (DataFrame) – labeled triples

  • entity_mapping (Optional[Dict[str, int]]) – already mapped entities

  • rel_mapping (Optional[Dict[str, int]]) – already mapped relations

Return type:

Tuple[ndarray, Dict[str, int], Dict[str, int]]

Returns:

id-based numpy array triples, (updated) entity label to id mapping, (updated) relation label to id mapping

sylloge.id_mapped.perform_map(triples, head_map, rel_map, tail_map)[source]

Map str triples to int ids via dictionaries.

Parameters:
  • triples (ndarray) – string triples

  • head_map (Mapping[str, int]) – mapping for head column

  • rel_map (Mapping[str, int]) – mapping for rel column

  • tail_map (Mapping[str, int]) – mapping for tail column

Return type:

ndarray

Returns:

integer id mapped triples