### Setup Schema.org Environment Source: https://github.com/schemaorg/doc_update/blob/main/software/scripts/Schema_org_Examples.ipynb Configures the data source for Schema.org terms and examples, downloads required Python libraries, and installs dependencies. It also handles cloning the schemaorg repository if needed. ```python DataSource = "Github:main" #@param ["Github:main", "staging.schema.org", "schema.org"] {allow-input: true} gitpullrequired = False if DataSource == "Github:main": gitpullrequired = True termSource = "default" examplesSource = "default" elif DataSource == "staging.schema.org": termSource = "https://staging.schema.org/version/latest/schemaorg-current-http.ttl" examplesSource = "https://staging.schema.org/version/latest/schemaorg-all-examples.txt" elif DataSource == "schema.org": termSource = "https://schema.org/version/latest/schemaorg-current-http.ttl" examplesSource = "https://schema.org/version/latest/schemaorg-all-examples.txt" os.chdir("/content") if not os.path.isdir("lib"): !mkdir lib for path in [os.getcwd(),"lib","/content/lib"]: sys.path.insert( 1, path ) #Pickup libs from shipped lib directory print("Loading schemaorg support libraries ...") !(cd lib; curl -s -O https://raw.githubusercontent.com/schemaorg/schemaorg/main/SchemaTerms/sdotermsource.py) !(cd lib; curl -s -O https://raw.githubusercontent.com/schemaorg/schemaorg/main/SchemaTerms/sdoterm.py) !(cd lib; curl -s -O https://raw.githubusercontent.com/schemaorg/schemaorg/main/SchemaTerms/localmarkdown.py) !(cd lib; curl -s -O https://raw.githubusercontent.com/schemaorg/schemaorg/main/SchemaExamples/schemaexamples.py) !(cd lib; curl -s -O https://raw.githubusercontent.com/schemaorg/schemaorg/main/requirements.txt) !pip --quiet install -r lib/requirements.txt from schemaexamples import SchemaExamples, Example from sdotermsource import SdoTermSource from sdoterm import * from localmarkdown import Markdown Markdown.setWikilinkCssClass("localLink") Markdown.setWikilinkPrePath("https://schema.org/") Markdown.setWikilinkPostPath("") if gitpullrequired: print("\nPulling data from schemaorg repository...") if os.path.isdir("schemaorg"): !rm -r schemaorg !git clone https://github.com/schemaorg/schemaorg.git os.chdir("schemaorg") #If sources are 'default' file paths are relative to schemaorg dir. print("\nLoading triples file(s)") SdoTermSource.loadSourceGraph(termSource,init=True) print ("loaded %s triples - %s terms" % (len(SdoTermSource.sourceGraph()),len(SdoTermSource.getAllTerms())) ) print("\nLoading examples file(s)") SchemaExamples.loadExamplesFiles(examplesSource,init=True) print("Loaded %d examples " % (SchemaExamples.count())) os.chdir("/content") #put us back to a consistent place ``` -------------------------------- ### Example File Format for Contributing New Examples Source: https://context7.com/schemaorg/doc_update/llms.txt New structured data examples for a type are written in data/ext/pending/issue-XXXX-examples.txt using a multi-section plain-text format parsed by software/SchemaExamples/schemaexamples.py. ```text TYPES: #000 Thing PRE-MARKUP: Introducing the Fnuffl. More information here. MICRODATA:
Introducing the Fnuffl. More information .
RDFA: n/a JSON: ``` -------------------------------- ### Example Building Instance (Brick.ttl) Source: https://github.com/schemaorg/doc_update/blob/main/docs/iot-gettingstarted.html An example of how to instantiate a building, its zones, and sensors using the BRICK schema. ```turtle @prefix brick: . @prefix brickframe: . @prefix ex: . @prefix owl: . @prefix rdfs: . ex:example_building a brick:Building . ex:zt_sensor_1 a brick:Zone_Temperature_Sensor; brickframe:isPointOf ex:zone_1, ex:vav_1 . ex:zone_1 a brick:HVAC_Zone; brickframe.isLocatedIn ex:example_building . ex:vav_1 a brick:VAV; brickframe:basPoint ex:zt_sensor_1; brickframe:feeds ex:zone_1. ``` -------------------------------- ### Install Ruby Test Dependencies Source: https://github.com/schemaorg/doc_update/blob/main/software/SOFTWARE_README.md Installs Ruby and Bundler, then installs the necessary Ruby gems for running tests. ```bash sudo apt-get install ruby-bundler ruby-dev cd schemaorg/software/scripts sudo bundle install ``` -------------------------------- ### Update and Install Packages Source: https://github.com/schemaorg/doc_update/blob/main/software/SOFTWARE_README.md Updates the package list and installs Git and Python package installer. Run this before cloning the repository. ```bash sudo apt-get update && sudo apt-get upgrade sudo apt-get install git python3-pip ``` -------------------------------- ### Install SPARQLWrapper Library Source: https://github.com/schemaorg/doc_update/blob/main/software/scripts/Schema_org_Dashboard.ipynb Installs the SPARQLWrapper library, which is required for querying SPARQL endpoints. Run this once per session. ```python # run this once per session to bring in a required library !pip --quiet install sparqlwrapper | grep -v 'already satisfied' from SPARQLWrapper import SPARQLWrapper, JSON import pandas as pd import io import requests ``` -------------------------------- ### OrganizeAction Example Source: https://github.com/schemaorg/doc_update/blob/main/data/examples.txt Use to describe an action where an agent organizes something. This example shows John organizing a webpage. ```json { "@context": "https://schema.org", "@type": "OrganizeAction", "agent": { "@type": "Person", "name": "John" }, "object": { "@type": "WebPage", "name": "John's thought about the web" } } ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/schemaorg/doc_update/blob/main/software/RELEASING.md Ensure your Python environment is set up with the correct library versions by installing dependencies from the requirements file. ```bash pip install -r software/requirements.txt ``` -------------------------------- ### Multiple Platform URLs Example Source: https://github.com/schemaorg/doc_update/blob/main/docs/actions.html Provides examples of specifying multiple target URLs for different platforms, demonstrating the 'target' property within an 'EntryPoint'. ```json { "@context": "https://schema.org", "@type": "Restaurant", "name": "Tartine Bakery", "potentialAction": { "@type": "ViewAction", "target": [ /* Web deep link */ "http://www.urbanspoon.com/r/6/92204", ``` -------------------------------- ### MarryAction Example Source: https://github.com/schemaorg/doc_update/blob/main/data/examples.txt Represents the action of getting married. This example shows John marrying Ann. ```json { "@context": "https://schema.org", "@type": "MarryAction", "agent": { "@type": "Person", "name": "John" }, "recipient": { "@type": "Person", "name": "Ann" } } ``` -------------------------------- ### Initial Site Build Source: https://github.com/schemaorg/doc_update/blob/main/software/SOFTWARE_README.md Perform an initial build of the Schema.org website locally. This creates a static image in the `site` directory and may take several minutes. ```bash ./software/util/buildsite.py -a ``` -------------------------------- ### Qualifying AlumniOf with OrganizationRole JSON Example Source: https://github.com/schemaorg/doc_update/blob/main/software/SchemaExamples/example-code/examples.txt An example of an OrganizationRole being used to qualify the 'alumniOf' property, indicating the start date of the alumni situation. ```json { "@context": "http://schema.org", "@type": "Person", "name": "Delia Derbyshire", "sameAs": "http://en.wikipedia.org/wiki/Delia_Derbyshire", "alumniOf": { "@type": "OrganizationRole", "alumniOf": { "@type": "CollegeOrUniversity", "name": "University of Cambridge", "sameAs": "http://en.wikipedia.org/wiki/University_of_Cambridge" }, "startDate": "1959" } } ``` -------------------------------- ### TravelAction Example - Traveling from US to Brazil with Steve Source: https://github.com/schemaorg/doc_update/blob/main/data/examples.txt This example extends TravelAction to include origin, destination, and participants. Use fromLocation for the starting point and participant for companions. ```json { "@context": "https://schema.org", "@type": "TravelAction", "agent": { "@type": "Person", "name": "John" }, "fromLocation": { "@type": "Country", "name": "USA" }, "toLocation": { "@type": "Country", "name": "Brazil" }, "participant": { "@type": "Person", "name": "Steve" } } ``` -------------------------------- ### JSON-LD Event Example Source: https://github.com/schemaorg/doc_update/blob/main/software/SchemaExamples/example-code/examples.txt Represents an event with location, name, offers, and start date. Suitable for event listings and ticketing platforms. ```json { "@context": "http://schema.org", "@type": "Event", "location": { "@type": "Place", "address": { "@type": "PostalAddress", "addressLocality": "Denver", "addressRegion": "CO", "postalCode": "80209", "streetAddress": "7 S. Broadway" }, "name": "The Hi-Dive" }, "name": "Typhoon with Radiation City", "offers": { "@type": "Offer", "price": "13.00", "priceCurrency": "USD", "url": "http://www.ticketfly.com/purchase/309433" }, "startDate": "2013-09-14T21:30" } ``` -------------------------------- ### Find Example Files Source: https://github.com/schemaorg/doc_update/blob/main/software/scripts/Schema_org_Dashboard.ipynb Utilize the find command to locate all files ending with 'example.txt' or 'examples.txt' within the cloned schema.org repository. This helps in gathering all schema examples. ```shell !find . -name \*example\*.txt -exec ls {} \; ``` -------------------------------- ### PrependAction Example: Prepending a Movie Source: https://github.com/schemaorg/doc_update/blob/main/data/examples.txt Represents the action of prepending an item to the beginning of a collection. Use this when an item is added to the very start of a list. ```json { "@context": "https://schema.org", "@type": "PrependAction", "agent": { "@type": "Person", "name": "John" }, "object": { "@type": "Movie", "name": "The Internship" }, "targetCollection": { "@type": "ItemList", "name": "List of my favorite movies", "url": "http://netflix.com/john/favorite" } } ``` -------------------------------- ### Run Local Development Server Source: https://github.com/schemaorg/doc_update/blob/main/software/SOFTWARE_README.md Start a local development server to view the Schema.org website. Access it via `localhost:8080` in your browser. ```bash ./software/devserv.py ``` -------------------------------- ### Two B.B. King Music Events Source: https://github.com/schemaorg/doc_update/blob/main/data/examples.txt Example of two MusicEvent entries, each with basic details like name, start date, location, and offer URL. ```json [{ "@context" : "https://schema.org", "@type" : "MusicEvent", "name" : "B.B. King", "startDate" : "2014-04-12T19:30", "location" : { "@type" : "Place", "name" : "Lupo's Heartbreak Hotel", "address" : "79 Washington St., Providence, RI" }, "offers" : { "@type" : "Offer", "url" : "https://www.etix.com/ticket/1771656" } }, { "@context" : "https://schema.org", "@type" : "MusicEvent", "name" : "B.B. King", "startDate" : "2014-04-13T20:00", "location" : { "@type" : "Place", "name" : "Lynn Auditorium", "address" : "Lynn, MA, 01901" }, "offers" : { "@type" : "Offer", "url" : "http://frontgatetickets.com/venue.php?id=11766" } }] ``` -------------------------------- ### Build and Test Release Candidate Source: https://github.com/schemaorg/doc_update/blob/main/software/RELEASING.md Run the buildsite script with the --release flag to assign example IDs, build the site, and run tests. This also copies release files to the data/releases directory. ```bash ./software/util/buildsite.py --release ``` -------------------------------- ### Event JSON-LD Example Source: https://github.com/schemaorg/doc_update/blob/main/data/examples.txt This JSON-LD snippet represents an event with its location, name, offers, and start date. It's a concise way to structure event data. ```json { "@context": "https://schema.org", "@type": "Event", "location": { "@type": "Place", "address": { "@type": "PostalAddress", "addressLocality": "Denver", "addressRegion": "CO", "postalCode": "80209", "streetAddress": "7 S. Broadway" }, "name": "The Hi-Dive" }, "name": "Typhoon with Radiation City", "offers": { "@type": "Offer", "price": "13.00", "priceCurrency": "USD", "url": "http://www.ticketfly.com/purchase/309433" }, "startDate": "2013-09-14T21:30" } ``` -------------------------------- ### Event Markup with Date and Time Source: https://github.com/schemaorg/doc_update/blob/main/docs/gs.html This example demonstrates marking up an event using schema.org types and properties, including the event name, description, and start date/time using the 'time' tag with 'datetime'. ```html
Spinal Tap
One of the loudest bands ever reunites for an unforgettable two-day show. Event date:
``` -------------------------------- ### Schema.org Dashboard Setup Source: https://github.com/schemaorg/doc_update/blob/main/software/scripts/dashboard.ipynb Initializes the testing harness, registers the JSON-LD serializer for rdflib, loads master data stores, and reads schema and extension definitions. This setup is crucial for subsequent data processing and analysis. ```python # Setup setInTestHarness(True) import sdoapp rdflib.plugin.register("json-ld", Serializer, "rdflib_jsonld.serializer", "JsonLDSerializer") store = getMasterStore() read_schemas(loadExtensions=True) read_extensions(sdoapp.ENABLED_EXTENSIONS) graphs = list(store.graphs()) ``` -------------------------------- ### AddAction Example (Skill) Source: https://github.com/schemaorg/doc_update/blob/main/software/SchemaExamples/example-code/examples.txt Demonstrates adding a different type of object, such as software or a skill, to a collection. Note the use of SoftwareApplication for 'SAAS'. ```json // John added SAAS to his skillset. { "@context": "http://schema.org", "@type": "AddAction", "agent": { "@type": "Person", "name": "John" }, "object": { "@type": "SoftwareApplication", "name": "SAAS" }, "targetCollection": { "@type": "ItemList", "name": "John's skillset", "url": "http://linkedn.com/john/skillset" } } ``` -------------------------------- ### PlanAction Example (Exercise Plan) Source: https://github.com/schemaorg/doc_update/blob/main/software/SchemaExamples/example-code/examples.txt Use this to describe a user planning an exercise plan with another person. It specifies the agent, object (exercise plan), and participant. ```json // John planned an exercise plan with Steve. { "@context": "http://schema.org", "@type": "PlanAction", "agent": { "@type": "Person", "name": "John" }, "object": { "@type": "ExercisePlan", "name": "John's weight loss plan" }, "participant": { "@type": "Person", "name": "Steve" } } ``` -------------------------------- ### Product with Detailed SizeSpecification (JSON-LD) Source: https://github.com/schemaorg/doc_update/blob/main/data/ext/pending/issue-2811-examples.txt This example shows a complete product with a detailed SizeSpecification, including size system, group, measurements, and suggested body measurements. Use this for comprehensive product sizing information. ```json { "@context": "https://schema.org/", "@type": "Product", "sku": "44E01-M11000", "inProductGroupWithID": "44E01", "gtin14": "98766051104218", "image": "https://www.example.com/jacket_large_green.jpg", "name": "Large green jacket", "description": "Large wool green jacket for the winter months", "brand": { "@type": "Brand", "name": "A fashion brand" }, "color": "green", "size": { "@type": "SizeSpecification", "sizeSystem": "https://schema.org/WearableSizeSystemUS", "sizeGroup": [ "https://schema.org/WearableSizeGroupMens", "https://schema.org/WearableSizeGroupBig", "https://schema.org/WearableSizeGroupTall" ], "name": "3XL", "hasMeasurement": [ { "@type": "QuantitativeValue", "valueReference": "https://schema.org/WearableMeasurementChestOrBust", "unitCode": "INH", "value": 52 }, { "@type": "QuantitativeValue", "valueReference": "https://schema.org/WearableMeasurementLength", "unitCode": "INH", "value": 42 } ], "suggestedGender": "male", "suggestedAge": { "@type": "QuantitativeValue", "name": "adult", "unitCode": "ANN", "minValue": 13 }, "suggestedMeasurement": [ { "@type": "QuantitativeValue", "valueReference": "https://schema.org/BodyMeasurementChest", "unitCode": "INH", "minValue": 51, "maxValue": 54 }, { "@type": "QuantitativeValue", "valueReference": "https://schema.org/BodyMeasurementHeight", "unitCode": "FOT", "minValue": 6, "maxValue": 6.3 } ] }, "offers": { "@type": "Offer", "url": "https://www.example.com/jacket?s=l&c=g", "priceCurrency": "USD", "price": 239.99, "itemCondition": "https://schema.org/NewCondition", "availability": "https://schema.org/InStock" } } ``` -------------------------------- ### InteractAction Example (Organization) Source: https://github.com/schemaorg/doc_update/blob/main/data/examples.txt This InteractAction example shows a person interacting with an organization. ```json { "@context": "https://schema.org", "@type": "InteractAction", "agent": { "@type": "Person", "name": "John" }, "participant": { "@type": "Organization", "name": "IEEE" } } ``` -------------------------------- ### Initialize Libraries Source: https://github.com/schemaorg/doc_update/blob/main/software/scripts/Schema_org_Examples.ipynb Imports necessary libraries for script execution. Ensure these are available in your environment. ```python import os,sys ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/schemaorg/doc_update/blob/main/software/SOFTWARE_README.md Installs the Python dependencies required for the schema.org project using pip. ```bash pip3 install -r software/requirements.txt ``` -------------------------------- ### OrganizeAction with LocalBusiness Example Source: https://github.com/schemaorg/doc_update/blob/main/data/examples.txt Use to describe an action where an agent organizes something. This example shows John organizing a local business. ```json { "@context": "https://schema.org", "@type": "OrganizeAction", "agent": { "@type": "Person", "name": "John" }, "object": { "@type": "LocalBusiness", "name": "John's tavern" } } ``` -------------------------------- ### ScheduleAction Example Source: https://github.com/schemaorg/doc_update/blob/main/software/SchemaExamples/example-code/examples.txt Represents scheduling an event. This example shows scheduling an event named 'SXSW' for 'May'. ```json // John scheduled an event to occur in May. { "@context": "http://schema.org", "@type": "ScheduleAction", "agent": { "@type": "Person", "name": "John" }, "object": { "@type": "Event", "name": "SXSW" }, "scheduledTime": "May" } ``` -------------------------------- ### Clone and Build Schema.org Site Locally Source: https://context7.com/schemaorg/doc_update/llms.txt Steps to clone the repository, set up a Python virtual environment, install dependencies, and perform an initial full build of the Schema.org site. Requires Python 3.11+. ```bash # 1. Clone the repository git clone https://github.com/schemaorg/schemaorg.git cd schemaorg # 2. Create and activate a Python virtual environment (Python 3.11+ required) python3 -m venv venv source venv/bin/activate # 3. Install dependencies pip install -r software/requirements.txt # 4. Perform the initial full build (takes 5–20 minutes) ./software/util/buildsite.py -a # 5. Start the local dev server (default: http://localhost:8080) ./software/devserv.py # Optional: change host/port ./software/devserv.py --host 0.0.0.0 --port 8080 # Expected output: # Serving on http://localhost:8080 ... ``` -------------------------------- ### ConsumeAction Example Source: https://github.com/schemaorg/doc_update/blob/main/software/SchemaExamples/example-code/examples.txt Represents the act of consuming something, such as food or energy. This example shows calories consumed by 'biceps'. ```json { "@context": "http://schema.org", "@type": "ConsumeAction", "agent": { "@type": "Thing", "name": "biceps" }, "object": { "@type": "Energy", "name": "100 calories" } } ``` -------------------------------- ### ChooseAction Example with Multiple Options Source: https://github.com/schemaorg/doc_update/blob/main/data/examples.txt Illustrates a ChooseAction where an agent selects one option from a list of possibilities. Both the selected object and the action options should be clearly defined. ```json { "@context": "https://schema.org", "@type": "ChooseAction", "agent": { "@type": "Person", "name": "John" }, "object": { "@type": "Brewery", "name": "Dogfish Head" }, "actionOption": [ { "@type": "Brewery", "name": "Dogfish Head" }, { "@type": "Brewery", "name": "Russian River" } ] } ```