pub struct GraphTransformer;Expand description
Graph transformation utilities
Implementations§
Source§impl GraphTransformer
impl GraphTransformer
Sourcepub fn filter_by_predicate<F>(triples: &[Triple], predicate: F) -> Vec<Triple>
pub fn filter_by_predicate<F>(triples: &[Triple], predicate: F) -> Vec<Triple>
Filter triples by predicate
§Example
use oxirs_ttl::toolkit::graph_utils::GraphTransformer;
use oxirs_core::model::{Triple, NamedNode};
let triples = vec![
Triple::new(
NamedNode::new("http://example.org/s")?,
NamedNode::new("http://example.org/p1")?,
NamedNode::new("http://example.org/o")?,
),
Triple::new(
NamedNode::new("http://example.org/s")?,
NamedNode::new("http://example.org/p2")?,
NamedNode::new("http://example.org/o")?,
),
];
let filtered = GraphTransformer::filter_by_predicate(
&triples,
|p| p.ends_with("p1")
);
assert_eq!(filtered.len(), 1);Sourcepub fn filter_by_subject<F>(triples: &[Triple], predicate: F) -> Vec<Triple>
pub fn filter_by_subject<F>(triples: &[Triple], predicate: F) -> Vec<Triple>
Filter triples by subject
Sourcepub fn group_by_subject(triples: &[Triple]) -> HashMap<String, Vec<Triple>>
pub fn group_by_subject(triples: &[Triple]) -> HashMap<String, Vec<Triple>>
Group triples by subject
Returns a map from subject to all triples with that subject.
Sourcepub fn group_by_predicate(triples: &[Triple]) -> HashMap<String, Vec<Triple>>
pub fn group_by_predicate(triples: &[Triple]) -> HashMap<String, Vec<Triple>>
Group triples by predicate
Sourcepub fn unique_subjects(triples: &[Triple]) -> Vec<String>
pub fn unique_subjects(triples: &[Triple]) -> Vec<String>
Get all unique subjects in the graph
Sourcepub fn unique_predicates(triples: &[Triple]) -> Vec<String>
pub fn unique_predicates(triples: &[Triple]) -> Vec<String>
Get all unique predicates in the graph
Sourcepub fn unique_objects(triples: &[Triple]) -> Vec<String>
pub fn unique_objects(triples: &[Triple]) -> Vec<String>
Get all unique objects in the graph
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GraphTransformer
impl RefUnwindSafe for GraphTransformer
impl Send for GraphTransformer
impl Sync for GraphTransformer
impl Unpin for GraphTransformer
impl UnsafeUnpin for GraphTransformer
impl UnwindSafe for GraphTransformer
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more