.
This commit is contained in:
Generated
+20
-20
@@ -106,9 +106,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.102"
|
version = "1.0.103"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
|
checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arboard"
|
name = "arboard"
|
||||||
@@ -130,9 +130,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arc-swap"
|
name = "arc-swap"
|
||||||
version = "1.9.1"
|
version = "1.9.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6a3a1fd6f75306b68087b831f025c712524bcb19aad54e557b1129cfa0a2b207"
|
checksum = "c049c0be4daef0b145cb3555416b3b8ef5b7888a38aea1a3a155801fe7b0810b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustversion",
|
"rustversion",
|
||||||
]
|
]
|
||||||
@@ -1399,9 +1399,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glam"
|
name = "glam"
|
||||||
version = "0.33.1"
|
version = "0.33.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "898f5a568a84989b6c0f8caa50a93074b97dbdc58fc6d9543157bb4562758933"
|
checksum = "7f22fb22f065b308be0d8724e3706c7fa3fc2a6c7d6899df4cad7860e7a75436"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glob"
|
name = "glob"
|
||||||
@@ -1630,7 +1630,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "iced"
|
name = "iced"
|
||||||
version = "0.15.0-dev"
|
version = "0.15.0-dev"
|
||||||
source = "git+https://github.com/iced-rs/iced.git?branch=master#e46f9c9e69a8d787823c4a64fdcc49c23f303065"
|
source = "git+https://github.com/iced-rs/iced.git?branch=master#36b6ed0aec85fb01afbb63b4f48afa7763487967"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"iced_debug",
|
"iced_debug",
|
||||||
@@ -1645,7 +1645,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_core"
|
name = "iced_core"
|
||||||
version = "0.15.0-dev"
|
version = "0.15.0-dev"
|
||||||
source = "git+https://github.com/iced-rs/iced.git?branch=master#e46f9c9e69a8d787823c4a64fdcc49c23f303065"
|
source = "git+https://github.com/iced-rs/iced.git?branch=master#36b6ed0aec85fb01afbb63b4f48afa7763487967"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.13.0",
|
"bitflags 2.13.0",
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -1663,7 +1663,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_debug"
|
name = "iced_debug"
|
||||||
version = "0.15.0-dev"
|
version = "0.15.0-dev"
|
||||||
source = "git+https://github.com/iced-rs/iced.git?branch=master#e46f9c9e69a8d787823c4a64fdcc49c23f303065"
|
source = "git+https://github.com/iced-rs/iced.git?branch=master#36b6ed0aec85fb01afbb63b4f48afa7763487967"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"iced_futures",
|
"iced_futures",
|
||||||
@@ -1673,7 +1673,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_futures"
|
name = "iced_futures"
|
||||||
version = "0.15.0-dev"
|
version = "0.15.0-dev"
|
||||||
source = "git+https://github.com/iced-rs/iced.git?branch=master#e46f9c9e69a8d787823c4a64fdcc49c23f303065"
|
source = "git+https://github.com/iced-rs/iced.git?branch=master#36b6ed0aec85fb01afbb63b4f48afa7763487967"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
@@ -1687,7 +1687,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_graphics"
|
name = "iced_graphics"
|
||||||
version = "0.15.0-dev"
|
version = "0.15.0-dev"
|
||||||
source = "git+https://github.com/iced-rs/iced.git?branch=master#e46f9c9e69a8d787823c4a64fdcc49c23f303065"
|
source = "git+https://github.com/iced-rs/iced.git?branch=master#36b6ed0aec85fb01afbb63b4f48afa7763487967"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.13.0",
|
"bitflags 2.13.0",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
@@ -1705,7 +1705,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_program"
|
name = "iced_program"
|
||||||
version = "0.15.0-dev"
|
version = "0.15.0-dev"
|
||||||
source = "git+https://github.com/iced-rs/iced.git?branch=master#e46f9c9e69a8d787823c4a64fdcc49c23f303065"
|
source = "git+https://github.com/iced-rs/iced.git?branch=master#36b6ed0aec85fb01afbb63b4f48afa7763487967"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_graphics",
|
"iced_graphics",
|
||||||
"iced_runtime",
|
"iced_runtime",
|
||||||
@@ -1714,7 +1714,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_renderer"
|
name = "iced_renderer"
|
||||||
version = "0.15.0-dev"
|
version = "0.15.0-dev"
|
||||||
source = "git+https://github.com/iced-rs/iced.git?branch=master#e46f9c9e69a8d787823c4a64fdcc49c23f303065"
|
source = "git+https://github.com/iced-rs/iced.git?branch=master#36b6ed0aec85fb01afbb63b4f48afa7763487967"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_graphics",
|
"iced_graphics",
|
||||||
"iced_tiny_skia",
|
"iced_tiny_skia",
|
||||||
@@ -1726,7 +1726,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_runtime"
|
name = "iced_runtime"
|
||||||
version = "0.15.0-dev"
|
version = "0.15.0-dev"
|
||||||
source = "git+https://github.com/iced-rs/iced.git?branch=master#e46f9c9e69a8d787823c4a64fdcc49c23f303065"
|
source = "git+https://github.com/iced-rs/iced.git?branch=master#36b6ed0aec85fb01afbb63b4f48afa7763487967"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
@@ -1737,7 +1737,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_tiny_skia"
|
name = "iced_tiny_skia"
|
||||||
version = "0.15.0-dev"
|
version = "0.15.0-dev"
|
||||||
source = "git+https://github.com/iced-rs/iced.git?branch=master#e46f9c9e69a8d787823c4a64fdcc49c23f303065"
|
source = "git+https://github.com/iced-rs/iced.git?branch=master#36b6ed0aec85fb01afbb63b4f48afa7763487967"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"cosmic-text",
|
"cosmic-text",
|
||||||
@@ -1753,7 +1753,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_wgpu"
|
name = "iced_wgpu"
|
||||||
version = "0.15.0-dev"
|
version = "0.15.0-dev"
|
||||||
source = "git+https://github.com/iced-rs/iced.git?branch=master#e46f9c9e69a8d787823c4a64fdcc49c23f303065"
|
source = "git+https://github.com/iced-rs/iced.git?branch=master#36b6ed0aec85fb01afbb63b4f48afa7763487967"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.13.0",
|
"bitflags 2.13.0",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
@@ -1770,7 +1770,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_widget"
|
name = "iced_widget"
|
||||||
version = "0.15.0-dev"
|
version = "0.15.0-dev"
|
||||||
source = "git+https://github.com/iced-rs/iced.git?branch=master#e46f9c9e69a8d787823c4a64fdcc49c23f303065"
|
source = "git+https://github.com/iced-rs/iced.git?branch=master#36b6ed0aec85fb01afbb63b4f48afa7763487967"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_renderer",
|
"iced_renderer",
|
||||||
"iced_runtime",
|
"iced_runtime",
|
||||||
@@ -1784,7 +1784,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_winit"
|
name = "iced_winit"
|
||||||
version = "0.15.0-dev"
|
version = "0.15.0-dev"
|
||||||
source = "git+https://github.com/iced-rs/iced.git?branch=master#e46f9c9e69a8d787823c4a64fdcc49c23f303065"
|
source = "git+https://github.com/iced-rs/iced.git?branch=master#36b6ed0aec85fb01afbb63b4f48afa7763487967"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arboard",
|
"arboard",
|
||||||
"iced_debug",
|
"iced_debug",
|
||||||
@@ -4727,9 +4727,9 @@ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "1.23.3"
|
version = "1.23.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "144d6b123cef80b301b8f72a9e2ca4370ddec21950d0a103dd22c437006d2db7"
|
checksum = "bf80a72845275afea99e7f2b434723d3bc7e38470fcd1c7ed39a599c73319a53"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.4.3",
|
"getrandom 0.4.3",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
|
|||||||
+18
-17
@@ -1,7 +1,7 @@
|
|||||||
use crate::rdf::ontology::{LabeledIri, Ontology};
|
use crate::rdf::ontology::{LabeledIri, Ontology};
|
||||||
use crate::rdf::term_helper::{TermHelper, TermHelperMut};
|
use crate::rdf::term_helper::{TermHelper, TermHelperMut};
|
||||||
use crate::rdf::vocab::{gl, rda};
|
use crate::rdf::vocab::{gl, rda};
|
||||||
use gl_search::{Schema, SearchDocument, SearchIndex, doc, NamedFieldDocument, OwnedValue};
|
use gl_search::{Schema, SearchDocument, SearchIndex, NamedFieldDocument, OwnedValue, doc};
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use iced::alignment::Horizontal;
|
use iced::alignment::Horizontal;
|
||||||
use iced::widget::button::Style;
|
use iced::widget::button::Style;
|
||||||
@@ -18,8 +18,8 @@ use ldp::traverse::Traverse;
|
|||||||
use ldp::{RdfSource, RdfSourceUpdateResponse, ResourceRequestBuilder, SerializationOptions};
|
use ldp::{RdfSource, RdfSourceUpdateResponse, ResourceRequestBuilder, SerializationOptions};
|
||||||
use oxigraph::io::RdfFormat;
|
use oxigraph::io::RdfFormat;
|
||||||
use oxigraph::model::vocab::{rdf, rdfs};
|
use oxigraph::model::vocab::{rdf, rdfs};
|
||||||
use oxigraph::model::{BaseDirection, Dataset, NamedNode, NamedNodeRef, Quad, Term, TermRef};
|
use oxigraph::model::{BaseDirection, Dataset, NamedNode, Quad, Term, TermRef};
|
||||||
use tracing::{debug, error, info};
|
use tracing::{debug, error, info, info_span, span, Level};
|
||||||
use crate::widget::iri_input::iri_input;
|
use crate::widget::iri_input::iri_input;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@@ -95,40 +95,41 @@ pub(crate) struct Publisher {
|
|||||||
|
|
||||||
impl Publisher {
|
impl Publisher {
|
||||||
pub(crate) fn new() -> (Self, Task<Message>) {
|
pub(crate) fn new() -> (Self, Task<Message>) {
|
||||||
let ontology = Ontology::builder()
|
let ontology = info_span!("Ontology Creation").in_scope(|| {
|
||||||
|
Ontology::builder()
|
||||||
.with_path("/home/alex/.local/share/org.graphofliberty.desktop/ontology")
|
.with_path("/home/alex/.local/share/org.graphofliberty.desktop/ontology")
|
||||||
.build()
|
.build()
|
||||||
.expect("Failed to build ontology");
|
.expect("Failed to build ontology")
|
||||||
|
});
|
||||||
|
|
||||||
|
let index = info_span!("Ontology Indexing").in_scope(|| {
|
||||||
let mut index = SearchIndex::builder()
|
let mut index = SearchIndex::builder()
|
||||||
.with_path("/home/alex/Documents/Index")
|
//.with_path("/home/alex/.local/share/org.graphofliberty.desktop/index")
|
||||||
.build()
|
.build()
|
||||||
.expect("Failed to build search index");
|
.expect("Failed to build search index");
|
||||||
|
|
||||||
if let Some(id) = ontology.catalog_id(&rdf::PROPERTY.into_owned()) { index.remove_all_of_type(id); }
|
if let Some(id) = ontology.catalog_id(&rdf::PROPERTY.into_owned()) { index.remove_all_of_type(id); }
|
||||||
if let Some(id) = ontology.catalog_id(&rdfs::CLASS.into_owned()) { index.remove_all_of_type(id); }
|
if let Some(id) = ontology.catalog_id(&rdfs::CLASS.into_owned()) { index.remove_all_of_type(id); }
|
||||||
|
|
||||||
/*for (iri, info) in ontology.iri_info() {
|
for (iri, entity) in ontology.entities() {
|
||||||
if let Some(type_) = ontology.catalog_id(&info.type_) {
|
|
||||||
let mut document = doc!(
|
let mut document = doc!(
|
||||||
Schema::type_field() => type_,
|
Schema::type_field() => entity.catalog_id,
|
||||||
Schema::iri_field() => iri.as_str(),
|
Schema::iri_field() => iri.as_str(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(label) = &info.label &&
|
if let Some(field) = ontology.field_for_property(&rdfs::LABEL.into_owned()) {
|
||||||
let Some(field) = ontology.field_for_property(&rdfs::LABEL.into_owned()) {
|
document.add_text(Schema::field(&field.name), &entity.label);
|
||||||
document.add_text(Schema::field(&field.name), label);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(comment) = &info.comment &&
|
if let Some(field) = ontology.field_for_property(&rdfs::COMMENT.into_owned()) {
|
||||||
let Some(field) = ontology.field_for_property(&rdfs::COMMENT.into_owned()) {
|
document.add_text(Schema::field(&field.name), entity.comment.clone().unwrap_or(String::from("")));
|
||||||
document.add_text(Schema::field(&field.name), comment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
index.add(document).expect("Unable to add annotated IRI to search index");
|
index.add(document).expect("Unable to add annotated IRI to search index");
|
||||||
}
|
}
|
||||||
}
|
index.commit().expect("Unable to commit ontology to index");
|
||||||
index.commit().expect("Unable to commit ontology to index");*/
|
index
|
||||||
|
});
|
||||||
|
|
||||||
let mut abbreviated_datatypes = ontology
|
let mut abbreviated_datatypes = ontology
|
||||||
.datatypes()
|
.datatypes()
|
||||||
|
|||||||
@@ -21,4 +21,7 @@ pub(crate) enum Error {
|
|||||||
|
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Search(#[from] gl_search::SearchError),
|
Search(#[from] gl_search::SearchError),
|
||||||
|
|
||||||
|
#[error(transparent)]
|
||||||
|
QueryEvaluation(#[from] oxigraph::sparql::QueryEvaluationError),
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -4,16 +4,16 @@ mod rdf;
|
|||||||
mod windows;
|
mod windows;
|
||||||
mod widget;
|
mod widget;
|
||||||
|
|
||||||
use iced::Program;
|
|
||||||
use crate::app::Publisher;
|
use crate::app::Publisher;
|
||||||
use tracing_subscriber::layer::SubscriberExt;
|
use tracing_subscriber::layer::SubscriberExt;
|
||||||
use tracing_subscriber::util::SubscriberInitExt;
|
use tracing_subscriber::util::SubscriberInitExt;
|
||||||
use tracing_subscriber::{EnvFilter, fmt};
|
use tracing_subscriber::{EnvFilter, fmt};
|
||||||
|
use tracing_subscriber::fmt::format::FmtSpan;
|
||||||
|
|
||||||
fn main() -> color_eyre::Result<()> {
|
fn main() -> color_eyre::Result<()> {
|
||||||
let appender = tracing_appender::rolling::never("/tmp", "publisher-log");
|
let appender = tracing_appender::rolling::never("/tmp", "publisher-log");
|
||||||
tracing_subscriber::registry()
|
tracing_subscriber::registry()
|
||||||
.with(fmt::layer().with_writer(appender))
|
.with(fmt::layer().with_span_events(FmtSpan::CLOSE).with_writer(appender))
|
||||||
.with(EnvFilter::from_default_env())
|
.with(EnvFilter::from_default_env())
|
||||||
.init();
|
.init();
|
||||||
color_eyre::install()?;
|
color_eyre::install()?;
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
use oxigraph::model::{NamedNode, Quad, Term};
|
use oxigraph::model::{NamedNode, Quad, Term};
|
||||||
use oxigraph::model::vocab::{rdf, xsd};
|
use oxigraph::model::vocab::{rdf, xsd};
|
||||||
|
use tracing::info;
|
||||||
|
|
||||||
fn quad_to_term(quad: &Quad) -> &Term {
|
pub fn quad_to_term(quad: &Quad) -> &Term {
|
||||||
&quad.object
|
&quad.object
|
||||||
}
|
}
|
||||||
|
|
||||||
fn term_to_named_node(term: &Term) -> Option<&NamedNode> {
|
pub fn term_to_named_node(term: &Term) -> Option<&NamedNode> {
|
||||||
if let Term::NamedNode(node) = term {
|
if let Term::NamedNode(node) = term {
|
||||||
Some(node)
|
Some(node)
|
||||||
} else {
|
} else {
|
||||||
@@ -13,7 +14,7 @@ fn term_to_named_node(term: &Term) -> Option<&NamedNode> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn term_to_string(term: &Term) -> Option<&str> {
|
pub fn term_to_string(term: &Term) -> Option<&str> {
|
||||||
if let Term::Literal(literal) = term {
|
if let Term::Literal(literal) = term {
|
||||||
match literal.datatype() {
|
match literal.datatype() {
|
||||||
xsd::STRING | xsd::NORMALIZED_STRING | rdf::LANG_STRING | rdf::DIR_LANG_STRING => {
|
xsd::STRING | xsd::NORMALIZED_STRING | rdf::LANG_STRING | rdf::DIR_LANG_STRING => {
|
||||||
@@ -26,7 +27,7 @@ fn term_to_string(term: &Term) -> Option<&str> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn term_to_boolean(term: &Term) -> Option<bool> {
|
pub fn term_to_boolean(term: &Term) -> Option<bool> {
|
||||||
if let Term::Literal(literal) = term {
|
if let Term::Literal(literal) = term {
|
||||||
if literal.datatype() == xsd::BOOLEAN {
|
if literal.datatype() == xsd::BOOLEAN {
|
||||||
literal.value().parse().ok()
|
literal.value().parse().ok()
|
||||||
@@ -38,9 +39,9 @@ fn term_to_boolean(term: &Term) -> Option<bool> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn term_to_u64(term: &Term) -> Option<u64> {
|
pub fn term_to_u64(term: &Term) -> Option<u64> {
|
||||||
if let Term::Literal(literal) = term &&
|
if let Term::Literal(literal) = term &&
|
||||||
literal.datatype() == xsd::NON_NEGATIVE_INTEGER {
|
(literal.datatype() == xsd::NON_NEGATIVE_INTEGER || literal.datatype() == xsd::INTEGER) {
|
||||||
let value: u64 = literal.value().parse().expect("Failed to parse u64 from ontology. It ought to be a non-negative integer.");
|
let value: u64 = literal.value().parse().expect("Failed to parse u64 from ontology. It ought to be a non-negative integer.");
|
||||||
Some(value)
|
Some(value)
|
||||||
} else { None }
|
} else { None }
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use oxigraph::store::Store;
|
|||||||
use crate::error;
|
use crate::error;
|
||||||
use crate::rdf::vocab::owl;
|
use crate::rdf::vocab::owl;
|
||||||
|
|
||||||
pub fn same_as(store: Store) -> error::Result<Store> {
|
pub fn same_as(store: &mut Store) -> error::Result<()> {
|
||||||
let additional_quads = store
|
let additional_quads = store
|
||||||
.quads_for_pattern(None, Some(owl::SAME_AS), None, None)
|
.quads_for_pattern(None, Some(owl::SAME_AS), None, None)
|
||||||
.filter_map(Result::ok)
|
.filter_map(Result::ok)
|
||||||
@@ -42,11 +42,11 @@ pub fn same_as(store: Store) -> error::Result<Store> {
|
|||||||
if new_size > old_size {
|
if new_size > old_size {
|
||||||
same_as(store)
|
same_as(store)
|
||||||
} else {
|
} else {
|
||||||
Ok(store)
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn super_classes(dataset: &mut Dataset) {
|
pub fn super_classes(store: &mut Store) -> error::Result<()> {
|
||||||
let query = SparqlEvaluator::new()
|
let query = SparqlEvaluator::new()
|
||||||
.parse_query(
|
.parse_query(
|
||||||
r#"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
r#"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
@@ -61,7 +61,7 @@ CONSTRUCT {
|
|||||||
.expect("Unable to parse superclass query");
|
.expect("Unable to parse superclass query");
|
||||||
|
|
||||||
let mut additional_quads = Dataset::new();
|
let mut additional_quads = Dataset::new();
|
||||||
if let QueryResults::Graph(graph) = query.on_queryable_dataset(&*dataset).execute().unwrap()
|
if let QueryResults::Graph(graph) = query.on_store(&store).execute().unwrap()
|
||||||
{
|
{
|
||||||
additional_quads.extend(graph.filter_map(Result::ok).map(|triple| {
|
additional_quads.extend(graph.filter_map(Result::ok).map(|triple| {
|
||||||
Quad::new(
|
Quad::new(
|
||||||
@@ -73,12 +73,14 @@ CONSTRUCT {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
let old_size = dataset.len();
|
let old_size = store.len()?;
|
||||||
dataset.extend(&additional_quads);
|
store.extend(&additional_quads)?;
|
||||||
let new_size = dataset.len();
|
let new_size = store.len()?;
|
||||||
|
|
||||||
if new_size > old_size {
|
if new_size > old_size {
|
||||||
super_classes(dataset)
|
super_classes(store)
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -214,11 +214,15 @@ fedora:lastModifiedBy rdf:type owl:NamedIndividual ;
|
|||||||
|
|
||||||
### http://www.w3.org/1999/02/22-rdf-syntax-ns#Property
|
### http://www.w3.org/1999/02/22-rdf-syntax-ns#Property
|
||||||
rdf:Property rdf:type owl:NamedIndividual ;
|
rdf:Property rdf:type owl:NamedIndividual ;
|
||||||
|
:associatedProperty :comment ,
|
||||||
|
:label ;
|
||||||
:catalogId "0"^^xsd:nonNegativeInteger .
|
:catalogId "0"^^xsd:nonNegativeInteger .
|
||||||
|
|
||||||
|
|
||||||
### http://www.w3.org/2000/01/rdf-schema#Class
|
### http://www.w3.org/2000/01/rdf-schema#Class
|
||||||
rdfs:Class rdf:type owl:NamedIndividual ;
|
rdfs:Class rdf:type owl:NamedIndividual ;
|
||||||
|
:associatedProperty :comment ,
|
||||||
|
:label ;
|
||||||
:catalogId "1"^^xsd:nonNegativeInteger .
|
:catalogId "1"^^xsd:nonNegativeInteger .
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+51
-52
@@ -9,7 +9,8 @@ use std::fmt::Display;
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
use oxigraph::store::Store;
|
use oxigraph::store::Store;
|
||||||
use crate::rdf::materialize;
|
use tracing::{info, instrument};
|
||||||
|
use crate::rdf::{conversion, materialize};
|
||||||
|
|
||||||
static PREFIXES: LazyLock<BTreeMap<String, String>> = LazyLock::new(|| {
|
static PREFIXES: LazyLock<BTreeMap<String, String>> = LazyLock::new(|| {
|
||||||
BTreeMap::from_iter([
|
BTreeMap::from_iter([
|
||||||
@@ -57,7 +58,7 @@ impl OntologyBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(self) -> error::Result<Ontology> {
|
pub fn build(self) -> error::Result<Ontology> {
|
||||||
let store = if let Some(path) = self.path {
|
let mut store = if let Some(path) = self.path {
|
||||||
Store::open(path)
|
Store::open(path)
|
||||||
} else {
|
} else {
|
||||||
Store::new()
|
Store::new()
|
||||||
@@ -68,41 +69,40 @@ impl OntologyBuilder {
|
|||||||
.map(|(k, v)| (k.to_string(), v.to_string()))
|
.map(|(k, v)| (k.to_string(), v.to_string()))
|
||||||
.collect::<HashMap<String, String>>();
|
.collect::<HashMap<String, String>>();
|
||||||
|
|
||||||
let store = materialize::same_as(store)?;
|
materialize::same_as(&mut store)?;
|
||||||
//materialize::super_classes(&mut dataset);
|
materialize::super_classes(&mut store)?;
|
||||||
|
store.optimize()?;
|
||||||
|
|
||||||
// Full-text search index field names
|
// Full-text search index field names
|
||||||
//let fields = Self::fields(&dataset);
|
let fields = Self::fields(&store)?;
|
||||||
|
|
||||||
/*let mut entities: HashMap<NamedNode, Entity> = HashMap::new();
|
let mut entities: HashMap<NamedNode, Entity> = HashMap::new();
|
||||||
let entity_iris = Self::subclass_of(&dataset, gl::ENTITY)
|
// All Entities have exactly one catalog ID.
|
||||||
.chain(Self::subclass_of(&dataset, rda::ENTITY))
|
for quad in store.quads_for_pattern(None, Some(gl::CATALOG_ID), None, None)
|
||||||
.chain([
|
.filter_map(Result::ok) {
|
||||||
rdf::PROPERTY.into_owned(),
|
let label = store.quads_for_pattern(Some(quad.subject.as_ref().into()), Some(rdfs::LABEL), None, None)
|
||||||
rdfs::CLASS.into_owned(),
|
.filter_map(Result::ok)
|
||||||
]);
|
.filter_map(|quad| conversion::term_to_string(&quad.object).map(String::from))
|
||||||
|
|
||||||
for iri in entity_iris {
|
|
||||||
let subject = iri.as_ref().into();
|
|
||||||
|
|
||||||
let label = dataset.quads_for_pattern(Some(subject), Some(rdfs::LABEL), None, None)
|
|
||||||
.filter_map(|quad| term_to_string(&quad.object.into_owned()).map(String::from))
|
|
||||||
.next();
|
.next();
|
||||||
|
|
||||||
let catalog_id = dataset.quads_for_pattern(Some(subject), Some(gl::CATALOG_ID), None, None)
|
let comment = store.quads_for_pattern(Some(quad.subject.as_ref().into()), Some(rdfs::COMMENT), None, None)
|
||||||
.filter_map(|quad| term_to_u64(&quad.object.into_owned()))
|
.filter_map(Result::ok)
|
||||||
|
.filter_map(|quad| conversion::term_to_string(&quad.object).map(String::from))
|
||||||
.next();
|
.next();
|
||||||
|
|
||||||
if let Some(catalog_id) = catalog_id {
|
if let Some(catalog_id) = conversion::term_to_u64(&quad.object) &&
|
||||||
|
let NamedOrBlankNode::NamedNode(subject) = quad.subject &&
|
||||||
|
let Some(label) = label {
|
||||||
let mut properties = HashSet::new();
|
let mut properties = HashSet::new();
|
||||||
for quad in dataset.quads_for_pattern(Some(subject), Some(gl::ASSOCIATED_PROPERTY), None, None) {
|
for quad in store.quads_for_pattern(Some(subject.as_ref().into()), Some(gl::ASSOCIATED_PROPERTY), None, None)
|
||||||
if let NamedOrBlankNodeRef::NamedNode(subject) = quad.subject
|
.filter_map(Result::ok) {
|
||||||
&& let TermRef::NamedNode(property) = quad.object {
|
if let Term::NamedNode(property) = quad.object {
|
||||||
properties.insert(property.into_owned());
|
properties.insert(property);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entities.insert(iri, Entity {
|
entities.insert(subject, Entity {
|
||||||
label: label.unwrap_or(catalog_id.to_string()),
|
label,
|
||||||
|
comment,
|
||||||
catalog_id,
|
catalog_id,
|
||||||
properties,
|
properties,
|
||||||
});
|
});
|
||||||
@@ -110,28 +110,25 @@ impl OntologyBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut indexed_by = HashMap::new();
|
let mut indexed_by = HashMap::new();
|
||||||
for quad in dataset.quads_for_pattern(None, Some(gl::INDEXED_BY_FIELD), None, None) {
|
for quad in store.quads_for_pattern(None, Some(gl::INDEXED_BY_FIELD), None, None)
|
||||||
if let NamedOrBlankNodeRef::NamedNode(subject) = quad.subject
|
.filter_map(Result::ok) {
|
||||||
&& let TermRef::NamedNode(field) = quad.object
|
if let NamedOrBlankNode::NamedNode(subject) = quad.subject
|
||||||
|
&& let Term::NamedNode(field) = quad.object
|
||||||
{
|
{
|
||||||
indexed_by.insert(subject.into_owned(), field.into_owned());
|
indexed_by.insert(subject, field);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
Ok(Ontology {
|
Ok(Ontology {
|
||||||
store,
|
store,
|
||||||
prefixes,
|
prefixes,
|
||||||
fields: HashMap::new(),
|
fields,
|
||||||
entities: HashMap::from_iter([(rdf::PROPERTY.into_owned(), Entity {
|
entities,
|
||||||
label: "property".to_string(),
|
indexed_by,
|
||||||
catalog_id: 0,
|
|
||||||
properties: HashSet::new(),
|
|
||||||
})]),
|
|
||||||
indexed_by: HashMap::new(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/*fn fields(dataset: &Dataset) -> HashMap<NamedNode, IndexField> {
|
fn fields(store: &Store) -> error::Result<HashMap<NamedNode, IndexField>> {
|
||||||
let query = SparqlEvaluator::new()
|
let query = SparqlEvaluator::new()
|
||||||
.parse_query(
|
.parse_query(
|
||||||
r#"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
r#"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
@@ -147,13 +144,12 @@ SELECT DISTINCT ?subject ?name ?label {
|
|||||||
.expect("Unable to parse field query");
|
.expect("Unable to parse field query");
|
||||||
|
|
||||||
let mut results = HashMap::new();
|
let mut results = HashMap::new();
|
||||||
if let QueryResults::Solutions(solutions) =
|
if let QueryResults::Solutions(solutions) = query.on_store(store).execute()?
|
||||||
query.on_queryable_dataset(dataset).execute().unwrap()
|
|
||||||
{
|
{
|
||||||
for solution in solutions.filter_map(Result::ok) {
|
for solution in solutions.filter_map(Result::ok) {
|
||||||
let subject = solution.get("subject").and_then(term_to_named_node);
|
let subject = solution.get("subject").and_then(conversion::term_to_named_node);
|
||||||
let name = solution.get("name").and_then(term_to_string);
|
let name = solution.get("name").and_then(conversion::term_to_string);
|
||||||
let label = solution.get("label").and_then(term_to_string);
|
let label = solution.get("label").and_then(conversion::term_to_string);
|
||||||
|
|
||||||
if let Some(subject) = subject && let Some(name) = name {
|
if let Some(subject) = subject && let Some(name) = name {
|
||||||
let field = IndexField {
|
let field = IndexField {
|
||||||
@@ -164,10 +160,10 @@ SELECT DISTINCT ?subject ?name ?label {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
results
|
Ok(results)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subclass_of(dataset: &Dataset, class: NamedNodeRef<'_>) -> impl Iterator<Item = NamedNode> {
|
/*fn subclass_of(dataset: &Dataset, class: NamedNodeRef<'_>) -> impl Iterator<Item = NamedNode> {
|
||||||
let query = SparqlEvaluator::new()
|
let query = SparqlEvaluator::new()
|
||||||
.parse_query(
|
.parse_query(
|
||||||
format!(
|
format!(
|
||||||
@@ -200,6 +196,7 @@ SELECT ?class {{
|
|||||||
pub struct LabeledIri {
|
pub struct LabeledIri {
|
||||||
pub iri: NamedNode,
|
pub iri: NamedNode,
|
||||||
pub label: String,
|
pub label: String,
|
||||||
|
pub comment: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq for LabeledIri {
|
impl PartialEq for LabeledIri {
|
||||||
@@ -225,6 +222,7 @@ pub struct IriInformation {
|
|||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Entity {
|
pub struct Entity {
|
||||||
pub label: String,
|
pub label: String,
|
||||||
|
pub comment: Option<String>,
|
||||||
pub catalog_id: u64,
|
pub catalog_id: u64,
|
||||||
pub properties: HashSet<NamedNode>,
|
pub properties: HashSet<NamedNode>,
|
||||||
}
|
}
|
||||||
@@ -263,11 +261,6 @@ impl Ontology {
|
|||||||
&*PREFIXES
|
&*PREFIXES
|
||||||
}
|
}
|
||||||
|
|
||||||
/*pub fn info(&self, node: NamedNodeRef<'_>) -> Option<&IriInformation> {
|
|
||||||
let node = node.into_owned();
|
|
||||||
self.iri_info.get(&node)
|
|
||||||
}*/
|
|
||||||
|
|
||||||
pub fn abbreviate(&self, node: NamedNodeRef<'_>) -> String {
|
pub fn abbreviate(&self, node: NamedNodeRef<'_>) -> String {
|
||||||
for (prefix_name, prefix_iri) in &self.prefixes {
|
for (prefix_name, prefix_iri) in &self.prefixes {
|
||||||
if let Some(local_name) = node.as_str().strip_prefix(prefix_iri) {
|
if let Some(local_name) = node.as_str().strip_prefix(prefix_iri) {
|
||||||
@@ -314,6 +307,7 @@ impl Ontology {
|
|||||||
.map(|entity| LabeledIri {
|
.map(|entity| LabeledIri {
|
||||||
iri: class.to_owned(),
|
iri: class.to_owned(),
|
||||||
label: entity.label.to_owned(),
|
label: entity.label.to_owned(),
|
||||||
|
comment: entity.comment.to_owned(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,9 +316,14 @@ impl Ontology {
|
|||||||
.map(|(iri, entity)| LabeledIri {
|
.map(|(iri, entity)| LabeledIri {
|
||||||
iri: iri.to_owned(),
|
iri: iri.to_owned(),
|
||||||
label: entity.label.to_owned(),
|
label: 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> {
|
pub fn datatypes(&self) -> impl Iterator<Item = NamedNode> {
|
||||||
self.store
|
self.store
|
||||||
.quads_for_pattern(
|
.quads_for_pattern(
|
||||||
|
|||||||
@@ -11,7 +11,4 @@ pub enum SearchError {
|
|||||||
|
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
OpenDirectoryError(#[from] tantivy::directory::error::OpenDirectoryError),
|
OpenDirectoryError(#[from] tantivy::directory::error::OpenDirectoryError),
|
||||||
|
|
||||||
#[error("Path to index not specified")]
|
|
||||||
IndexPathNotSpecified,
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-8
@@ -21,7 +21,6 @@ impl SearchIndexBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(self) -> error::Result<SearchIndex> {
|
pub fn build(self) -> error::Result<SearchIndex> {
|
||||||
if let Some(path) = self.path {
|
|
||||||
let ngram_32 = NgramTokenizer::new(1, 32, false)?;
|
let ngram_32 = NgramTokenizer::new(1, 32, false)?;
|
||||||
let ngram_32_lowercase = TextAnalyzer::builder(ngram_32)
|
let ngram_32_lowercase = TextAnalyzer::builder(ngram_32)
|
||||||
.filter(LowerCaser)
|
.filter(LowerCaser)
|
||||||
@@ -30,12 +29,17 @@ impl SearchIndexBuilder {
|
|||||||
let tokenizer_manager = TokenizerManager::default();
|
let tokenizer_manager = TokenizerManager::default();
|
||||||
tokenizer_manager.register("ngram_32", ngram_32_lowercase);
|
tokenizer_manager.register("ngram_32", ngram_32_lowercase);
|
||||||
|
|
||||||
|
let builder = Index::builder()
|
||||||
|
.schema(Schema::schema().clone())
|
||||||
|
.tokenizers(tokenizer_manager);
|
||||||
|
|
||||||
|
let index = if let Some(path) = self.path {
|
||||||
let mmap_directory = MmapDirectory::open(path)?;
|
let mmap_directory = MmapDirectory::open(path)?;
|
||||||
let managed_directory = ManagedDirectory::wrap(Box::new(mmap_directory))?;
|
let managed_directory = ManagedDirectory::wrap(Box::new(mmap_directory))?;
|
||||||
let index = Index::builder()
|
builder.open_or_create(managed_directory)?
|
||||||
.schema(Schema::schema().clone())
|
} else {
|
||||||
.tokenizers(tokenizer_manager)
|
builder.create_in_ram()?
|
||||||
.open_or_create(managed_directory)?;
|
};
|
||||||
|
|
||||||
let reader = index
|
let reader = index
|
||||||
.reader_builder()
|
.reader_builder()
|
||||||
@@ -49,9 +53,6 @@ impl SearchIndexBuilder {
|
|||||||
reader,
|
reader,
|
||||||
writer,
|
writer,
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
Err(SearchError::IndexPathNotSpecified)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user