| OSW Schema ID: OSWab674d663a5b472f838d8e1eb43e6784 | UUID: ab674d66-3a5b-472f-838d-8e1eb43e6784 | 📦: world.opensemantic.meta.docs.core | |
|---|---|
| ID | OSWab674d663a5b472f838d8e1eb43e6784 |
| UUID | ab674d66-3a5b-472f-838d-8e1eb43e6784 |
| Label | OSW Schema |
| Machine compatible name | OswSchema |
| Types/Categories | Article |
| Statements (outgoing) | |
| Statements (incoming) | |
|
|
|
| Details | |
| |
Description[edit source]
Documentation about to OSW data schema
| Item | |
|---|---|
| Type(s)/Category(s) | Article |
Schema for the dynamical Composition of nested class structures
Contents
- 1 Introduction
- 2 Overview
- 3 Slots
- 4 Meta-Schemas
- 5 Json-Schema
- 5.1 Base
- 5.2 Json-Editor
- 5.3 Custom Extensions
- 6 JSON-LD
- 7 Recursive Parsing
- 8 Python Code Generation
- 9 Statement
- 10 File Handling
- 11 Links
Introduction[edit | edit source]
Transforming Semantic Mediawiki into a knowledge base with structured data used to require PageForms and multiple template per class:
- Template to store the data and render the page
- Form to edit the page
- Form to query for instances of the class
- Template to render the query results
- Subtemplate to handle complex data
Reusing structures with this approach is difficult and storing data in wikicode leads to a significant lock-in regarding editing those data using existing stardards and tools.
The new concept is based on strictly storing data in json and use wikicode just for structured text and render templates. Insteaf of distributing content among multiple pages all relevent content is stored withing different slots of the same page. Additional, inheritance is highly supported and enables a broad reuse of any structure.
Overview[edit | edit source]
General[edit | edit source]
Diagram OSW concept and included technologies
Diagram diagram-01
Dual hierarchy example[edit | edit source]
Why are Categories (Classes) different from Items (Instances)?
- Pro
- Reflects rdf(s) and owl standard
- Reflects OOP in Python and other programming languages, only (?) Javascript supports a similar concepts with prototypes
- Compatible with SMW features like rdf-export and Inferencing
- Contra
- User needs to decide before creating a term or move the term later to a different namespace (renaming/redirect)
Slots[edit | edit source]
| Key | Model | Description |
|---|---|---|
| main | wikitext | default content slot, rendered between the page header and footer |
| jsonschema | json | stored within a category (=class) page, defining the schema for the jsondata slot of any category member (instance) |
| jsondata | json | structured data |
| schema_template | text | stored within a metacategory/-class, contains a handlebars template to build the jsonschema of a class from its jsondata slot |
| data_template | wikitext | stored within a category (=class) page, defining how the jsondata attributes of any category member (instance) are mapped to semantic properties |
| header_template | wikitext | stored within a category (=class) page, renders the page header of any category member (instance) |
| footer_template | wikitext | stored within a category (=class) page, renders the page footer of any category member (instance) |
| header | wikitext | renders the page header |
| footer | wikitext | renders the page footer |
| template/internal | wikitext | hidden content, not rendered. Can be used to call parser functions or lua modules |
Meta-Schemas[edit | edit source]
Category (Class) ist the default Metacategory / -class for all categories / classes. Its slot schema_template contains a handlebars template that sets schema attributes like title, allOf, description, etc. from the user generated jsondata. Additional Metacategories can be created as subclasses of Category (Class) to simplify the creation of complex schemas, e. g. Category:OSWecff4345b4b049218f8d6628dc2f2f21. This feature is compareable to python metaclasses.
Diagram meta-schema
Matecategories /-classes contain a handlebars template within the schema_template slot. The templated is evaluated with the jsondata-slot content to create / update the jsonschema-slot content of any derivated class on every edit. #Handlebars_Template_Helper and #Special_Template_Variables apply here.
Json-Schema[edit | edit source]
Diagram diagram-json
Base[edit | edit source]
https://json-schema.org/ (Draft 4)
A Jsonschema can reference other schemas. This is equivalent to [[Subcategory of::Entity]] (Semantic Mediawiki) and owl:subclass_of
{
"title": "MyEntitySubclass",
"type": "object",
"allOf": [{"$ref": "../Category/Entity.slot_jsonschema.json"}]
}
Note: refs were previously noted as "/wiki/Category:Entity?action=raw&slot=jsonschema"but this notation only works if /wiki is actually the root path of the system. Path-relative notations (./)Category:Entity and url-params are problematic so initial absolute and subsequent relative resolving is done via Special:SlotResolver, e. g. Special:SlotResolver/JsonSchema/Label.slot_main.json or Special:SlotResolver/Category/Entity.slot_jsonschema.json. To reuse a schema in an external tool you can use e. g. "$schema": "https://opensemantic.world/wiki/Special:SlotResolver/Category/Entity.slot_jsonschema.json"
Json-Editor[edit | edit source]
https://github.com/json-editor/json-editor, which is used to render edit & query forms based on provided jsonschema, adds additional keywords and options.
- Basic features: see https://github.com/json-editor/json-editor#readme
- Further details: https://github.com/json-editor/json-editor/blob/master/README_ADDON.md
- Demos: https://json-editor.github.io/json-editor/, https://pmk65.github.io/jedemov2/dist/demo.html
- Examples: https://github.com/json-editor/json-editor/tree/master/tests/pages
Autocompletion[edit | edit source]
- https://github.com/trevoreyre/autocomplete
- https://github.com/corejavascript/typeahead.js/blob/master/doc/jquery_typeahead.md (currently not supported)
Enables autocompletion in input fields. Configuration see Additional options
Custom Extensions[edit | edit source]
Embedded i18n support:[edit | edit source]
keywords title and description can be extended with additional keywords title* and description*, which hold and object with lang-keys (de, en, etc.) pointing to the translated strings.
{
"title": "Default Title",
"title*": {"en": "Title (en)", "de": "Titel (de)"}
}
Property Order[edit | edit source]
Extending json-editors definition, propertyOrder can be set to the render order of properties in the edit form. In general smaller values are on the top, larger values below. The value range 0 - 1000 is reserved for the local order of properties within the same schema. Values < 0 will move the property globally on top, values > 1000 globally to the bottom of the form. See also implementation.
Handlebars Template Helper[edit | edit source]
Whenever templates are supported, the following custom handlebars helpers are supported as well:
| Key | Syntax | Example | Example result | Description | Comment |
|---|---|---|---|---|---|
| when | {{#when <operand1> <operator> <operand2>}}...{{/when}}
|
{{#when 2 'eq' 1}}equal{{else when var1 'gt' var2}}gt{{else}}lt{{/when}}
|
gt
|
compare operator | Supported operators: see implementation |
| replace | {{#replace <find> <replace>}}{{string}}{{/replace}}
|
{{#replace "test" "test2"}}_test_{{/replace}}
|
_test2_
|
string replace operator | |
| split | {{#split <find> <index>}}<string>{{/split}}
|
{{#split "/" -1}}https://test.com/target{{/split}}
|
target
|
string split operator | |
| each_split | {{#each_split <string> <find>}}...{{/each_split}}
|
{{#each_split "https://test.com/target" "/"}}{{.}},{{/each_split}}
|
https:,,test.com,target,
|
split result iterator | |
| substring | {{#substring start end}}<string>{{/substring}}
|
{{#substring 0 -2}}My-test-string{{/substring}} => My-test-stri
|
My-test-stri
|
substring operator | negative indices are supported (counted from end-of-string) |
| calc | {{calc <operand1> <operator> <operand2>}}
{{#calc <operand1> <operator>}}<operand2>{{/calc}}
|
a={{calc (calc 1 '+' 1) '*' 10}}
b={{#calc 3 '*'}}2{{/calc}}
|
a=20 b=6
|
math callback | |
| patternformat | {{#patternformat <pattern>}}<string>{{/patternformat}}
{{patternformat <pattern> <value>}}
|
{{patternformat '00.0000' '1.1' }}
|
01.1000
|
pattern formator for both numbers and strings | |
| dateformat | {{dateformat <format> <date>}}
|
{{dateformat 'Y' (_now_)}}
|
2024
|
formats a datetime value | supported formats: https://flatpickr.js.org/formatting/ |
| _uuid_ | {{_uuid_}}
|
{{_uuid_}}
|
ad56b31f-9fe5-466a-8be7-89bce58045f1
|
uuidv4 | |
| _now_ | {{_now_}}
|
{{_now_}}
|
2024-02-04T04:31:08.050Z
|
current datetime | iso-format |
Note on helper and param naming collision: When a helper has the same name as a key in the json params, the helper is prioritized. However, you can use this.<param> to enforce the param over the helper.[1]
Example: helper 'test' returns 'helper', json data is {"test": "param"}.
Template "{{test}} {{#test}}{{/test}} {{this.test}}" will be evaluated to helper helper param
Note on escaping curly brackets: You can escape single blocks, e.g. \{{escaped}} \{{also_escaped}} {{not_escaped}} will be evaluated to {{escaped}} {{also_escaped}} some value... .[2]
Special Template Variables[edit | edit source]
Available in format: dynamic_template[edit | edit source]
| Variable | Description | Example | Example result | Note |
|---|---|---|---|---|
| _current_user_ | The identity of the current active user | {{{_current_user_}}}
|
User:MyUserName | |
| _current_subject_ | The title / OSW-ID of the current page / entry | {{{_current_subject_}}}
|
Item:OSWab674d663a5b472f838d8e1eb43e6784 | |
| _array_index_ | The index of an array item within its parent array | {{{_array_index_}}}
|
1 | |
| _global_index_ | Retrieves the smallest non-existing prefixed index for values of the specified property (default: Property:HasId). See also Additional options / global_index | ID-{{{_global_index_}}}
|
Existing entries: "HasId::ID-0001", "HasId::ID-0002", "HasId::ID-0003"
Template resolves to "ID-0004" |
Available in slot schema_template:[edit | edit source]
| Variable | Description | Example | Example result | Note |
|---|---|---|---|---|
| _page_title | The title / OSW-ID of the current page / entry | {{{_page_title}}}
|
Category:Entity | deprecated, use _current_subject_
|
| _current_subject_ | The title / OSW-ID of the current page / entry | {{{_current_subject_}}}
|
Category:Entity | replaces _page_title
|
| self | The template itself as partial | {
"name": "Object",
"subobjects": [{
"name": "Subobject",
"subobjects": [{
"name": "Subsubobject",
"subobjects": "..."
}]
}]
}
name: {{name}}
{{#each subobject}}
{{> self}}
{{/each}}
|
name: Object
name: Subobject
name: Subsubobject
...
|
allows recursive templates, see also https://handlebarsjs.com/guide/partials.html |
Additional keywords[edit | edit source]
| Key | Alias | Subkeys | Value | Description | Note |
|---|---|---|---|---|---|
| range | - | - | <category> | range of a property in the sense of OWL restricting the class(es) the pointed item could be instance of. Currently supports only a single string. Multiple categories connected with AND or OR: tbd | Also used to generate a suitable inline editor to create or edit these items (see also $properties.<property>.options.autocomplete) |
| template | <string> | handlebars template string. Available variables: watched values | Build-in | ||
| dynamic_template | handlebars template string. Available variables: watched values | Extended template feature | |||
| eval_template | evaluation template for the current json object (while 'template' is used by jsoneditor in the UI) | eval_templates are expanded before the json data is passed to render templates and property mapping | |||
| type | mediawiki | uses the wiki template parser. Cannot handle objects and arrays => non-literals get stripped | |||
| " | mustache | uses the lua mustache template parser https://github.com/OpenSemanticLab/lustache/tree/scribunto-module-pages. Can handle objects and arrays | https://mustache.github.io/, https://stackblitz.com/edit/mustache-tester?file=index.js | ||
| " | mustache-wikitext | applies mustache first, then wikitext | wikitext parts containing {{ need to be wrapped inside {{=<% %>=}} and<%={{ }}=%>
| ||
| mode | <none> | the given template will be used to render the json object and store it's semantic data | |||
| " | render | the given template will be used to render the json object | |||
| " | store | the given template will be used to store semantic data | |||
| value | <string> | the template string | |||
| data_source_maps | see section "Remote / external data import" |
Note on default rendering in infoboxes:
- Properties of
@typexds:dateandxsd:dateTimeare rendered with{{dateformat: {{value}} | ymd}}, see https://www.mediawiki.org/wiki/Help:Magic_words#dateformat - Properites of
@type@idare rendered as links as long as they are (arrays of) string literals and no eval_template is defined.
| Key | Alias | Subkeys | Value | Description | Note |
|---|---|---|---|---|---|
| type | - | an array of category pages | if defined, the given category will be used to render the json object and store it's semantic data |
Additional options[edit | edit source]
| Key | Subkeys | SubSubkeys | Value | Example | Description | Note |
|---|---|---|---|---|---|---|
| conditional_visible | ||||||
| modes | <array> | ["default", "query"] | Display this field only in the selected modes of the editor | |||
| conditional_hide | tbd | |||||
| range | string | "Category:Item" | Shortcut for a static query [[Category:Item]][[Display_title_of_normalized::~*{{_user_input_normalized}}*]]|?... . Creates an inline editor for the given category
|
|||
| subclassof_range | string | "Category:Device" | Indicates that the target are subclasses of the given device. Inline editor will use the meta class of the given category, e. g. "Category:MetaDeviceCategory", or will use the range if given | |||
| autocomplete | buildin option | |||||
| mode | smw | query mode | for now only supports semantic mediawiki | |||
| query | [[HasLabel::~*{{_user_input}}*]]|?HasLabel=label
|
handlebars query template. Available are all keys of the current schema and _user_input, _user_input_lowercase, _user_input_normalized, _user_lang
|
|?Display_title_of=label,
| |||
| category | Category:Item | creates a static query [[Category:Item]][[Display_title_of_normalized::~*{{_user_input_normalized}}*]]|?.... Creates an inline editor for the given category
|
see also $properties.<property>.range | |||
| property | Property:HasLabel | query entities with existing value of the specified property [[HasLabel::+]][[Display_title_of_normalized::~*{{_user_input_normalized}}*]]?...
|
||||
| render_template | how to display query results in the suggestion list | |||||
| type | <array> | ["handlebars", "wikitext"] | template engines are applied in the specified order. wikitext will result in parse-API calls, which is not recommanded for large result sets | |||
| value | template string | [[{{result.fulltext}}]]
|
the actual template string. Pure handlebars templates can contain html tags like links (<a>) and images (<img>), wikitext templates need to use the wiki-syntax [[ ]]
|
wiki-links to categories need a : prefix: [[:{{result.fulltext}}]]
| ||
| label_template | how to display the item after getting selected by the user | |||||
| type | <array> | ["handlebars"] | only handlebars supported | |||
| value | template string | result.printouts.label.[0]
|
||||
| field_maps | Auto-set editor fields based on the SMW ask-API query result. Example: JsonSchema:QuantityStatement | |||||
| source_path | <jsonpath> | "$" | jsonpath to apply on the query result | |||
| template | template string | "{{{result.printouts.label.[0]}}}" | optional handlebars template applied on the json-object retrieved from the source path of the query result | |||
| target_path | <jsonpath> | "$(unit_symbol)" | jsonpath of the target field in the editor. You can use jsoneditors watch variables (recommended) to auto-generate the expression | |||
| dynamic_template | options for dynamic_template | |||||
| override | <enum value> | unstored|empty|always | always | Allow the template to override the current value of the field if the current value is undefined or an empty string (empty), was not yet stored (unstored) or always. dynamic_templates with _global_index_ default to unsafed (=> do not update the value after initial stored), user editable fields (not hidden and not readonly => only set an initial default) to emtpy, else always is used.
|
||
| global_index | ||||||
| property | <property name> | Property:HasId | The Property to determine the next lowest index of a prefixed value within the dynamic_template option. Currently hardcoded to Property:HasId
|
|||
| number_pattern | <string> | 0000 | The pattern of the index. Index = 2, pattern = 0000 => 0002. Currently hardcoded to 0000 | |||
| increment | <numver> | 1 | The increment of the index. Currently hardcoded to 1 | |||
| role | query | {"filter": "min|max|eq"} | {"filter": "min"} | Creates a semantic mediawiki query for a numerical property, e. g. if the property maps to "HasNumber", the filter is "min" and the user provided value is 3 this results in the query ">3Property "HasNumber" (as page type) with input value ">3" contains invalid characters or is incomplete and therefore can cause unexpected results during a query or annotation process." |
Autocomplete[edit | edit source]
Default setting (planned, see also Object Properties and Data / Annotation Properties)
- for data / annotation properties: existing values of the property:
{{#ask:[[<Property>::+]]|?<Property>=value}} - for object properties: existing instances of the range category:
{{#ask:[[Category:<range>]]}}
Shortcuts[edit | edit source]
category: Populates the field with instances of the given category (and its subcategories)
{
"type": "string",
"format": "autocomplete",
"options":{
"autocomplete": {
"category":"Category:X"
}
}
}
Reverse properties[edit | edit source]
There are many cases were relation are summetric, e.g. Organization employees Person <=> Person worksFor Organization.
However, usually we do not want to store this information in different schemas but allow users to edit it from both sides.
For this usecase the additional keywords x-oold-reverse-properties, x-oold-reverse-default-properties and x-oold-reverse-required are introduced
To make employees the reverse property of organization we have to
- define
employeesin the schema sectionx-oold-reverse-propertiesof Organization - define
works_forin the schema sectionx-oold-reverse-propertiesof Person - map
employeesto a semantic property, e.g.Property:worksForin the@contextof Person - map
employeeswith@reversein the@contextof Organization to the same property, compliant to JSON-LD @reverse
When loading the editor for an Organization, the editor will now prepopulate the field employees by executing the query "Which persons work for this organization"?
When storing an Organization, the editor will also load the Persons referenced in employeesand stores the current Organization in their organization field, following the @context mappings of both schemas.
Deleting a Person in employees will also delete the Organization from the corresponding field.
Example[edit | edit source]
Category:Organization
{
"@context": [
{
"employees": {
"@reverse": "Property:WorksFor",
"@type": "@id"
}
}
],
"title": "OrganizationalUnit",
"uuid": "3cb8cef2-225e-4030-92f0-98f99bc4c472",
"id": "OSW3cb8cef2225e403092f098f99bc4c472",
"type": "object",
"required": [
"type"
],
"properties": {
"...": {}
},
"x-oold-reverse-required": [],
"x-oold-reverse-defaultProperties": [
"employees"
],
"x-oold-reverse-properties": {
"employees": {
"type": "array",
"title": "Employees",
"items": {
"type": "string",
"format": "autocomplete",
"title": "Person",
"$comment": "range is Person",
"range": "Category:OSW44deaa5b806d41a2a88594f562b110e9"
}
}
}
}
Category:Person
{
"@context": [
{
"organization": {
"@id": "Property:WorksFor",
"@type": "@id"
}
}
],
"title": "Person",
"type": "object",
"uuid": "44deaa5b-806d-41a2-a885-94f562b110e9",
"defaultProperties": [
"organization"
],
"properties": {
"organization": {
"title": "Organization",
"description": "Organization(s) the person is affiliated with. E.g., university, research institute, company, etc.",
"type": "array",
"format": "table",
"items": {
"type": "string",
"title": "Organization",
"format": "autocomplete",
"range": "Category:OSW3cb8cef2225e403092f098f99bc4c472"
}
}
}
}
Remote / external data import[edit | edit source]
| Key | Alias | Subkeys | SubSubkeys | Value | Example | Description | Note |
|---|---|---|---|---|---|---|---|
| data_source_maps | - | To fetch data from an external source (by user request) and store it in the edit form | |||||
| id | <string> | pub.orcid.org | |||||
| label | <string> | ORCID | Label for the data source, displayed on the request button | ||||
| required | <array> | ["orcid"]
|
Properties of the schema that are required to send the request (typically those occure as template params in source
|
the request button is disabled if required properties are missing | |||
| source | <url> | https://pub.orcid.org/v3.0/{{#split '/' -1}}{{orcid}}{{/split}}
|
API endpoint to fetch data | supports templates. API must allow request from a foreign domain | |||
| format | <enum> | jsonld | The format of the requested resource. One of json (default), jsonld, xml, html
|
Used to set the correct contentType header field and parse the result | |||
| mode | <enum> | jsonpath | The format of the path expression in the object_map. One of jsonpath (default for json, jsonld), xpath (default for xml, html)
|
||||
| object_map | <dict> | {"first_name": "$.givenName"}
|
Stores the result of the path expression value (right-hand, evaluated on the API result) in the given key (left-hand) | Result of the path expression can be an array or object. | |||
| template_map | <dict> | Constructs a value from a handlebars template (left-hand) and asigns it to the given key (right-hand) | tbd | ||||
| request_map | tbd | ||||||
| map | tbd |
{
"...": {},
"data_source_maps": [
{
"id": "pubchem.ncbi.nlm.nih.gov",
"source": "https://pubchem.ncbi.nlm.nih.gov/rest/pug_view/data/compound/{{pubchem_cid}}/JSON",
"label": "PubChem",
"required": [
"pubchem_cid"
],
"object_map": {
"cas_numbers": "$..[?(@.TOCHeading==='CAS')].Information..Value.StringWithMarkup..String"
}
}
],
"properties": {
"pubchem_cid": {
"title": "PubChem CID",
"type": "string"
},
"cas_numbers": {
"type": "array",
"...": {}
},
"...": {}
}
}
Tests could be run on various playgrounds:
- Handlebars template: [3]
Search[edit | edit source]
Properties can be marked as inputs for the categories query form by adding the conditional_visible option. Therefor a context mapping to a SWM Property is mandatory (see #JSON-LD). With "hidden": true the property is only visible in the query form. With "hidden": false it's visible both in the edit and in the query form.
{
"@context":
"...",
{
"query_label": "Property:HasLabel"
}
],
"...": {},
"properties": {
"query_label": {
"type": "string",
"options": {
"hidden": true,
"conditional_visible": {
"modes": [
"query"
]
}
}
}
}
}
The default comperator for text properties is ~ (like), for all other properties = (equal). The comperator can be defined with the role filter option, e. g. "min" for >.
{
"@context": [
{
"start_date_min": "Property:HasStartDateAndTime"
}
],
"...": "...",
"properties": {
"start_date_min": {
"type": "string",
"format": "datetime-local",
"options": {
"flatpickr": {},
"conditional_visible": {
"modes": "query"
},
"role": {
"query": {
"filter": "min"
}
}
}
}
}
}
JSON-LD[edit | edit source]
json-ld jsonschema: https://github.com/json-ld/json-ld.org/blob/main/schemas/jsonld-schema.json
Local playground: https://wiki-dev.open-semantic-lab.org/w/extensions/MwJson/json-ld/playground/index.html
References[edit | edit source]
json-ld should be embedded into jsonschema, but has its own referencing mechanism:
{
"@context": [
"../Category/Entity.slot_jsonschema.json",
{
"Property": {"@id": "https://wiki-dev.open-semantic-lab.org/id/Property-3A", "@prefix": true},
"manufacturer": "Property:HasManufacturer"
}
],
"title": "MyEntitySubclass",
"type": "object",
"allOf": [{"$ref": "../Category/Entity.slot_jsonschema.json"}],
"properties": {
"manufacturer": {
"type": "string"
}
}
}
Example: [6]
For a remote context the same mechanism are used as in json-schema $refs. To reuse a context in external tools you can use e. g. "@context": "https://opensemantic.world/wiki/Special:SlotResolver/Category/Entity.slot_jsonschema.json" .
Property mapping[edit | edit source]
Properties with a local definition (SMW Property) are automatically mapped. Jsondata of an instance of the category could then be provided with an json-ld context:
{
"@context": [
{
"@version": 1.1,
"wiki": "https://wiki-dev.open-semantic-lab.org/id/",
"Property": {"@id": "wiki:Property-3A", "@prefix": true},
"@vocab": "https://wiki-dev.open-semantic-lab.org/id/Property-3A",
"myproperty": "Property:MyProperty",
"myproperty2": "wiki:Property-3AMyProperty",
"myproperty3": "MyProperty",
"Item": {"@id": "wiki:Item-3A", "@prefix": true},
"myObjectProperty": {"@id": "Property:MyObjectProperty", "@type": "@id"}
}
],
"myproperty": "Works by using '@prefix': true (preferred)",
"myproperty2": "Works by using 'wiki' prefix with terminating '/'",
"myproperty3": "Works by using '@vocab'",
"myObjectProperty": "Item:123456"
}
Currently there seems no way to express that a property has two ids (e. g. with "label": {"@id": ["property:HasLabel", "skos:prefLabel"]}): https://github.com/json-ld/json-ld.org/issues/160
As a workaround, an additional context notation is provided: <property>* pointing to a list of additional "@id" mappings:
{
"@context": [
{
"@version": 1.1,
"skos": "https://www.w3.org/TR/skos-reference/",
"wiki": "https://wiki-dev.open-semantic-lab.org/id/",
"Property": {"@id": "wiki:Property-3A", "@prefix": true},
"label": "skos:prefLabel",
"label*": "Property:HasLabel",
"label**": "Property:Display_title_of"
}
],
"label": "Maps externally to skos:prefLabel and internally to Property:HasLabel"
}
OSW allows mapping to external (<any_prefix>:<property>) and internal vocabs (Property:<property>). Please note that properties mapped to an external vocab are currently not available in Semantic MediaWiki and the related query interfaces. Using the * notation it is possible to map to both external vocab ("property": "<any_prefix>:<property>") and internal ("property*": "Property:<property>", "property**": "Property:<another_property>").
Object Properties and Data / Annotation Properties[edit | edit source]
Properties default to data / annotation properties (value is a literal). Object properties (value is an identifier/reference to another object) can by defined by adding "@type": "@id".
Subobjects[edit | edit source]
If the value of a mapped property is an object (after expanding all eval_templates), it will get stored as a smw subobject with an id derivated from the field uuid, a display title from mapped Property:HasLabel, Property:HasName or Property:Display title of (fallback values of keywordslabel or name or the schema title of the property pointing to the object) and a category from type (if provided). Subobjects also support JSON-LD @reverse notation, allowing to store properties pointing from the subobject to the superordinated or root object.
Example: can be selected with [[MyObjectProperty.MyProperty::myvalue]]
{
"@context": [
{
"@version": 1.1,
"wiki": "https://wiki-dev.open-semantic-lab.org/id/",
"Property": {"@id": "wiki:Property-3A", "@prefix": true},
"myproperty": "Property:MyProperty",
"Item": {"@id": "wiki:Item-3A", "@prefix": true},
"myObjectProperty": {"@id": "Property:MyObjectProperty", "@type": "@id"}
}
],
"myObjectProperty": {
"uuid": "2ea5b605-c91f-4e5a-9559-3dff79fdd4a5",
"name": "MySubobject",
"myproperty": "myvalue"
}
}
Labels and i18n[edit | edit source]
i18n language keys can be embedded in to an label object to create a language tagged string
{
"@context": [
{
"@version": 1.1,
"skos": "https://www.w3.org/TR/skos-reference/",
"label": {"@id": "skos:prefLabel", "@container": "@language"},
"label2": {"@id": "skos:prefLabel"},
"label_text": {"@id": "@value"},
"label_lang_key": {"@id": "@language"}
}
],
"label": {"en": "'Text' gets transformed to 'Text@en' by applying @container"},
"label2": {"label_text": "'Text' gets transformed to 'Text@de' by subkeys @id's", "label_lang_key": "de"}
}
Ontology term import/export[edit | edit source]
Existing ontology terms can be imported/exported via json-ld directly or ttl by defining the corresponding context, e. g. for EMMO-Terms: [7]
Matching external vocabularies and ontologies[edit | edit source]
As explained above, JSON-LD's @context allows to map properties to external vocabularies and ontologies.
In order to map classes and instances, additional annotation properties are provided:
rdf_type- stating this entity is instance of an additional rdf class, see also https://schema.org/additionalType
exact_ontology_match- stating an exact match, expressed by mapping toowl:sameAs | owl:equivalentClass | owl:equivalentProperty(see below) andskos:exactMatchexternally, as well as internally toProperty:Equivalent_URIandProperty:HasExactOntologyMatchclose_ontology_match- stating a close exact match, expressed by mapping toskos:closeMatchexternally, as well as internally toProperty:Equivalent_URIandProperty:HasCloseOntologyMatch
This properties were originally available via a Characteristic type, called Ontology related, that can be mixed in by inheritance via an allOf in the respective schema. However, they are now integrated in the common Category:Entity for general availability.
rdf_type - Asserting additional types on instances[edit | edit source]
rdf_type has direct implication on the type system. The value must be a full IRI, e.g. https://schema.org/Person. Defined in Category:Entity it states additional RDF types for an Entity, which are directly applied.
rdf_type is mapped to rdfs:type, implying that an Item has additional RDF types, as stated by the JSON data on this property. A JSON-LD export of the JSON-data of this "Item" will contain a respective @type entry.
Ontology annotation - annotating conceptual proximity of an instance or class[edit | edit source]
To provide an annotation, e.g. to state that an Entity (Item or Category) matches a concept within an external ontology (closely), we have two properties exact_ontology_match and close_ontology_match.
The value must be a full IRI, e.g. https://schema.org/Person
While the meaning of close_ontology_match is constantly defined as stated above, the @context mapping of exact_ontology_match differs depending on the inheriting Category (Class) Schema:
Category:Entity
Abstract definition of the property.
Category:Item
Definition of the property for instances of the class (category) or its subclasses = Entities within the Item namespace.
exact_ontology_match is here mapped to owl:sameAs, implying that an Item has the same meaning as an external concept.
Category:Category (Class)
Definition of the property for instances of the class Category (Class) or its subclasses = Entities within the Category namespace, which themselves are categories.
exact_ontology_match maps to owl:equivalentClass, thereby stating that this Category is a concept equivalent to a class defined in an external vocabulary. Note: Instances of this class or category will only contain the additional @type if additional reasoning was applied by the export algorithm.
Category:Property
Definition of the property for instances of the class Property or its subclasses = Entities within the Property namespace, which are Semantic MediaWiki properties.
exact_ontology_match maps to owl:equivalentProperty, implying that a Property is equivalent to a property in an external vocabulary, e.g. https://schema.org/address which is an attribute of https://schema.org/Person.
Examples[edit | edit source]
Asserting equivalent class[edit | edit source]
The Category Person has a property exact_ontology_match with value https://schema.org/Person thereby stating that this concept is equivalent to the concept Person in schema.org.
Annotating equivalent instance[edit | edit source]
The instance of Quantity Unit "kilo gram" can state that it is equivalent to https://qudt.org/vocab/unit/KiloGM.
Recursive Parsing[edit | edit source]
Module:Category[edit | edit source]
Called from Category:<UUID>@template
Synchonize Category:<UUID>@jsondata.subclass_of with Category:<UUID>@jsonschema.allOfExpand Category:Category@header_template with jsondata parametersRender Category:<UUID>@mainExpand Category:Category@footer_template with jsondata parameters
Module:Entity[edit | edit source]
Called from item@template, item = Item:<UUID>
Recursion[edit | edit source]
- For each Item:<UUID>@jsondata.osl_category as category:
- For each category@jsondata.osl_category or category@jsonschema.allOf as supercategory:
- For each supercategory@jsondata.osl_category or supercategory@jsonschema.allOf as supersupercategory:
- ...
- Expand supercategory@header_template with item@jsondata parameters. Fallback: Render infobox
- Expand supercategory@data_template with item.jsondata parameters. Fallback: Use Json-LD mapping within category:jsonschema
- For each supercategory@jsondata.osl_category or supercategory@jsonschema.allOf as supersupercategory:
- If category@header_template: Expand category@header_template with item@jsondata parameters
- Else: Render infobox with all attribute-value pairs
- Expand category@data_template with item.jsondata parameters. Fallback: Use Json-LD mapping within category:jsonschema
- For each category@jsondata.osl_category or category@jsonschema.allOf as supercategory:
- Render item@main
- footer...
Data Storing[edit | edit source]
- template specified: use template
- category specified:
- category@data_template specified: use data_template
- Use Json-LD mapping
- mapping specified: Store semantic property
- Literal value: store value
- Object value
- Property has type text/code: Store json string
- osl_category / osl_template specifided: see below
- Don't store semantic property
- mapping specified: Store semantic property
Nested objects within item@jsondata are handled
- osl_category: same handling as the root object, but:
- Rendering with category@header_template. Fallback: Nested info box
- Data storing with category@data_template. Fallback: Creating a subobject with Json-LD mapping + (inverse) semantic relation to the root object
- osl_template: expand the template, return value is asigned to the property
Python Code Generation[edit | edit source]
see https://github.com/OpenSemanticLab/osw-python
Statement[edit | edit source]
| s | p/s | o/p/s | o/p | o... |
|---|---|---|---|---|
| PCB | contains | Lead | ||
| contains | HasMassConcentration | 10% | ||
| HasMassConcentration | HasPrecision | 1% | ||
| PCB | contains | Gold |
File Handling[edit | edit source]
Copy-Policy[edit | edit source]
drop: do not copy the file
copy: copy the file and store the reference to it
copy-ref: store the referece to the original file
ask-on-edit: store the reference but ask the user to copy the original file when he tries to edit it (current_page != creation_page)
Meta-Data[edit | edit source]
HasProject=project inherit: permissions from project
HasCreationPage=creation_page: wiki page within this file was created
HasEditPage=edit_page: wiki page within this file was edited
HasCreator=creator: initial creator of the file
HasEditor=editor: editors of the file
Links[edit | edit source]
Graph
QR Code
Attachments[edit source]
📎 Select files (or drop them here)... 📷 Camera
jsondata
| type |
| |||||
|---|---|---|---|---|---|---|
| uuid | "ab674d66-3a5b-472f-838d-8e1eb43e6784" | |||||
| label |
| |||||
| description |
| |||||
| name | "OswSchema" | |||||
| attachments |
|