describo / type-definitions

Code and data to generate describo type definitions
MIT License
0 stars 0 forks source link

Revise type definition creation #4

Open michaelgfalk opened 8 months ago

michaelgfalk commented 8 months ago

Revise type definition creation

Once this is done we can then update the generation of the type definitions. We want this script to:

load all of the schema.org classes - probably into a map keyed on the class name (e.g. CreativeWork) join all of the relevant properties into their respective classes iterate over the extensions in the schema.org-extensions folder and add any new classes New classes should be joined in where they make sense. That is, if we were adding a class (for example) Truck an appropriate parent would be https://schema.org/Vehicle rather than https://schema.org/Thing. Not relevant for this example but something to keep in mind when creating the extensions crate

then join any properties that have been defined

finally write out a type definitions file containing an object of entity definitions keyed on the class name - see snippet following: {
..., "Restaurant": { "id": "http://schema.org/Restaurant", "name": "Restaurant", "help": "A restaurant.", "subClassOf": ["FoodEstablishment"], "allowAdditionalProperties": false, "inputs": [], "linksTo": [], "hierarchy": [ "Restaurant", "FoodEstablishment", "LocalBusiness", "Organization", "Place", "Thing" ] }, "LocalBusiness": { "id": "http://schema.org/LocalBusiness", "name": "LocalBusiness", "help": "A particular physical business or branch of an organization. Examples of LocalBusiness include a restaurant, a particular branch of a restaurant chain, a branch of a bank, a medical practice, a club, a bowling alley, etc.", "subClassOf": ["Organization", "Place"], "allowAdditionalProperties": false, "inputs": [ { "id": "http://schema.org/branchOf", "name": "branchOf", "help": "The larger organization that this local business is a branch of, if any. Not to be confused with (anatomical)[[branch]].", "multiple": true, "type": ["Organization"] }, { "id": "http://schema.org/currenciesAccepted", "name": "currenciesAccepted", "help": "The currency accepted.\n\nUse standard formats: ISO 4217 currency format e.g. \"USD\"; Ticker symbol for cryptocurrencies e.g. \"BTC\"; well known names for Local Exchange Tradings Systems (LETS) and other currency types e.g. \"Ithaca HOUR\".", "multiple": true, "type": ["Text"] }, { "id": "http://schema.org/openingHours", "name": "openingHours", "help": "The general opening hours for a business. Opening hours can be specified as a weekly time range, starting with days, then times per day. Multiple days can be listed with commas ',' separating each day. Day or time ranges are specified using a hyphen '-'.\n\n Days are specified using the following two-letter combinations: Mo, Tu, We, Th, Fr, Sa, Su.\n Times are specified using 24:00 format. For example, 3pm is specified as 15:00, 10am as 10:00. \n Here is an example: <time itemprop=\"openingHours\" datetime="Tu,Th 16:00-20:00">Tuesdays and Thursdays 4-8pm</time>.\n If a business is open 7 days a week, then it can be specified as <time itemprop="openingHours" datetime="Mo-Su">Monday through Sunday, all day</time>.", "multiple": true, "type": ["Text"] }, { "id": "http://schema.org/paymentAccepted", "name": "paymentAccepted", "help": "Cash, Credit Card, Cryptocurrency, Local Exchange Tradings System, etc.", "multiple": true, "type": ["Text"] }, { "id": "http://schema.org/priceRange", "name": "priceRange", "help": "The price range of the business, for example $$$.", "multiple": true, "type": ["Text"] } ], "linksTo": ["SpecialAnnouncement"], "hierarchy": ["LocalBusiness", "Organization", "Place", "Thing"] }, ..., To explain this structure:

"Restaurant": { "id": "http://schema.org/Restaurant", "name": "Restaurant", "help": "A restaurant.", "subClassOf": ["FoodEstablishment"], "allowAdditionalProperties": false, "inputs": [], "linksTo": [], "hierarchy": [ "Restaurant", "FoodEstablishment", "LocalBusiness", "Organization", "Place", "Thing" ] }, Consider the definition @ https://schema.org/Restaurant and note that it's a child in two different hierarchies

The key is the class name The object definition is: id: the URI to the definition of the thing, name: the short name, help: the description, subClassOf: a link to its parent class, showAdditionalProperties: unused, inputs: an array of inputs defined on this class specifically - look at the localBusiness definition for an example, linksTo: unused (I think... it's been a while), hierarchy: the class hierarchy - perhaps the most important property as it tells describo how to find the properties that can be defined for this entity. Note that it captures both of the hierarchies.

marcolarosa commented 7 months ago

@michaelgfalk

I've done some work towards this and it's all in the branch https://github.com/describo/type-definitions/tree/revise-additional-schema. Can you please take over? Look for the TODO statements in lib.js.

If you have time to take a look before our catchup Thursday we can discuss any issues that you might have.

I'm going to go back to desktop - I'll fill you in on Thursday.

michaelgfalk commented 7 months ago

No worries. I’ve pulled the branch. I’ll take a look on the train tomorrow. See you on Thursday!

I’ll look at Describo Desktop on the train as well.

Cheers,

Michael

Michael Falk | Senior Lecturer in Digital Studies | he/him English and Theatre Studies | Faculty of Arts The University of Melbourne, Victoria 3010 Australia E: @.**@.> unimelb.edu.auhttps://unimelb.edu.au/ | wikihistorieshttps://wikihistories.net/ | wikkitidyhttps://wikihistories.github.io/wikkitidy | google scholarhttps://scholar.google.com.au/citations?user=nRERD8oAAAAJ&hl=en

From: Marco La Rosa @.> Date: Sunday, 10 March 2024 at 19:40 To: describo/type-definitions @.> Cc: Michael Falk @.>, Mention @.> Subject: Re: [describo/type-definitions] Revise type definition creation (Issue #4)

@michaelgfalkhttps://github.com/michaelgfalk

I've done some work towards this and it's all in the branch https://github.com/describo/type-definitions/tree/revise-additional-schema. Can you please take over? Look for the TODO statements in lib.js.

If you have time to take a look before our catchup Thursday we can discuss any issues that you might have.

I'm going to go back to desktop - I'll fill you in on Thursday.

— Reply to this email directly, view it on GitHubhttps://github.com/describo/type-definitions/issues/4#issuecomment-1987145461, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIQO5U5WQWQS7TFEEM2W7HDYXQMBFAVCNFSM6AAAAABDF2FWHOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBXGE2DKNBWGE. You are receiving this because you were mentioned.Message ID: @.***>