sdml_core/stdlib/
skos.rs

1/**
2This Rust module contains the SDML model of the SDML library module `skos` for SKOS.
3*/
4use crate::model::annotations::AnnotationBuilder;
5use crate::model::modules::Module;
6use crate::model::HasBody;
7use crate::stdlib::{owl, rdf, rdfs};
8use url::Url;
9
10// ------------------------------------------------------------------------------------------------
11// Public Macros
12// ------------------------------------------------------------------------------------------------
13
14// ------------------------------------------------------------------------------------------------
15// Public Types
16// ------------------------------------------------------------------------------------------------
17
18pub const MODULE_NAME: &str = "skos";
19pub const MODULE_URL: &str = "http://www.w3.org/2004/02/skos/core#";
20
21pub const COLLECTION: &str = "Collection";
22pub const CONCEPT: &str = "Concept";
23pub const CONCEPT_SCHEME: &str = "ConceptScheme";
24pub const ORDERED_COLLECTION: &str = "OrderedCollection";
25
26pub const ALT_LABEL: &str = "altLabel";
27pub const BROAD_MATCH: &str = "broadMatch";
28pub const BROADER: &str = "broader";
29pub const BROADER_TRANSITIVE: &str = "broaderTransitive";
30pub const CHANGE_NOTE: &str = "changeNote";
31pub const CLOSE_MATCH: &str = "closeMatch";
32pub const DEFINITION: &str = "definition";
33pub const EDITORIAL_NOTE: &str = "editorialNote";
34pub const EXACT_MATCH: &str = "exactMatch";
35pub const EXAMPLE: &str = "example";
36pub const HAS_TOP_CONCEPT: &str = "hasTopConcept";
37pub const HIDDEN_LABEL: &str = "hiddenLabel";
38pub const HISTORY_NOTE: &str = "historyNote";
39pub const IN_SCHEME: &str = "inScheme";
40pub const MAPPING_RELATION: &str = "mappingRelation";
41pub const MEMBER: &str = "member";
42pub const MEMBER_LIST: &str = "memberList";
43pub const NARROW_MATCH: &str = "narrowMatch";
44pub const NARROWER: &str = "narrower";
45pub const NARROWER_TRANSITIVE: &str = "narrowerTransitive";
46pub const NOTATION: &str = "notation";
47pub const NOTE: &str = "note";
48pub const PREF_LABEL: &str = "prefLabel";
49pub const RELATED: &str = "related";
50pub const RELATED_MATCH: &str = "relatedMatch";
51pub const SCOPE_NOTE: &str = "scopeNote";
52pub const SEMANTIC_RELATION: &str = "semanticRelation";
53pub const TOP_CONCEPT_OF: &str = "topConceptOf";
54
55// ------------------------------------------------------------------------------------------------
56// Public Functions
57// ------------------------------------------------------------------------------------------------
58
59pub fn module() -> Module {
60    #[allow(non_snake_case)]
61    let MODULE_IRI: url::Url = url::Url::parse(MODULE_URL).unwrap();
62    let mut module = Module::empty(id!(MODULE_NAME)).with_base_uri(Url::parse(MODULE_URL).unwrap());
63
64    module
65        .body_mut()
66        .add_to_imports(import!(id!(rdf::MODULE_NAME), id!(rdfs::MODULE_NAME)));
67
68    module.body_mut().extend_definitions(vec![
69        rdf!(class COLLECTION, MODULE_IRI)
70            .with_predicate(
71                qualid!(owl::MODULE_NAME, owl::DISJOINT_WITH),
72                seq!(
73                    idref!(CONCEPT),
74                    idref!(CONCEPT_SCHEME)
75                )
76            )
77            .with_predicate(
78                id!(DEFINITION),
79                lstr!("Labelled collections can be used where you would like a set of concepts
80to be displayed under a 'node label' in the hierarchy."@en)
81            )
82            .with_predicate(
83                id!(SCOPE_NOTE),
84                lstr!("Labelled collections can be used where you would like a set of concepts
85to be displayed under a 'node label' in the hierarchy."@en)
86            )
87            .into(),
88        rdf!(class CONCEPT, MODULE_IRI)
89            .with_predicate(
90                id!(DEFINITION),
91                lstr!("An idea or notion; a unit of thought."@en)
92            )
93            .into(),
94        rdf!(class CONCEPT_SCHEME, MODULE_IRI)
95            // Label: Concept Scheme
96            .with_predicate(
97                qualid!(owl::MODULE_NAME, owl::DISJOINT_WITH),
98                idref!(CONCEPT)
99            )
100            .with_predicate(
101                id!(DEFINITION),
102                lstr!("A set of concepts, optionally including statements about semantic
103relationships between those concepts."@en)
104            )
105            .with_predicate(
106                id!(EXAMPLE),
107                lstr!("Thesauri, classification schemes, subject heading lists, taxonomies,
108'folksonomies', and other types of controlled vocabulary are all examples of concept schemes.
109Concept schemes are also embedded in glossaries and terminologies."@en)
110            )
111            .with_predicate(
112                id!(SCOPE_NOTE),
113                lstr!("A concept scheme may be defined to include concepts from different
114sources."@en)
115            )
116             .into(),
117        rdf!(class ORDERED_COLLECTION, MODULE_IRI; COLLECTION)
118            .with_predicate(
119                id!(DEFINITION),
120                lstr!("An ordered collection of concepts, where both the grouping and the
121ordering are meaningful."@en)
122            )
123            .with_predicate(
124                id!(SCOPE_NOTE),
125                lstr!("Ordered collections can be used where you would like a set of concepts
126 to be displayed in a specific order, and optionally under a 'node label'."@en)
127            )
128             .into(),
129
130        // Properties
131        rdf!(property ALT_LABEL, MODULE_IRI, (rdfs::MODULE_NAME, rdfs::LABEL))
132            .with_type(qualid!(owl::MODULE_NAME, owl::ANNOTATION_PROPERTY))
133            .with_comment(lstr!("skos:prefLabel, skos:altLabel and skos:hiddenLabel are
134pairwise disjoint properties."@en))
135            .with_predicate(
136                id!(DEFINITION),
137                lstr!("An alternative lexical label for a resource."@en)
138            )
139            .with_predicate(
140                id!(EXAMPLE),
141                lstr!("Acronyms, abbreviations, spelling variants, and irregular plural/singular
142forms may be included among the alternative labels for a concept. Mis-spelled terms are normally
143 included as hidden labels (see skos:hiddenLabel)"@en)
144            )
145            .into(),
146        rdf!(property BROAD_MATCH, MODULE_IRI, BROADER, MAPPING_RELATION)
147            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
148            .with_predicate(
149                qualid!(owl::MODULE_NAME, owl::INVERSE_OF),
150                idref!(NARROW_MATCH)
151            )
152            .with_predicate(
153                id!(DEFINITION),
154                lstr!("skos:broadMatch is used to state a hierarchical mapping link between
155two conceptual resources in different concept schemes."@en)
156            )
157            .into(),
158        rdf!(property BROADER, MODULE_IRI, BROADER_TRANSITIVE)
159            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
160            .with_predicate(
161                qualid!(owl::MODULE_NAME, owl::INVERSE_OF),
162                idref!(NARROWER)
163            )
164            .with_comment(lstr!("Broader concepts are typically rendered as parents in a
165concept hierarchy (tree)."@en))
166            .with_predicate(
167                id!(DEFINITION),
168                lstr!("Relates a concept to a concept that is more general in meaning."@en)
169            )
170            .with_predicate(
171                id!(SCOPE_NOTE),
172                lstr!("By convention, skos:broader is only used to assert an immediate
173(i.e. direct) hierarchical link between two conceptual resources."@en)
174            )
175            .into(),
176        rdf!(property BROADER_TRANSITIVE, MODULE_IRI, SEMANTIC_RELATION)
177            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
178            .with_type(qualid!(owl::MODULE_NAME, owl::TRANSITIVE_PROPERTY))
179            .with_predicate(
180                qualid!(owl::MODULE_NAME, owl::INVERSE_OF),
181                idref!(NARROWER_TRANSITIVE)
182            )
183            .with_predicate(
184                id!(DEFINITION),
185                lstr!("skos:broaderTransitive is a transitive superproperty of skos:broader."@en)
186            )
187            .with_predicate(
188                id!(SCOPE_NOTE),
189                lstr!("By convention, skos:broaderTransitive is not used to make assertions.
190 Rather, the properties can be used to draw inferences about the transitive closure of the
191 hierarchical relation, which is useful e.g. when implementing a simple query expansion
192 algorithm in a search application."@en)
193            )
194            .into(),
195        rdf!(property CHANGE_NOTE, MODULE_IRI, NOTE)
196            .with_type(qualid!(owl::MODULE_NAME, owl::ANNOTATION_PROPERTY))
197            .with_predicate(
198                id!(DEFINITION),
199                lstr!("A note about a modification to a concept."@en)
200            )
201            .into(),
202        rdf!(property CLOSE_MATCH, MODULE_IRI, MAPPING_RELATION)
203            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
204            .with_type(qualid!(owl::MODULE_NAME, owl::SYMMETRIC_PROPERTY))
205            .with_predicate(
206                id!(DEFINITION),
207                lstr!("skos:closeMatch is used to link two concepts that are sufficiently similar
208 that they can be used interchangeably in some information retrieval applications. In order to
209avoid the possibility of \"compound errors\" when combining mappings across more than two concept
210 schemes, skos:closeMatch is not declared to be a transitive property."@en)
211            )
212             .into(),
213        rdf!(property DEFINITION, MODULE_IRI, NOTE)
214            .with_type(qualid!(owl::MODULE_NAME, owl::ANNOTATION_PROPERTY))
215            .with_predicate(
216                id!(DEFINITION),
217                lstr!("A statement or formal explanation of the meaning of a concept."@en)
218            )
219            .into(),
220        rdf!(property EDITORIAL_NOTE, MODULE_IRI, NOTE)
221            .with_type(qualid!(owl::MODULE_NAME, owl::ANNOTATION_PROPERTY))
222            .with_predicate(
223                id!(DEFINITION),
224                lstr!("A note for an editor, translator or maintainer of the vocabulary."@en)
225            )
226            .into(),
227        rdf!(property EXACT_MATCH, MODULE_IRI, CLOSE_MATCH)
228            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
229            .with_type(qualid!(owl::MODULE_NAME, owl::SYMMETRIC_PROPERTY))
230            .with_type(qualid!(owl::MODULE_NAME, owl::TRANSITIVE_PROPERTY))
231            .with_comment(lstr!("skos:exactMatch is disjoint with each of the properties
232skos:broadMatch and skos:relatedMatch."@en))
233            .with_predicate(
234                id!(DEFINITION),
235                lstr!("skos:exactMatch is used to link two concepts, indicating a high
236degree of confidence that the concepts can be used interchangeably across a wide range
237of information retrieval applications. skos:exactMatch is a transitive property, and is
238a sub-property of skos:closeMatch."@en)
239            )
240            .into(),
241        rdf!(property EXAMPLE, MODULE_IRI, NOTE)
242            .with_type(qualid!(owl::MODULE_NAME, owl::ANNOTATION_PROPERTY))
243            .with_predicate(
244                id!(DEFINITION),
245                lstr!("An example of the use of a concept."@en)
246            )
247            .into(),
248        rdf!(property HAS_TOP_CONCEPT, MODULE_IRI;
249             CONCEPT_SCHEME => CONCEPT)
250            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
251            .with_predicate(
252                qualid!(owl::MODULE_NAME, owl::INVERSE_OF),
253                idref!(TOP_CONCEPT_OF)
254            )
255            .with_predicate(
256                id!(DEFINITION),
257                lstr!("Relates, by convention, a concept scheme to a concept which is
258topmost in the broader/narrower concept hierarchies for that scheme, providing an entry
259 point to these hierarchies."@en)
260            )
261            .into(),
262        rdf!(property HIDDEN_LABEL, MODULE_IRI, (rdfs::MODULE_NAME, rdfs::LABEL))
263            .with_type(qualid!(owl::MODULE_NAME, owl::ANNOTATION_PROPERTY))
264            .with_predicate(
265                id!(DEFINITION),
266                lstr!("A lexical label for a resource that should be hidden when generating
267visual displays of the resource, but should still be accessible to free text search operations."@en)
268            )
269            .into(),
270        rdf!(property HISTORY_NOTE, MODULE_IRI, NOTE)
271            .with_type(qualid!(owl::MODULE_NAME, owl::ANNOTATION_PROPERTY))
272            .with_predicate(
273                id!(DEFINITION),
274                lstr!("A note about the past state/use/meaning of a concept."@en)
275            )
276            .into(),
277        rdf!(property IN_SCHEME, MODULE_IRI => CONCEPT_SCHEME)
278            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
279            .with_predicate(
280                id!(DEFINITION),
281                lstr!("Relates a resource (for example a concept) to a concept scheme in which
282 it is included."@en)
283            )
284           .with_predicate(
285                id!(SCOPE_NOTE),
286                lstr!("A concept may be a member of more than one concept scheme."@en)
287            )
288            .into(),
289        rdf!(property MAPPING_RELATION, MODULE_IRI, SEMANTIC_RELATION)
290            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
291            .with_comment(lstr!("These concept mapping relations mirror semantic relations,
292 and the data model defined below is similar (with the exception of skos:exactMatch) to the
293 data model defined for semantic relations. A distinct vocabulary is provided for concept
294 mapping relations, to provide a convenient way to differentiate links within a concept scheme
295 from links between concept schemes. However, this pattern of usage is not a formal requirement
296 of the SKOS data model, and relies on informal definitions of best practice."@en))
297             .with_predicate(
298                 id!(DEFINITION),
299                 lstr!("Relates two concepts coming, by convention, from different schemes,
300 and that have comparable meanings."@en)
301            )
302            .into(),
303        rdf!(property MEMBER, MODULE_IRI; COLLECTION)
304            // rdfs:range [ a owl:Class ; owl:unionOf (skos:Concept skos:Collection) ]
305            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
306            .with_predicate(
307                id!(DEFINITION),
308                lstr!("Relates a collection to one of its members."@en)
309            )
310            .into(),
311        rdf!(property MEMBER_LIST, MODULE_IRI;
312             ORDERED_COLLECTION => (rdf::MODULE_NAME, rdf::LIST))
313            .with_type(qualid!(owl::MODULE_NAME, owl::FUNCTIONAL_PROPERTY))
314            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
315            .with_predicate(
316                id!(DEFINITION),
317                lstr!("Relates an ordered collection to the RDF list containing its members."@en)
318            )
319            .into(),
320        rdf!(property NARROW_MATCH, MODULE_IRI, MAPPING_RELATION, NARROWER)
321            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
322            .with_predicate(
323                qualid!(owl::MODULE_NAME, owl::INVERSE_OF),
324                idref!(BROAD_MATCH)
325            )
326            .with_predicate(
327                id!(DEFINITION),
328                lstr!("skos:narrowMatch is used to state a hierarchical mapping link between two
329conceptual resources in different concept schemes."@en)
330            )
331            .into(),
332        rdf!(property NARROWER, MODULE_IRI, NARROWER_TRANSITIVE)
333            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
334            .with_predicate(
335                qualid!(owl::MODULE_NAME, owl::INVERSE_OF),
336                idref!(BROADER)
337            )
338            .with_comment(lstr!("Narrower concepts are typically rendered as children in a
339 concept hierarchy (tree)."@en))
340            .with_predicate(
341                id!(DEFINITION),
342                lstr!("Relates a concept to a concept that is more specific in meaning."@en)
343            )
344            .with_predicate(
345                id!(SCOPE_NOTE),
346                lstr!("By convention, skos:broader is only used to assert an immediate (i.e.
347 direct) hierarchical link between two conceptual resources."@en)
348            )
349            .into(),
350        rdf!(property NARROWER_TRANSITIVE, MODULE_IRI, SEMANTIC_RELATION)
351            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
352            .with_type(qualid!(owl::MODULE_NAME, owl::TRANSITIVE_PROPERTY))
353            .with_predicate(
354                qualid!(owl::MODULE_NAME, owl::INVERSE_OF),
355                idref!(BROADER_TRANSITIVE)
356            )
357            .with_predicate(
358                id!(DEFINITION),
359                lstr!("skos:narrowerTransitive is a transitive superproperty of skos:narrower."@en)
360            )
361            .with_predicate(
362                id!(SCOPE_NOTE),
363                lstr!("By convention, skos:narrowerTransitive is not used to make assertions.
364Rather, the properties can be used to draw inferences about the transitive closure of the
365hierarchical relation, which is useful e.g. when implementing a simple query expansion
366algorithm in a search application."@en)
367            )
368            .into(),
369        rdf!(property NOTATION, MODULE_IRI)
370            .with_type(qualid!(owl::MODULE_NAME, owl::DATATYPE_PROPERTY))
371            .with_predicate(
372                id!(DEFINITION),
373                lstr!("A notation, also known as classification code, is a string of
374characters such as \"T58.5\" or \"303.4833\" used to uniquely identify a concept within
375the scope of a given concept scheme."@en)
376            )
377            .with_predicate(
378                id!(SCOPE_NOTE),
379                lstr!("By convention, skos:notation is used with a typed literal in the
380object position of the triple."@en)
381            )
382            .into(),
383        rdf!(property NOTE, MODULE_IRI)
384            .with_type(qualid!(owl::MODULE_NAME, owl::ANNOTATION_PROPERTY))
385            .with_predicate(
386                id!(DEFINITION),
387                lstr!("A general note, for any purpose."@en)
388            )
389             .with_predicate(
390                id!(SCOPE_NOTE),
391                 lstr!("This property may be used directly, or as a super-property for
392more specific note types."@en)
393            )
394             .into(),
395        rdf!(property PREF_LABEL, MODULE_IRI, (rdfs::MODULE_NAME, rdfs::LABEL))
396            .with_type(qualid!(owl::MODULE_NAME, owl::ANNOTATION_PROPERTY))
397            .with_comment(lstr!("A resource has no more than one value of skos:prefLabel per
398language tag, and no more than one value of skos:prefLabel without language tag."@en))
399            .with_comment(lstr!("The range of skos:prefLabel is the class of RDF plain literals."@en))
400            .with_comment(lstr!("skos:prefLabel, skos:altLabel and skos:hiddenLabel are pairwise
401disjoint properties."@en))
402            .with_predicate(
403                id!(DEFINITION),
404                lstr!("The preferred lexical label for a resource, in a given language."@en)
405            )
406            .into(),
407        rdf!(property RELATED, MODULE_IRI, SEMANTIC_RELATION)
408            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
409            .with_type(qualid!(owl::MODULE_NAME, owl::SYMMETRIC_PROPERTY))
410            .with_comment(lstr!("skos:related is disjoint with skos:broaderTransitive"@en))
411            .with_predicate(
412                id!(DEFINITION),
413                lstr!("Relates a concept to a concept with which there is an associative
414semantic relationship."@en)
415            )
416             .into(),
417        rdf!(property RELATED_MATCH, MODULE_IRI, MAPPING_RELATION, RELATED)
418            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
419            .with_type(qualid!(owl::MODULE_NAME, owl::SYMMETRIC_PROPERTY))
420            .with_predicate(
421                id!(DEFINITION),
422                lstr!("skos:relatedMatch is used to state an associative mapping link between
423two conceptual resources in different concept schemes."@en)
424            )
425            .into(),
426        rdf!(property SCOPE_NOTE, MODULE_IRI, NOTE)
427            .with_type(qualid!(owl::MODULE_NAME, owl::ANNOTATION_PROPERTY))
428            .with_predicate(
429                id!(DEFINITION),
430                lstr!("A note that helps to clarify the meaning and/or the use of a concept."@en)
431            )
432            .into(),
433        rdf!(property SEMANTIC_RELATION, MODULE_IRI;
434             CONCEPT => CONCEPT)
435            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
436            .with_predicate(
437                id!(DEFINITION),
438                lstr!("Links a concept to a concept related by meaning."@en)
439            )
440            .with_predicate(
441                id!(SCOPE_NOTE),
442                lstr!("This property should not be used directly, but as a super-property for
443all properties denoting a relationship of meaning between concepts."@en)
444            )
445            .into(),
446        rdf!(property TOP_CONCEPT_OF, MODULE_IRI, IN_SCHEME;
447             CONCEPT => CONCEPT_SCHEME)
448            .with_type(qualid!(owl::MODULE_NAME, owl::OBJECT_PROPERTY))
449            .with_predicate(
450                qualid!(owl::MODULE_NAME, owl::INVERSE_OF),
451                idref!(HAS_TOP_CONCEPT)
452            )
453            .with_predicate(
454                id!(DEFINITION),
455                lstr!("Relates a concept to the concept scheme that it is a top level concept of."@en)
456            )
457            .into(),
458    ]).unwrap();
459
460    module
461}