Skip to content

Commit

Permalink
feat: add core to stdlib
Browse files Browse the repository at this point in the history
  • Loading branch information
johnstonskj committed Jan 23, 2024
1 parent c564c5d commit 005f6e1
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 30 deletions.
2 changes: 1 addition & 1 deletion sdml-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sdml-core"
description = "Core Model for Simple Domain Modeling Language (SDML)"
version = "0.2.4"
version = "0.2.5"
authors = ["Simon Johnston <johnstonskj@gmail.com>"]
repository = "https://github.com/johnstonskj/rust-sdml.git"
license-file = "../LICENSE"
Expand Down
20 changes: 19 additions & 1 deletion sdml-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,29 @@ Rust in-Memory model of the Simple Domain Modeling Language (SDML).

## Changes

**Version 0.2.5**

* Feature: Implemented the core standard library modules.
* `dc` (elements) -- Complete.
* `dc_terms` -- Not started.
* `dc_am` -- Not started.
* `dc_type` -- Not started.
* `owl` -- Complete.
* `rdf` -- Complete.
* `rdfs` -- Complete.
* `sdml` -- Mostly complete.
* `skos` -- Complete.
* `xsd` (part 2) -- Complete.

This change affects the `ModuleCache` as well, it's `with_stdlib` constructor will include all the library modules and their
definitions. This can be checked out with the command-line tool to either draw diagrams of the standard library modules
or convert into s-expressions, etc.

**Version 0.2.4**

* Feature: add new stdlib modules with standard layout.
* Feature: minor refactor of cache and loader.

E
**Version 0.2.3**

* Feature: Update to latest grammar for version URIs and RDF definitions.
Expand Down
136 changes: 108 additions & 28 deletions sdml-core/src/stdlib/dc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
This Rust module contains the SDML model of the SDML library module `dc`.
*/

use crate::model::definitions::Definition;
use crate::model::HasBody;
use crate::model::{
definitions::RdfDef,
identifiers::Identifier,
modules::{ImportStatement, Module},
};
use url::Url;
Expand Down Expand Up @@ -39,38 +36,121 @@ pub const PROP_TYPE_NAME: &str = "type";
// ------------------------------------------------------------------------------------------------

