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:
objectDataclass 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
-
ent_links:
ndarray¶ 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
-
attr_mapping:
- class sylloge.id_mapped.IdMappedTrainTestValSplit(train, test, val)[source]¶
Bases:
objectDataclass 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
-
test:
- class sylloge.id_mapped.PandasTrainTestValSplit(train, test, val)[source]¶
Bases:
objectDataclass 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
-
test:
- 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 mapmapping (
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 triplesentity_mapping (
Optional[Dict[str,int]]) – already mapped entitiesrel_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 tripleshead_map (
Mapping[str,int]) – mapping for head columnrel_map (
Mapping[str,int]) – mapping for rel columntail_map (
Mapping[str,int]) – mapping for tail column
- Return type:
ndarray- Returns:
integer id mapped triples
