.
This commit is contained in:
+1
-3
@@ -1,10 +1,8 @@
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Display;
|
||||
use oxigraph::model::{Graph, Literal, NamedNode, NamedNodeRef, NamedOrBlankNode, Term, TermRef, Triple};
|
||||
use oxigraph::model::{Graph, Literal, NamedNode, NamedNodeRef, NamedOrBlankNode, Term, Triple};
|
||||
use oxilangtag::LanguageTag;
|
||||
use url::Url;
|
||||
use gl_search::Schema;
|
||||
use crate::language::LanguageCondition;
|
||||
use crate::vocab;
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::LazyLock;
|
||||
use oxigraph::model::NamedNode;
|
||||
use url::Url;
|
||||
|
||||
const ONTOLOGY_PREFIX: &str = "https://graphofliberty.org/2026/04/ont/";
|
||||
@@ -87,7 +86,7 @@ impl CurieHelper {
|
||||
|
||||
absolute_iri.split_once(':')
|
||||
.and_then(|(prefix, name)| {
|
||||
if prefix == "" && let Some(base) = base {
|
||||
if prefix.is_empty() && let Some(base) = base {
|
||||
Some(format!("{base}{name}"))
|
||||
} else {
|
||||
self.prefixes
|
||||
|
||||
@@ -2,7 +2,6 @@ use rayon::iter::ParallelIterator;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use oxigraph::model::{Graph, NamedNode, TermRef, NamedOrBlankNodeRef, NamedNodeRef};
|
||||
use rayon::iter::IntoParallelRefIterator;
|
||||
use url::Url;
|
||||
use gl_search::{Field, OwnedValue, Schema};
|
||||
use crate::class::Class;
|
||||
use crate::{helpers, vocab, CurieHelper};
|
||||
@@ -90,7 +89,7 @@ impl<'a> Indexer<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
let results = entities_and_types.par_iter()
|
||||
entities_and_types.par_iter()
|
||||
.filter_map(|(subject, class)| {
|
||||
Class::try_from_named_node(*class).and_then(|class| {
|
||||
match class {
|
||||
@@ -114,9 +113,7 @@ impl<'a> Indexer<'a> {
|
||||
document
|
||||
})
|
||||
})
|
||||
}).collect();
|
||||
|
||||
results
|
||||
}).collect()
|
||||
}
|
||||
|
||||
pub fn ontology(&self, entities: HashMap<NamedNode, ResourceDescription>) -> Vec<HashMap<Field, OwnedValue>> {
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use std::env::var;
|
||||
use oxigraph::model::{Literal, TermRef};
|
||||
use oxilangtag::LanguageTag;
|
||||
use std::sync::LazyLock;
|
||||
use spargebra::algebra::{Expression, Function, GraphPattern};
|
||||
use spargebra::term::{NamedNode, NamedNodePattern, TermPattern, TriplePattern, Variable};
|
||||
use tracing::debug;
|
||||
use spargebra::term::Variable;
|
||||
|
||||
pub static ENGLISH_TAG: LazyLock<LanguageTag<String>> = LazyLock::new(|| {
|
||||
LanguageTag::parse("en".to_string()).unwrap()
|
||||
|
||||
+26
-17
@@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::fmt::Debug;
|
||||
use std::str::FromStr;
|
||||
use oxigraph::io::{RdfFormat, RdfParser, RdfSerializer};
|
||||
use oxigraph::model::{Graph, NamedNode, NamedNodeRef, Triple};
|
||||
use oxigraph::model::{Graph, NamedNode, Triple};
|
||||
use oxigraph::sparql::results::{QueryResultsFormat, QueryResultsParser, SliceQueryResultsParserOutput};
|
||||
use spargebra::algebra::GraphPattern;
|
||||
use spargebra::term::{GroundTerm, NamedNodePattern, TermPattern, TriplePattern, Variable};
|
||||
@@ -86,11 +86,11 @@ impl ConnectedOntology {
|
||||
output_buffer = serializer.finish()?;
|
||||
let turtle = String::from_utf8_lossy(&output_buffer).to_string();
|
||||
|
||||
let mut request = OntologyQueryRequest::default();
|
||||
request.sparql_query = None;
|
||||
request.turtle = Some(turtle);
|
||||
request.base = None;
|
||||
request.inferences_only = true;
|
||||
let request = OntologyQueryRequest {
|
||||
turtle: Some(turtle),
|
||||
inferences_only: true,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let response = self.client.query(request).await?;
|
||||
Ok(RdfParser::from_format(RdfFormat::Turtle)
|
||||
@@ -101,8 +101,7 @@ impl ConnectedOntology {
|
||||
}
|
||||
|
||||
pub async fn list_read_only(&mut self) -> crate::Result<HashSet<ReadOnlyEntity>> {
|
||||
let mut request = OntologyQueryRequest::default();
|
||||
request.sparql_query = Some(format!(r#"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||
let sparql_query = r#"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
||||
PREFIX gl: <https://graphofliberty.org/2026/04/ont/>
|
||||
@@ -111,7 +110,12 @@ SELECT ?subject ?class WHERE {{
|
||||
VALUES ?class {{ rdf:Property rdfs:Class }}
|
||||
?subject a ?class ;
|
||||
gl:readOnly "true"^^xsd:boolean .
|
||||
}}"#));
|
||||
}}"#.to_owned();
|
||||
|
||||
let request = OntologyQueryRequest {
|
||||
sparql_query: Some(sparql_query),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let response = self.client.query(request).await?;
|
||||
let parser_output = QueryResultsParser::from_format(QueryResultsFormat::Json)
|
||||
@@ -123,12 +127,12 @@ SELECT ?subject ?class WHERE {{
|
||||
let subject = solution
|
||||
.get("subject")
|
||||
.and_then(term_to_named_node)
|
||||
.map(|node| node.clone());
|
||||
.cloned();
|
||||
|
||||
let class = solution
|
||||
.get("class")
|
||||
.and_then(term_to_named_node)
|
||||
.map(|node| node.clone());
|
||||
.cloned();
|
||||
|
||||
if let Some(subject) = subject &&
|
||||
let Some(class) = class {
|
||||
@@ -186,8 +190,7 @@ SELECT ?subject ?class WHERE {{
|
||||
let comment_filter = self.language.filter("comment");
|
||||
let definition_filter = self.language.filter("definition");
|
||||
|
||||
let mut request = OntologyQueryRequest::default();
|
||||
request.sparql_query = Some(format!(r#"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||
let sparql_query = format!(r#"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
||||
|
||||
@@ -204,7 +207,12 @@ SELECT ?subject ?label ?description ?class WHERE {{
|
||||
{definition_filter}
|
||||
}}
|
||||
BIND(COALESCE(?definition, ?comment) AS ?description)
|
||||
}}"#));
|
||||
}}"#);
|
||||
|
||||
let request = OntologyQueryRequest {
|
||||
sparql_query: Some(sparql_query),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let response = self.client.query(request).await?;
|
||||
let parser_output = QueryResultsParser::from_format(QueryResultsFormat::Json)
|
||||
@@ -215,12 +223,13 @@ SELECT ?subject ?label ?description ?class WHERE {{
|
||||
for solution in solutions.filter_map(Result::ok) {
|
||||
let class = solution
|
||||
.get("class")
|
||||
.and_then(term_to_named_node);
|
||||
.and_then(term_to_named_node)
|
||||
.cloned();
|
||||
|
||||
let subject = solution
|
||||
.get("subject")
|
||||
.and_then(term_to_named_node)
|
||||
.map(|node| node.clone());
|
||||
.cloned();
|
||||
|
||||
if let Some(subject) = subject {
|
||||
let label = solution
|
||||
@@ -236,7 +245,7 @@ SELECT ?subject ?label ?description ?class WHERE {{
|
||||
results.insert(subject, ResourceDescription {
|
||||
label,
|
||||
description,
|
||||
class: class.cloned(),
|
||||
class,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user