SHACL Shape Editor¶
Build SHACL shapes visually — no Turtle knowledge needed. Load an existing shape file, use templates, or start from scratch.
Shape Recommender — auto-generate shapes from data
Runs the same induction engine as `ontoink.recommend` (Python) and the `recommend_shapes:` fence key — `baseline` profiles instance data (Mihindukulasooriya et al. 2018), `astrea` reads OWL axioms alone, and works even when your file has no instances at all. [See how it works](examples/shape-recommendation.md).
Prefixes ?
Shape Recommender — Methodology¶
This page's recommender calls ontoink.recommendShapes, a JavaScript port of ontoink/recommend/ — the same engine the recommend_shapes: fence key and POST /recommend-shapes use. It used to carry its own reimplementation with its own regex Turtle parser; that meant this page and the Python engine could disagree about the same file, so it was replaced. A test suite (tests/test_recommend_parity.py) runs both engines over identical fixtures on every change and asserts the constraint sets match — see Shape Recommendation for the full design rationale.
Two methods, chosen on evidence¶
Both were ported from a benchmark comparing eight induction methods on five datasets plus two real ontologies (MWO, NFDIcore):
baseline— frequency profiling of instance data (Mihindukulasooriya et al. 2018). Property present on ≥90% of a class's instances →sh:minCount 1; no instance with more than one value →sh:maxCount 1; one consistent XSD datatype or target class across all observed values →sh:datatype/sh:class+sh:nodeKind sh:IRI. Best F1-to-complexity ratio in the benchmark (mean F1 0.695 across five datasets).astrea— reads OWL axioms alone:rdfs:domain/rdfs:range,owl:FunctionalProperty, and cardinality/someValuesFrom/allValuesFromrestrictions. Needs no instance data, which is what most documentation ontologies ship.auto(default) — runs both and merges them; a constraint both methods derive keeps the evidence from whichever pass measured it.
Six other benchmarked methods are not shipped here: they over-predicted, produced output identical to the baseline on real ontologies, or were never fully implemented against their own design. See Architecture: SHACL Shape Recommendation for the full accounting.
Known gap. The previous page-local recommender also detected sh:pattern (email/URL/uppercase heuristics), sh:minLength/maxLength, numeric ranges, and uniqueness — extensions that were never run against the benchmark. They are not reproduced by the shared engine. If you need them today, describe the constraint by hand in the builder above; folding validated versions into ontoink/recommend/ is tracked on the roadmap.
Confidence, honestly¶
Confidence is support / population for baseline constraints — so a constraint backed by 3 of 3 instances currently reads the same as one backed by 300 of 300. astrea constraints show confidence: 1.0 because they come from an asserted axiom, not a measurement; a basis field distinguishing "measured" from "assumed" is planned rather than shipped. Read the evidence column before trusting a green row on a small dataset.
Input modes¶
- Upload / paste TTL — runs entirely in your browser, instant results, works offline and on static hosting.
- SPARQL endpoint — for each of the top 20 classes by instance count, fetches up to 30 instances and every triple of those instances, then profiles the result with the same engine. Bounded so it stays usable against a large public endpoint; a small sample can under- or over-state a constraint's real support.
Either mode skips classes already covered by the shapes you've built in this session — the recommendations narrow as your shape set grows.
References¶
- Mihindukulasooriya, N., Rashid, M. R. A., Rizzo, G., García-Castro, R., Corcho, O., Torchiano, M. (2018). RDF Shape Induction Using Knowledge Base Profiling. SAC 2018.
- Cimmino, A., Fernández-Izquierdo, A., García-Castro, R. (2020). ASTREA: Automatic Generation of SHACL Shapes. ESWC 2020.
What is SHACL?¶
SHACL (Shapes Constraint Language) defines rules that RDF data must follow. Think of it as a "schema" for your knowledge graph.
Key Concepts¶
| Concept | What it means | Example |
|---|---|---|
| sh:NodeShape | A set of rules for a class | "Rules for Person instances" |
| sh:targetClass | Which class the rules apply to | ex:Person |
| sh:property | A constraint on a specific property | "must have a name" |
| sh:minCount | Minimum values required (0 = optional, 1 = mandatory) | sh:minCount 1 |
| sh:maxCount | Maximum values allowed (1 = at most one) | sh:maxCount 1 |
| sh:datatype | Value must be a specific type | xsd:string, xsd:date |
| sh:nodeKind | Value must be IRI, literal, or blank node | sh:IRI |
| sh:pattern | Value must match a regex | ^[A-Z] |
| sh:closed | Only declared properties are allowed | Prevents unexpected data |
| sh:message | Custom error message | "Name is required" |
Common Patterns¶
Mandatory property: sh:minCount 1 — the property must exist at least once
Exactly one: sh:minCount 1; sh:maxCount 1 — must have exactly one value
Optional with limit: sh:maxCount 3 — at most 3 values (but can be 0)
Type constraint: sh:datatype xsd:string — value must be a string
Email validation: sh:pattern "^[^@]+@[^@]+\\.[^@]+$" — must match email regex