ontocast.tool.agg.match_common¶
Stateless helpers for RDF graph matching and evaluation.
Attributes¶
GENERIC_NAMESPACES = frozenset({'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'http://www.w3.org/2000/01/rdf-schema#', 'http://www.w3.org/2002/07/owl#', 'http://www.w3.org/2001/XMLSchema#'})
module-attribute
¶
SCHEMA_PREDICATES = frozenset({RDF.type, RDFS.subClassOf, RDFS.label, RDFS.comment})
module-attribute
¶
Classes¶
GraphEntityRef
dataclass
¶
Functions:¶
build_entity_match_candidates(predicted_entities, gt_entities, embeddings, *, similarity_threshold, pair_compatible)
¶
Source code in ontocast/tool/agg/match_common.py
collect_ontology_entities(triples)
¶
URIRefs that are class/concept/schema nodes (s/o), not relation predicates.
Source code in ontocast/tool/agg/match_common.py
compute_prf(true_positives, predicted_count, ground_truth_count)
¶
Precision, recall and F1, each None where it is undefined.
Precision is undefined with no predictions and recall with no ground truth; F1 is undefined when either is. Reporting zero instead would let an empty prediction pull a macro average down by its count, not its quality.
Source code in ontocast/tool/agg/match_common.py
cosine_similarity(left_vec, right_vec)
¶
Source code in ontocast/tool/agg/match_common.py
count_domain_entity_matches(entity_matches)
¶
Source code in ontocast/tool/agg/match_common.py
extract_entities(graph)
¶
Source code in ontocast/tool/agg/match_common.py
extract_instance_entities(graph)
¶
IRIs in subject or object position that are not ontology terms.
Predicates and schema vocabulary are excluded: entity metrics measure the individuals a graph identifies, not the vocabulary it uses.