prefixmap

The prefixmap crate contains an RDF prefix map implementation, where a prefix map is a list of alias declarations associated with IRIs. For example, in Turtle syntax, a prefix map can be declared as follows:

@prefix schema: <https://schema.org/> .
@prefix : <https://example.org/> .

Usage

For example, we can create a prefix map:

#![allow(unused)]
fn main() {
use prefixmap::PrefixMap;

let mut prefix_map = PrefixMap::new();

let other_map = PrefixMap::from_hashmap(
    HashMap::from([
        ("", "https://example.org/"),
        ("schema", "https://schema.org/")
    ])
)?;
}

And then register some prefixes:

#![allow(unused)]
fn main() {
use iri_s::IriS;

prefix_map.add_prefix("schema", "https://schema.org/");
prefix_map.add_prefix("ex", "https://example.org/");

// Also, we can register a prefix with the IriS type:
let default_iri = IriS::from_string("https://default.org/")?;
prefix_map.add_prefix("", default_iri);
}

This will allow use to qualify IRIs using the registered prefixes:

#![allow(unused)]
fn main() {
// This will return "schema:Person"
prefix_map.qualify("https://schema.org/Person")?;
}

And, if you need it, you get a basic prefix map or the WikiData prefix map:

#![allow(unused)]
fn main() {
// Returns a basic prefix map
PrefixMap::basic();

// Returns the WikiData prefix map
PrefixMap::wikidata();
}

Dependents and dependencies

This create depends mostly on the iri_s and indexmap crates.

This create is also used by other rudof modules that needs IRIs functionality, such as:

Documentation

The crate documentation can be found here.