Giter VIP home page Giter VIP logo

grdf's Introduction

Generalized RDF datasets.

CI Crate informations License Documentation

The Resource Description Framework (RDF) is a powerful method for modeling data and knowledge defined by the World Wide Web Consortium (W3C). A RDF dataset consists in a collection of graphs connecting nodes, values and predicates. This crate provides traits and implementations of Generalized RDF (gRDF) where nodes, values and predicates have the same representation.

Note that this crates requires rust compiler version 1.65 or later. It needs Generic Associated Typed (GAT) to work properly.

Basic usage

Exploring a dataset

Each Dataset implementation provides many iterators to explore the data. One simple way is to iterate through the quad of the dataset:

for Quad(subject, predicate, object, graph) in dataset.quads() {
	// do something
}

Another way is to access each graph individually using Dataset::graph. For a given graph, it is then possible to iterate through the triples of the graph:

let graph = dataset.graph(id).unwrap();

for Triple(subject, predicate, object) in graph.triples() {
	// do something
}

It is also possible to explore the graph logically, subject by subject, predicate by predicate, object by object:

// for each subject of the graph...
for (subject, predicates) in graph.subjects() {
	// for each predicate it is subject...
	for (predicate, objects) in predicates {
		// for each triple (subject, predicate, object)...
		for object in objects {
			// do something
		}
	}
}

Inserting new data

Insertion can be done on MutableDataset implementations using MutableDataset::insert:

let mut dataset: HashDataset<Term> = HashDataset::new();
dataset.insert(Quad(subject, predicate, object, graph));

Again it is possible to access each graph of the dataset mutably:

let mut graph = dataset.graph_mut(id).unwrap();
graph.insert(Triple(subject, predicate, object));

Custom node type

The type used to represent RDF nodes (subjects, predicate and objects) is a parameter of the dataset. Anything can be used although this crate provide a default Term type that represents generic RDF nodes (blank nodes, IRI-named nodes and literal values).

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

grdf's People

Contributors

timothee-haudebourg avatar ratmice avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.