ontometer_corpus.ontology_metrics¶
Per-ontology metric table: structure, coupling and reuse-network position.
One row per latest, parsed ontology (index node, the network's node id),
joining what the corpus tables measure separately:
corpus.db
counts per ontology (triples, classes, properties, individuals, SKOS
concepts), kind and home_registry.
structural_metrics.parquet, term_coupling.parquet
hierarchy shape, term-level coupling and restrictions, each keyed by raw-byte
file_hash.
network_nodes / network_edges
the dependency network, read in its logical-reuse view (:func:logical_view)
with SKOS-dominated sources removed (:func:load_views).
Derived columns follow fixed rules: a ratio is undefined (NaN) where its
denominator is, except that a value which is genuinely zero is kept as zero
(a flat ontology's branching factor, the coupling of an ontology that borrows
no domain term). Own-vs-external measures are undefined for an ontology that
declares no ontology IRI: most own no namespace, so every term would count as
external. Network columns are NaN for SKOS-dominated rows, which are not in the
network view; :func:structural_population drops those rows.
Attributes¶
METRIC_LABELS = {'triple_count': 'Triple count', 'class_count': 'Class count', 'property_count': 'Property count', 'instance_count': 'Individual count', 'entity_count': 'Entity count', 'n_nodes': 'Hierarchy size', 'schema_density': 'Schema density', 'axiom_density_triples': 'Axiom density (triples)', 'axiom_density_logical': 'Axiom density (logical statements)', 'mean_depth_long': 'Mean depth (longest)', 'mean_depth_short': 'Mean depth (shortest)', 'depth_skew': 'Depth skew', 'branching': 'Branching factor', 'orphan_rate': 'Orphan-class rate', 'cycle_rate': 'Cycle rate', 'multiple_inheritance_rate': 'Multiple-inheritance rate', 'restriction_density': 'Restriction density', 'coupling_ratio': 'Coupling ratio', 'coupling_ratio_logical': 'Coupling ratio (logical use)', 'reuse_intensity': 'External-term reuse intensity', 'reuse_distinctiveness': 'Reuse distinctiveness (mean IDF)', 'in_degree': 'In-degree', 'out_degree': 'Out-degree', 'idf_out_degree': 'IDF-weighted out-degree', 'idf_in_degree': 'IDF-weighted in-degree', 'betweenness': 'Betweenness', 'pagerank': 'PageRank', 'external_dependency_ratio': 'External dependency ratio'}
module-attribute
¶
DESCRIPTIVE_METRICS = ('triple_count', 'class_count', 'property_count', 'instance_count', 'entity_count', 'schema_density', 'axiom_density_triples', 'axiom_density_logical', 'coupling_ratio', 'n_nodes', 'mean_depth_long', 'mean_depth_short', 'branching', 'depth_skew', 'cycle_rate', 'multiple_inheritance_rate', 'orphan_rate', 'restriction_density', 'reuse_intensity')
module-attribute
¶
NETWORK_METRICS = ('in_degree', 'out_degree', 'idf_out_degree', 'betweenness', 'pagerank', 'external_dependency_ratio')
module-attribute
¶
CENTRALITY_DIGITS = 12
module-attribute
¶
DEPTH_SKEW_MIN_NODES = 50
module-attribute
¶
Classes¶
NetworkViews
dataclass
¶
The dependency network as the metrics read it.
g_all keeps every usage edge; g is the logical-reuse view. Both
have SKOS-dominated sources removed, and external targets only those
referenced. Every edge of both carries idf_weight.
Source code in ontometer_corpus/ontology_metrics.py
Functions:¶
latest_files(paths)
¶
file_hash, kind and ontology_iri of every latest, parsed file.
Source code in ontometer_corpus/ontology_metrics.py
drop_skos_dominated(g, files)
¶
Remove SKOS-dominated corpus sources, and externals left unreferenced; returns how many.
Source code in ontometer_corpus/ontology_metrics.py
is_logical_edge(d)
¶
An import, or a usage edge with at least one logically used domain-vocabulary term.
Source code in ontometer_corpus/ontology_metrics.py
logical_view(g_all)
¶
The logical-reuse view of g_all: every node, logical edges only, orphan externals dropped.
Source code in ontometer_corpus/ontology_metrics.py
attach_idf(g, n_corpus)
¶
Set idf_weight = log(n_corpus / df(target)) on every edge.
df counts the distinct ontologies referencing the target, so an import
and a usage edge between one pair count once. Near 0 for a target almost
every ontology cites, largest for one only a single ontology cites.
Source code in ontometer_corpus/ontology_metrics.py
load_views(paths, files=None)
¶
Load the network, drop SKOS-dominated sources, and build both IDF-weighted views.
Source code in ontometer_corpus/ontology_metrics.py
logical_namespaces(paths)
¶
Per file, the domain vocabularies it uses logically (at least one logically used term).
Source code in ontometer_corpus/ontology_metrics.py
external_ratio(n, g, ns_by_file, no_iri_nodes)
¶
Share of the vocabularies n uses (ns_by_file) that g resolves to another ontology.
NaN for an ontology without an ontology IRI, or that uses no vocabulary.
Source code in ontometer_corpus/ontology_metrics.py
network_measures(views, ns_by_file)
¶
Per corpus ontology, its position in the logical-reuse view.
Degrees count edges of the multigraph (an import and a usage edge between
one pair count twice), out to external targets too. Betweenness runs on
the corpus subgraph, PageRank on it collapsed to one link per pair.
reuse_distinctiveness is the mean IDF of all out-edges and
external_dependency_ratio the breadth of reuse; both are NaN for an
ontology with no out-edge (0 would claim it reuses only generic targets).
Source code in ontometer_corpus/ontology_metrics.py
add_derived_metrics(df)
¶
Add the derived columns to a frame of raw counts and joined table columns (in place).
Source code in ontometer_corpus/ontology_metrics.py
build_ontology_metrics(paths, views=None)
¶
The per-ontology metric table (see the module docstring), indexed by node.
Source code in ontometer_corpus/ontology_metrics.py
structural_population(df)
¶
The rows the structural analyses use: SKOS-dominated sources left out.
load_ontology_metrics(paths)
¶
Read ontology_metrics.parquet (written by ontometer-corpus ontology-metrics).
Raises:
| Type | Description |
|---|---|
ReleaseError
|
the corpus directory holds tables of another format. |