.
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
use oxigraph::model::{NamedNode, Quad, Term};
|
||||
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
|
||||
}
|
||||
|
||||
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 {
|
||||
Some(node)
|
||||
} 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 {
|
||||
match literal.datatype() {
|
||||
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 literal.datatype() == xsd::BOOLEAN {
|
||||
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 &&
|
||||
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.");
|
||||
Some(value)
|
||||
} else { None }
|
||||
|
||||
Reference in New Issue
Block a user