EntitySchema talk:E1

From geokb
Revision as of 23:00, 21 June 2023 by Joliveros (talk | contribs) (Created page with "<span id="creating-an-entityschema"></span> = Creating an EntitySchema = <span id="definitions"></span> == Definitions == ShEx and EntitySchemas are used interchangibly for the most part, but to be precise in the semantics EntitySchemas are items found within the GeoKB with an EID (e.g. E1) that have ShEx statements within. ShExC stands for ShEx Compact, which is the syntax used (There is also ShExJ and ShExR but those cannot be used within the GeoKB). <span id="reso...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Creating an EntitySchema

Definitions

ShEx and EntitySchemas are used interchangibly for the most part, but to be precise in the semantics EntitySchemas are items found within the GeoKB with an EID (e.g. E1) that have ShEx statements within. ShExC stands for ShEx Compact, which is the syntax used (There is also ShExJ and ShExR but those cannot be used within the GeoKB).

Resources

  • To learn more on how ShEx works, Validating RDF has plenty of examples for what’s possible
  • The author of the book also had a workshop showing how to create ShEx statements.
  • Some of the notation is based on Regular Expressions. The Quantifiers section of this page could be useful in understanding.
  • The WikiShape tool is essential to make sure that the desired EntitySchemas are being created.

Entering into GeoKB

From the Main Page click on New Schema. If the link cannot be found or has been moved, go to Special PagesWikibaseCreate a new Entityschema or follow this link.

Validation

Validating a schema can be done using the Wikishape tool. Unfortunately the SPARQL endpoint doesn’t work properly and does not give a descriptive enough error as to why but the ShExC section works. An existing QItem must be in the GeoKB for the validation process to work.

Example

Within the SPARQL_examples discussion there is a query that finds mineral commodities. By running the query we see that aluminum (Q293) is one of the results. Go to the Wikishape tool and add the item QID in the corresponding box and copy over the ShExC found within EntitySchema E6. This link shows the result of the validation.

Debugging for validity

A drawback of the Wikishape tool is that if an error occurs, it does not tell you what the issue is or where to find it within the schema. The best method I have found is to start from the loosest restrictions for the shape wanted and add restrictions one at a time, validating at each step. For example, if I wanted the least restrictions for E6 I would write

prefix wd: <https://geokb.wikibase.cloud/entity/>
PREFIX wdt: <https://geokb.wikibase.cloud/prop/direct/>

START = @<Commodity>

<Commodity> EXTRA wdt:P1 {
  wdt:P1 [ wd:Q406 ] * ; # Mineral Commodity
  wdt:P1 [ wd:Q280 ] * ; # Chemical Element
  wdt:P1 [ wd:Q24 ] * ; # Mineral
}

This will validate against any QItem successfully since * represents 0 or more matches.