pub fn module() -> Module {
let rdfs_name = Identifier::new_unchecked(super::rdfs::MODULE_NAME);
let mut module = Module::empty(Identifier::new_unchecked(MODULE_NAME))
#[allow(non_snake_case)]
let MODULE_IRI: url::Url = url::Url::parse(MODULE_URL).unwrap();
let mut module = Module::empty(id!(MODULE_NAME))
.with_base_uri(Url::parse(MODULE_URL).unwrap());

module
.body_mut()
.add_to_imports(ImportStatement::new_module(rdfs_name.clone()));
.add_to_imports(ImportStatement::new_module(id!(super::rdf::MODULE_NAME)));
module
.body_mut()
.add_to_imports(ImportStatement::new_module(rdfs_name.clone()));
.add_to_imports(ImportStatement::new_module(id!(super::rdfs::MODULE_NAME)));

let properties: Vec<Definition> = [
PROP_CONTRIBUTOR_NAME,
PROP_COVERAGE_NAME,
PROP_CREATOR_NAME,
PROP_DATE_NAME,
PROP_DESCRIPTION_NAME,
PROP_FORMAT_NAME,
PROP_IDENTIFIER_NAME,
PROP_LANGUAGE_NAME,
PROP_PUBLISHER_NAME,
PROP_RELATION_NAME,
PROP_RIGHTS_NAME,
PROP_SOURCE_NAME,
PROP_SUBJECT_NAME,
PROP_TITLE_NAME,
PROP_TYPE_NAME,
]
.into_iter()
.map(|id| Definition::from(RdfDef::property(Identifier::new_unchecked(id))))
.collect();
module.body_mut().extend_definitions(properties);
module.body_mut().extend_definitions(vec![
rdf!(property PROP_CONTRIBUTOR_NAME, MODULE_IRI)
.with_comment(lstr!("An entity responsible for making contributions to the resource."@en))
.with_predicate(
id!(PROP_DESCRIPTION_NAME),
lstr!("The guidelines for using names of persons or organizations as creators also apply to contributors. Typically, the name of a Contributor should be used to indicate the entity."@en)
)
.into(),
rdf!(property PROP_COVERAGE_NAME, MODULE_IRI)
.with_comment(lstr!("The spatial or temporal topic of the resource, spatial applicability of the resource, or jurisdiction under which the resource is relevant."@en))
.with_predicate(
id!(PROP_DESCRIPTION_NAME),
lstr!("Spatial topic and spatial applicability may be a named place or a location specified by its geographic coordinates. Temporal topic may be a named period, date, or date range. A jurisdiction may be a named administrative entity or a geographic place to which the resource applies. Recommended practice is to use a controlled vocabulary such as the Getty Thesaurus of Geographic Names [[TGN](https://www.getty.edu/research/tools/vocabulary/tgn/index.html)]. Where appropriate, named places or time periods may be used in preference to numeric identifiers such as sets of coordinates or date ranges."@en)
)
.into(),
rdf!(property PROP_CREATOR_NAME, MODULE_IRI)
.with_comment(lstr!("An entity primarily responsible for making the resource."@en))
.with_predicate(
id!(PROP_DESCRIPTION_NAME),
lstr!("Examples of a Creator include a person, an organization, or a service. Typically, the name of a Creator should be used to indicate the entity."@en)
)
.into(),
rdf!(property PROP_DATE_NAME, MODULE_IRI)
.with_comment(lstr!("A point or period of time associated with an event in the lifecycle of the resource."@en))
.with_predicate(
id!(PROP_DESCRIPTION_NAME),
lstr!("Date may be used to express temporal information at any level of granularity. Recommended practice is to express the date, date/time, or period of time according to ISO 8601-1 [[ISO 8601-1](https://www.iso.org/iso-8601-date-and-time-format.html)] or a published profile of the ISO standard, such as the W3C Note on Date and Time Formats [[W3CDTF](https://www.w3.org/TR/NOTE-datetime)] or the Extended Date/Time Format Specification [[EDTF](http://www.loc.gov/standards/datetime/)]. If the full date is unknown, month and year (YYYY-MM) or just year (YYYY) may be used. Date ranges may be specified using ISO 8601 period of time specification in which start and end dates are separated by a '/' (slash) character. Either the start or end date may be missing."@en)
)
.into(),
rdf!(property PROP_DESCRIPTION_NAME, MODULE_IRI)
.with_comment(lstr!("An account of the resource."@en))
.with_predicate(
id!(PROP_DESCRIPTION_NAME),
lstr!("Description may include but is not limited to: an abstract, a table of contents, a graphical representation, or a free-text account of the resource."@en)
)
.into(),
rdf!(property PROP_FORMAT_NAME, MODULE_IRI)
.with_comment(lstr!("The file format, physical medium, or dimensions of the resource."@en))
.with_predicate(
id!(PROP_DESCRIPTION_NAME),
lstr!("Recommended practice is to use a controlled vocabulary where available. For example, for file formats one could use the list of Internet Media Types [[MIME](https://www.iana.org/assignments/media-types/media-types.xhtml)]."@en)
)
.into(),
rdf!(property PROP_IDENTIFIER_NAME, MODULE_IRI)
.with_comment(lstr!("An unambiguous reference to the resource within a given context."@en))
.with_predicate(
id!(PROP_DESCRIPTION_NAME),
lstr!("Recommended practice is to identify the resource by means of a string conforming to an identification system."@en)
)
.into(),
rdf!(property PROP_LANGUAGE_NAME, MODULE_IRI)
.with_comment(lstr!("A language of the resource."@en))
.with_predicate(
id!(PROP_DESCRIPTION_NAME),
lstr!("Recommended practice is to use either a non-literal value representing a language from a controlled vocabulary such as ISO 639-2 or ISO 639-3, or a literal value consisting of an IETF Best Current Practice 47 [[IETF-BCP47](https://tools.ietf.org/html/bcp47)] language tag."@en)
)
.into(),
rdf!(property PROP_PUBLISHER_NAME, MODULE_IRI)
.with_comment(lstr!("An entity responsible for making the resource available."@en))
.with_predicate(
id!(PROP_DESCRIPTION_NAME),
lstr!("Examples of a Publisher include a person, an organization, or a service. Typically, the name of a Publisher should be used to indicate the entity."@en)
)
.into(),
rdf!(property PROP_RELATION_NAME, MODULE_IRI)
.with_comment(lstr!("A related resource."@en))
.with_predicate(
id!(PROP_DESCRIPTION_NAME),
lstr!("Recommended practice is to identify the related resource by means of a URI. If this is not possible or feasible, a string conforming to a formal identification system may be provided."@en)
)
.into(),
rdf!(property PROP_RIGHTS_NAME, MODULE_IRI)
.with_comment(lstr!("Information about rights held in and over the resource."@en))
.with_predicate(
id!(PROP_DESCRIPTION_NAME),
lstr!("Typically, rights information includes a statement about various property rights associated with the resource, including intellectual property rights."@en)
)
.into(),
rdf!(property PROP_SOURCE_NAME, MODULE_IRI)
.with_comment(lstr!("A related resource from which the described resource is derived."@en))
.with_predicate(
id!(PROP_DESCRIPTION_NAME),
lstr!("The described resource may be derived from the related resource in whole or in part. Recommended best practice is to identify the related resource by means of a string conforming to a formal identification system."@en)
)
.into(),
rdf!(property PROP_SUBJECT_NAME, MODULE_IRI)
.with_comment(lstr!("The topic of the resource."@en))
.with_predicate(
id!(PROP_DESCRIPTION_NAME),
lstr!("Typically, the subject will be represented using keywords, key phrases, or classification codes. Recommended best practice is to use a controlled vocabulary."@en)
)
.into(),
rdf!(property PROP_TITLE_NAME, MODULE_IRI)
.with_comment(lstr!("A name given to the resource."@en))
.into(),
rdf!(property PROP_TYPE_NAME, MODULE_IRI)
.with_comment(lstr!("The nature or genre of the resource."@en))
.with_predicate(
id!(PROP_DESCRIPTION_NAME),
lstr!("Recommended practice is to use a controlled vocabulary such as the DCMI Type Vocabulary [[DCMI-TYPE](http://dublincore.org/documents/dcmi-type-vocabulary/)]. To describe the file format, physical medium, or dimensions of the resource, use the Format element."@en)
)
.into(),
]);

module
}
Expand Down

0 comments on commit 005f6e1

Please sign in to comment.