Skip to content

Commit

Permalink
add skos to PrefixMapping::common
Browse files Browse the repository at this point in the history
  • Loading branch information
johnstonskj committed Oct 16, 2024
1 parent 541f945 commit c113623
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
4 changes: 2 additions & 2 deletions rdftk_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rdftk_core"
version = "0.5.2"
version = "0.5.3"
authors = ["Simon Johnston <[email protected]>"]
edition = "2021"
description = "This crate provides the core RDF data model; concrete implementations for Statements and Literals, along with a Resource type that provides a builder-like experience for models."
Expand All @@ -26,7 +26,7 @@ bimap = "0.6"
language-tags = "0.3.2"
lazy_static = "1.5"
rdftk_iri = { version = "0.2.5", path = "../rdftk_iri" }
rdftk_names = { version = "0.2.3", path = "../rdftk_names" }
rdftk_names = { version = "0.2.4", path = "../rdftk_names" }
unique_id = "0.1"
uuid = { version = "1.10", features = ["v4"] }

Expand Down
4 changes: 4 additions & 0 deletions rdftk_core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ pub fn make_statements() -> StatementList {

## Changes

### Version 0.5.3

* Feature: add SKOS to PrefixMapping commons.

### Version 0.5.2

* Fix: bug in `hex_encode` for binary literals.
Expand Down
40 changes: 38 additions & 2 deletions rdftk_core/src/model/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::model::features::{Featured, FEATURE_GRAPH_DUPLICATES, FEATURE_RDF_STA
use crate::model::statement::{BlankNode, ObjectNode, Statement, SubjectNode};
use bimap::BiHashMap;
use rdftk_iri::{Iri, IriExtra, Name, QName};
use rdftk_names::{dc, foaf, owl, rdf, rdfs, xsd};
use rdftk_names::{dc, foaf, owl, rdf, rdfs, skos, xsd};
use std::collections::{HashMap, HashSet};
use std::fmt::{Debug, Display, Formatter};
use std::hash::Hash;
Expand Down Expand Up @@ -216,7 +216,13 @@ impl PrefixMapping {
// --------------------------------------------------------------------------------------------

pub fn common() -> Self {
Self::default().with_owl().with_rdf().with_rdfs().with_xsd()
Self::default()
.with_dc_elements()
.with_owl()
.with_rdf()
.with_rdfs()
.with_skos()
.with_xsd()
}

///
Expand Down Expand Up @@ -315,6 +321,18 @@ impl PrefixMapping {
mut_self
}

///
/// Include the common "skos" mapping.
///
pub fn with_skos(self) -> Self
where
Self: Sized,
{
let mut mut_self = self;
mut_self.insert_skos();
mut_self
}

pub fn with(self, prefix: Name, iri: Iri) -> Self
where
Self: Sized,
Expand Down Expand Up @@ -422,6 +440,24 @@ impl PrefixMapping {
);
}

pub fn insert_skos(&mut self) {
self.insert(skos::default_prefix().clone(), skos::namespace().clone());
}

pub fn insert_skos_xl(&mut self) {
self.insert(
skos::xl::default_prefix().clone(),
skos::xl::namespace().clone(),
);
}

pub fn insert_skos_iso(&mut self) {
self.insert(
skos::iso::default_prefix().clone(),
skos::iso::namespace().clone(),
);
}

///
/// Remove a mapping for the provided prefix. This operation has no effect if no mapping is present.
///
Expand Down

0 comments on commit c113623

Please sign in to comment.