Mapping
EntityMapping(src_entity_iri, tgt_entity_iri, relation=DEFAULT_REL, score=0.0)
A datastructure for entity mapping.
Such entities should be named and have an IRI.
Attributes:
Name | Type | Description |
---|---|---|
src_entity_iri |
str
|
The IRI of the source entity, usually its IRI if available. |
tgt_entity_iri |
str
|
The IRI of the target entity, usually its IRI if available. |
relation |
str
|
A symbol that represents what semantic relation this mapping stands for. Defaults to |
score |
float
|
The score that indicates the confidence of this mapping. Defaults to |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src_entity_iri |
str
|
The IRI of the source entity, usually its IRI if available. |
required |
tgt_entity_iri |
str
|
The IRI of the target entity, usually its IRI if available. |
required |
relation |
str
|
A symbol that represents what semantic relation this mapping stands for. Defaults to |
DEFAULT_REL
|
score |
float
|
The score that indicates the confidence of this mapping. Defaults to |
0.0
|
Source code in src/deeponto/align/mapping.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
from_owl_objects(src_entity, tgt_entity, relation=DEFAULT_REL, score=0.0)
classmethod
Create an entity mapping from two OWLObject
entities which have an IRI.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src_entity |
OWLObject
|
The source entity in |
required |
tgt_entity |
OWLObject
|
The target entity in |
required |
relation |
str
|
A symbol that represents what semantic relation this mapping stands for. Defaults to |
DEFAULT_REL
|
score |
float
|
The score that indicates the confidence of this mapping. Defaults to |
0.0
|
Returns:
Type | Description |
---|---|
EntityMapping
|
The entity mapping created from the source and target entities. |
Source code in src/deeponto/align/mapping.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
to_tuple(with_score=False)
Transform an entity mapping (self
) to a tuple representation
Note that relation
is discarded and score
is optionally preserved).
Source code in src/deeponto/align/mapping.py
86 87 88 89 90 91 92 93 94 |
|
as_tuples(entity_mappings, with_score=False)
staticmethod
Transform a list of entity mappings to their tuple representations.
Note that relation
is discarded and score
is optionally preserved).
Source code in src/deeponto/align/mapping.py
96 97 98 99 100 101 102 |
|
sort_entity_mappings_by_score(entity_mappings, k=None)
staticmethod
Sort the entity mappings in a list by their scores in descending order.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entity_mappings |
List[EntityMapping]
|
A list entity mappings to sort. |
required |
k |
int
|
The number of top \(k\) scored entities preserved if specified. Defaults to |
None
|
Returns:
Type | Description |
---|---|
List[EntityMapping]
|
A list of sorted entity mappings. |
Source code in src/deeponto/align/mapping.py
104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
read_table_mappings(table_of_mappings_file, threshold=None, relation=DEFAULT_REL, is_reference=False)
staticmethod
Read entity mappings from .csv
or .tsv
files.
Mapping Table Format
The columns of the mapping table must have the headings: "SrcEntity"
, "TgtEntity"
, and "Score"
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table_of_mappings_file |
str
|
The path to the table ( |
required |
threshold |
Optional[float]
|
Mappings with scores less than |
None
|
relation |
str
|
A symbol that represents what semantic relation this mapping stands for. Defaults to |
DEFAULT_REL
|
is_reference |
bool
|
Whether the loaded mappings are reference mappigns; if so, |
False
|
Returns:
Type | Description |
---|---|
List[EntityMapping]
|
A list of entity mappings loaded from the table file. |
Source code in src/deeponto/align/mapping.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
ReferenceMapping(src_entity_iri, tgt_entity_iri, relation=DEFAULT_REL, candidate_mappings=[])
Bases: EntityMapping
A datastructure for entity mapping that acts as a reference mapping.
A reference mapppings is a ground truth entity mapping (with \(score = 1.0\)) and can
have several entity mappings as candidates. These candidate mappings should have the
same head
(i.e., source entity) as the reference mapping.
Attributes:
Name | Type | Description |
---|---|---|
src_entity_iri |
str
|
The IRI of the source entity, usually its IRI if available. |
tgt_entity_iri |
str
|
The IRI of the target entity, usually its IRI if available. |
relation |
str
|
A symbol that represents what semantic relation this mapping stands for. Defaults to |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src_entity_iri |
str
|
The IRI of the source entity, usually its IRI if available. |
required |
tgt_entity_iri |
str
|
The IRI of the target entity, usually its IRI if available. |
required |
relation |
str
|
A symbol that represents what semantic relation this mapping stands for. Defaults to |
DEFAULT_REL
|
candidate_mappings |
List[EntityMapping]
|
A list of entity mappings that are candidates for this reference mapping. Defaults to |
[]
|
Source code in src/deeponto/align/mapping.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
add_candidate(candidate_mapping)
Add a candidate mapping whose relation and head entity are the same as the reference mapping's.
Source code in src/deeponto/align/mapping.py
199 200 201 202 203 204 205 206 207 208 209 |
|
read_table_mappings(table_of_mappings_file, relation=DEFAULT_REL)
staticmethod
Read reference mappings from .csv
or .tsv
files.
Mapping Table Format
The columns of the mapping table must have the headings: "SrcEntity"
, "TgtEntity"
, and "Score"
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table_of_mappings_file |
str
|
The path to the table ( |
required |
relation |
str
|
A symbol that represents what semantic relation this mapping stands for. Defaults to |
DEFAULT_REL
|
Returns:
Type | Description |
---|---|
List[ReferenceMapping]
|
A list of reference mappings loaded from the table file. |
Source code in src/deeponto/align/mapping.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
|
SubsFromEquivMappingGenerator(src_onto, tgt_onto, equiv_mappings, subs_generation_ratio=None, delete_used_equiv_tgt_class=True)
Generating subsumption mappings from gold standard equivalence mappings.
paper
The online subsumption mapping construction algorithm is proposed in the paper: Machine Learning-Friendly Biomedical Datasets for Equivalence and Subsumption Ontology Matching (ISWC 2022).
This generator has an attribute delete_used_equiv_tgt_class
for determining whether or not to sabotage the equivalence
mappings used to create \(\geq 1\) subsumption mappings. The reason is that, if the equivalence mapping is broken, then the
OM tool is expected to predict subsumption mappings directly without relying on the equivalence mappings as an intermediate.
Attributes:
Name | Type | Description |
---|---|---|
src_onto |
Ontology
|
The source ontology. |
tgt_onto |
Ontology
|
The target ontology. |
equiv_class_pairs |
List[Tuple[str, str]]
|
A list of class pairs (in IRIs) that are equivalent according to the input equivalence mappings. |
subs_generation_ratio |
int
|
The maximum number of subsumption mappings generated from each equivalence
mapping. Defaults to |
delete_used_equiv_tgt_class |
bool
|
Whether to mark the target side of an equivalence mapping used for creating
at least one subsumption mappings as "deleted". Defaults to |
Source code in src/deeponto/align/mapping.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
|
online_construction()
An online algorithm for constructing subsumption mappings from gold standard equivalence mappings.
Let \(t\) denote the boolean value that indicates if the target class involved in an equivalence mapping will be deleted. If \(t\) is true, then for each equivalent class pair \((c, c')\), do the following:
- If \(c'\) has been inolved in a subsumption mapping, skip this pair as otherwise \(c'\) will need to be deleted.
- For each parent class of \(c'\), skip it if it has been marked deleted (i.e., involved in an equivalence mapping that has been used to create a subsumption mapping).
- If any subsumption mapping has been created from \((c, c')\), mark \(c'\) as deleted.
Steps 1 and 2 ensure that target classes that have been involved in a subsumption mapping have no conflicts with target classes that have been used to create a subsumption mapping.
This algorithm is online because the construction and deletion depend on the order of the input equivalent class pairs.
Source code in src/deeponto/align/mapping.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
|
save_subs(save_path)
Save the constructed subsumption mappings (in tuples) to a local .tsv
file.
Source code in src/deeponto/align/mapping.py
331 332 333 334 |
|
NegativeCandidateMappingGenerator(src_onto, tgt_onto, reference_class_mappings, annotation_property_iris, tokenizer, max_hops=5, for_subsumption=False)
Generating negative candidate mappings for each gold standard mapping.
Note that the source side of the golden standard mapping is fixed, i.e., candidate mappings are generated according to the target side.
paper
The candidate mapping generation algorithm is proposed in the paper: Machine Learning-Friendly Biomedical Datasets for Equivalence and Subsumption Ontology Matching (ISWC 2022).
Source code in src/deeponto/align/mapping.py
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
|
mixed_sample(reference_class_mapping, **strategy2nums)
A mixed sampling approach that combines several sampling strategies.
As introduced in the Bio-ML paper, this mixed approach guarantees that the number of samples for each strategy is either the maximum that can be sampled or the required number.
Specifically, at each sampling iteration, the number of candidates is first increased by the number of previously sampled candidates, as in the worst case, all the candidates sampled at this iteration will be duplicated with the previous.
The random sampling is used as the amending strategy, i.e., if other sampling strategies cannot retrieve the specified number of samples, then use random sampling to amend the number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reference_class_mapping |
ReferenceMapping
|
The reference class mapping for generating the candidate mappings. |
required |
**strategy2nums |
int
|
The keyword arguments that specify the expected number of candidates for each sampling strategy. |
{}
|
Source code in src/deeponto/align/mapping.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
|
random_sample(reference_class_mapping, num_candidates)
Randomly sample a set of target class candidates \(c'_{cand}\) for a given reference mapping \((c, c')\).
The sampled candidate classes will be combined with the source reference class \(c\) to get a set of candidate mappings \(\{(c, c'_{cand})\}\).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reference_class_mapping |
ReferenceMapping
|
The reference class mapping for generating the candidate mappings. |
required |
num_candidates |
int
|
The expected number of candidate mappings to generate. |
required |
Source code in src/deeponto/align/mapping.py
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 |
|
idf_sample(reference_class_mapping, num_candidates)
Sample a set of target class candidates \(c'_{cand}\) for a given reference mapping \((c, c')\) based on the \(idf\) scores w.r.t. the inverted annotation index (sub-word level).
Candidate classes with higher \(idf\) scores will be considered first, and then combined with the source reference class \(c\) to get a set of candidate mappings \(\{(c, c'_{cand})\}\).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reference_class_mapping |
ReferenceMapping
|
The reference class mapping for generating the candidate mappings. |
required |
num_candidates |
int
|
The expected number of candidate mappings to generate. |
required |
Source code in src/deeponto/align/mapping.py
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
|
neighbour_sample(reference_class_mapping, num_candidates)
Sample a set of target class candidates \(c'_{cand}\) for a given reference mapping \((c, c')\) based on the subsumption hierarchy.
Define one-hop as one edge derived from an asserted subsumption axiom, i.e., to the parent class or the child class. Candidates classes with nearer hops will be considered first, and then combined with the source reference class \(c\) to get a set of candidate mappings \(\{(c, c'_{cand})\}\).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reference_class_mapping |
ReferenceMapping
|
The reference class mapping for generating the candidate mappings. |
required |
num_candidates |
int
|
The expected number of candidate mappings to generate. |
required |
Source code in src/deeponto/align/mapping.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 |
|
Created: January 14, 2023