This commit is contained in:
Alex Wied
2026-06-29 23:10:22 -04:00
parent 59c8dffb01
commit 5cea8e8307
7 changed files with 129 additions and 115 deletions
+14 -4
View File
@@ -214,18 +214,28 @@ fedora:lastModifiedBy rdf:type owl:NamedIndividual ;
### http://www.w3.org/1999/02/22-rdf-syntax-ns#Property
rdf:Property rdf:type owl:NamedIndividual ;
:associatedProperty :comment ,
:label ;
:associatedProperty rdfs:comment ,
rdfs:label ;
:catalogId "0"^^xsd:nonNegativeInteger .
### http://www.w3.org/2000/01/rdf-schema#Class
rdfs:Class rdf:type owl:NamedIndividual ;
:associatedProperty :comment ,
:label ;
:associatedProperty rdfs:comment ,
rdfs:label ;
:catalogId "1"^^xsd:nonNegativeInteger .
### http://www.w3.org/2000/01/rdf-schema#comment
rdfs:comment rdf:type owl:NamedIndividual ;
:indexedByField :comment .
### http://www.w3.org/2000/01/rdf-schema#label
rdfs:label rdf:type owl:NamedIndividual ;
:indexedByField :label .
### http://www.w3.org/ns/ldp#BasicContainer
ldp:BasicContainer rdf:type owl:NamedIndividual ;
:readOnly "true"^^xsd:boolean .
+38 -25
View File
@@ -135,10 +135,12 @@ impl OntologyBuilder {
PREFIX gl: <https://graphofliberty.org/2026/04/ont/>
SELECT DISTINCT ?subject ?name ?label {
?subject a gl:IndexField ;
gl:fieldName ?name ;
gl:fieldLabel ?label .
FILTER (langMATCHES(LANG(?label), "en") || !hasLANG(?label))
GRAPH ?graph {
?subject a gl:IndexDocumentField ;
gl:fieldName ?name ;
gl:fieldLabel ?label .
FILTER (langMATCHES(LANG(?label), "en") || !hasLANG(?label))
}
}"#,
)
.expect("Unable to parse field query");
@@ -195,7 +197,7 @@ SELECT ?class {{
#[derive(Clone, Debug)]
pub struct LabeledIri {
pub iri: NamedNode,
pub label: String,
pub label: Option<String>,
pub comment: Option<String>,
}
@@ -207,18 +209,10 @@ impl PartialEq for LabeledIri {
impl Display for LabeledIri {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.label.clone())
write!(f, "{}", self.label.clone().unwrap_or_default())
}
}
#[derive(Clone, Debug)]
pub struct IriInformation {
pub type_: NamedNode,
pub label: Option<String>,
pub comment: Option<String>,
pub read_only: bool,
}
#[derive(Clone, Debug)]
pub struct Entity {
pub label: String,
@@ -302,11 +296,39 @@ impl Ontology {
.map(|entity| entity.catalog_id)
}
pub fn individuals(&self, class: &NamedNode) -> impl Iterator<Item = NamedNode> {
self.store
.quads_for_pattern(None, Some(rdf::TYPE), Some(class.into()), None)
.filter_map(Result::ok)
.filter_map(|quad|
if let NamedOrBlankNode::NamedNode(subject) = quad.subject {
Some(subject)
} else { None })
}
pub fn info(&self, iri: &NamedNode) -> LabeledIri {
let label = self.store.quads_for_pattern(Some(iri.as_ref().into()), Some(rdfs::LABEL), None, None)
.filter_map(Result::ok)
.filter_map(|quad| conversion::term_to_string(&quad.object).map(String::from))
.next();
let comment = self.store.quads_for_pattern(Some(iri.as_ref().into()), Some(rdfs::COMMENT), None, None)
.filter_map(Result::ok)
.filter_map(|quad| conversion::term_to_string(&quad.object).map(String::from))
.next();
LabeledIri {
iri: iri.clone(),
label,
comment,
}
}
pub fn labeled_entity(&self, class: &NamedNode) -> Option<LabeledIri> {
self.entities.get(class)
.map(|entity| LabeledIri {
iri: class.to_owned(),
label: entity.label.to_owned(),
label: Some(entity.label.to_owned()),
comment: entity.comment.to_owned(),
})
}
@@ -315,15 +337,11 @@ impl Ontology {
self.entities.iter()
.map(|(iri, entity)| LabeledIri {
iri: iri.to_owned(),
label: entity.label.to_owned(),
label: Some(entity.label.to_owned()),
comment: entity.comment.to_owned(),
})
}
pub fn entities(&self) -> impl Iterator<Item = (&NamedNode, &Entity)> {
self.entities.iter()
}
pub fn datatypes(&self) -> impl Iterator<Item = NamedNode> {
self.store
.quads_for_pattern(
@@ -354,11 +372,6 @@ impl Ontology {
.count() >= 1
}
/*pub fn for_each_annotated_(&self) -> impl Iterator<Item = TripleRef<'_>> {
self.store
.quads_for_pattern()
}*/
pub fn template_triples<'a>(
&'a self,
class: NamedNodeRef<'a>,