pub struct Classification { /* private fields */ }Expand description
The result of classify: every named concept’s entailed named
superclasses (transitively closed).
Implementations§
Source§impl Classification
impl Classification
Sourcepub fn subsumers(&self, concept: SctId) -> impl Iterator<Item = SctId> + '_
pub fn subsumers(&self, concept: SctId) -> impl Iterator<Item = SctId> + '_
Every concept concept is (transitively) subsumed by, per the
input axioms — strict: never includes concept itself,
mirroring SnapshotStore::ancestors’s convention. Empty for a
concept the axioms said nothing about.
Examples found in repository?
48fn main() {
49 let n: u64 = std::env::var("N")
50 .ok()
51 .and_then(|s| s.parse().ok())
52 .unwrap_or(370_000);
53 let mut rng = Rng(42);
54 let role = id(999_998);
55 let mut axioms = Vec::new();
56 for i in 2..=n {
57 let parent = 1 + rng.below(i - 1);
58 axioms.push(Axiom::SubClassOf {
59 sub: ClassExpression::Concept(id(1000 + i)),
60 sup: ClassExpression::Concept(id(1000 + parent)),
61 });
62 }
63 // 1 in 20 concepts also asserts an existential to a random earlier
64 // concept, exercising CR2/CR3 at scale.
65 for i in 2..=n {
66 if i % 20 == 0 {
67 let filler = 1 + rng.below(i - 1);
68 axioms.push(Axiom::SubClassOf {
69 sub: ClassExpression::Concept(id(1000 + i)),
70 sup: ClassExpression::ObjectSomeValuesFrom {
71 attribute: role,
72 filler: Box::new(ClassExpression::Concept(id(1000 + filler))),
73 },
74 });
75 }
76 }
77 axioms.push(Axiom::SubClassOf {
78 sub: ClassExpression::ObjectSomeValuesFrom {
79 attribute: role,
80 filler: Box::new(ClassExpression::Concept(id(1001))),
81 },
82 sup: ClassExpression::Concept(id(999_999)),
83 });
84
85 let start = Instant::now();
86 let report = classify(&axioms);
87 let elapsed = start.elapsed();
88 println!(
89 "N={n} axioms={} elapsed={elapsed:?} skipped={}",
90 axioms.len(),
91 report.skipped.len()
92 );
93 let mut total_subsumers = 0usize;
94 let mut max_subsumers = 0usize;
95 for i in 1..=n {
96 let count = report.classification.subsumers(id(1000 + i)).count();
97 total_subsumers += count;
98 max_subsumers = max_subsumers.max(count);
99 }
100 println!(
101 "avg subsumers/concept = {:.1}, max = {max_subsumers}",
102 total_subsumers as f64 / n as f64
103 );
104}Sourcepub fn is_subsumed_by(&self, sub: SctId, sup: SctId) -> bool
pub fn is_subsumed_by(&self, sub: SctId, sup: SctId) -> bool
Reflexive subsumption test: true when sub == sup or sup is
among sub’s entailed superclasses.
Sourcepub fn equivalent_to(&self, concept: SctId) -> impl Iterator<Item = SctId> + '_
pub fn equivalent_to(&self, concept: SctId) -> impl Iterator<Item = SctId> + '_
Concepts mutually subsuming concept (i.e. logically equivalent
under the input axioms) — excludes concept itself.
Sourcepub fn concepts(&self) -> impl Iterator<Item = SctId> + '_
pub fn concepts(&self) -> impl Iterator<Item = SctId> + '_
Every concept the input axioms said anything about — i.e. every
concept subsumers/is_subsumed_by/equivalent_to have a real
(possibly empty) answer for, not just concepts that happen to
appear somewhere as a filler. Order is unspecified.
Trait Implementations§
Source§impl Clone for Classification
impl Clone for Classification
Source§fn clone(&self) -> Classification
fn clone(&self) -> Classification
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more