.
This commit is contained in:
+38
-25
@@ -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>,
|
||||
|
||||
Reference in New Issue
Block a user