.
This commit is contained in:
+19
-9
@@ -5,7 +5,7 @@ mod navigator;
|
||||
mod rdf;
|
||||
mod theme;
|
||||
mod widget;
|
||||
mod windows;
|
||||
mod tasks;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use crate::app::Publisher;
|
||||
@@ -42,25 +42,23 @@ fn main() -> color_eyre::Result<()> {
|
||||
.init();
|
||||
color_eyre::install()?;
|
||||
|
||||
let mut index = SearchIndex::builder()
|
||||
.with_path("/home/alex/.local/share/org.graphofliberty.desktop/index")
|
||||
.build()
|
||||
.expect("Failed to build search index");
|
||||
|
||||
let args = AppArgs::parse();
|
||||
match args.command {
|
||||
Some(Command::Query(args)) => {
|
||||
let raw_query = String::from_utf8(std::fs::read(&args.query_path)?)?;
|
||||
let raw_query = if let Some(query) = &args.query_path {
|
||||
Some(String::from_utf8(std::fs::read(query)?)?)
|
||||
} else { None };
|
||||
|
||||
let graph = if let Some(dataset_path) = &args.dataset_path {
|
||||
Some(String::from_utf8(std::fs::read(dataset_path)?)?)
|
||||
} else { None };
|
||||
|
||||
let mut request = OntologyQueryRequest::default();
|
||||
request.sparql_query = Some(raw_query);
|
||||
request.sparql_query = raw_query;
|
||||
request.turtle = graph;
|
||||
request.prefixes = HashMap::from_iter(gl_graph::PREFIXES.iter().map(|(name, iri)| (name.clone(), iri.clone())));
|
||||
request.base = args.base.clone();
|
||||
request.inferences_only = args.inferences_only;
|
||||
|
||||
let runtime = tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
@@ -74,11 +72,22 @@ fn main() -> color_eyre::Result<()> {
|
||||
});
|
||||
}
|
||||
Some(Command::Search(args)) => {
|
||||
for document in index.query(args.discriminant, &args.query, Schema::all_fields(), 5000)? {
|
||||
let mut index = SearchIndex::builder()
|
||||
.with_path("/home/alex/.local/share/org.graphofliberty.desktop/index")
|
||||
.build()
|
||||
.expect("Failed to build search index");
|
||||
|
||||
let limit = args.limit.unwrap_or(5);
|
||||
for document in index.query(args.discriminant, &args.query, Schema::all_fields(), limit)? {
|
||||
println!("{}", gl_search::to_json(document));
|
||||
}
|
||||
}
|
||||
Some(Command::Reindex) => {
|
||||
let mut index = SearchIndex::builder()
|
||||
.with_path("/home/alex/.local/share/org.graphofliberty.desktop/index")
|
||||
.build()
|
||||
.expect("Failed to build search index");
|
||||
|
||||
let mut writer = index.writer()?;
|
||||
debug_span!("Clear Index").in_scope(|| {
|
||||
writer.delete_all_documents()?;
|
||||
@@ -147,6 +156,7 @@ fn main() -> color_eyre::Result<()> {
|
||||
request.turtle = Some(turtle);
|
||||
request.prefixes = HashMap::new();
|
||||
request.base = None;
|
||||
request.inferences_only = false;
|
||||
|
||||
let response = client.query(request).await?;
|
||||
let graph_with_inferences = RdfParser::from_format(RdfFormat::Turtle)
|
||||
|
||||
Reference in New Issue
Block a user