Skip to content

Instantly share code, notes, and snippets.

@danbri
Created April 1, 2022 20:29
Show Gist options
  • Save danbri/1ae3afdad3f7a82177376eafc113d6eb to your computer and use it in GitHub Desktop.
Save danbri/1ae3afdad3f7a82177376eafc113d6eb to your computer and use it in GitHub Desktop.
ShEx IconShEx2 — Simple Online Validator
controls
PREFIX : <http://schema.org/>
PREFIX validate: <https://google.com/search/validation/valid>
<S1> {
:url . + %validate:url{console.log('some url checking code here')%}
} AND {
:datePublished . ? %validate:date-time{console.log('some datetime checking code here')%}
} AND {
:claimReviewed .
} AND {
:itemReviewed {
a [:CreativeWork]
} AND (
NOT {
a [:CreativeWork]
} OR {
:author (
{
a [:Organization]
} OR {
a [:Person]
}
) AND (
NOT (
{
a [:Organization]
} OR {
a [:Person]
}
) OR {
:name . ?
}
)?
} AND {
:datePublished . ? %validate:date-time{console.log('some datetime checking code here')%}
}
)?
} AND {
:author (
{
a [:Organization]
} OR {
a [:Person]
}
) AND (
NOT (
{
a [:Organization]
} OR {
a [:Person]
}
) OR (
{
:name .
} OR {
:url .
}
) AND {
:url . * %validate:url{console.log('some url checking code here')%}
}
)?
} AND {
:reviewRating {
a [:Rating]
} AND (
NOT {
a [:Rating]
} OR {
:alternateName .
} AND (
(
NOT {
:name .
} OR {
:alternateName . ?
}
) AND (
NOT (
NOT {
:name .
}
) OR {
:alternateName . +
}
)
) AND NOT (
{
:alternateName .
} AND {
:name .
}
) AND (
NOT (
(
{
:ratingValue .
} OR {
:bestRating .
} OR {
:worstRating .
}
) AND NOT (
{
:ratingValue /-1/
} AND {
:bestRating /-1/
} AND {
:worstRating /-1/
}
)
) OR {
:ratingValue /([0-9]+[\.,]?[0-9]*)\/([0-9]+[\.,]?[0-9]*)/ OR /([0-9]+[\.,]?[0-9]*)%/ OR /([0-9]+[\.,]?[0-9]*)/ +
} AND (
NOT {
:ratingValue /([0-9]+[\.,]?[0-9]*)/ +
} OR {
} %validate:rating%
)
)
)+
}
Manifest:
clinical observation
GO-CAM example
wikidata query
Each Wikidata item on Cancer should have a NCI Thesaurus ID
protein record
basic information about humans
Query MapQuery Map EditorFixed Map
_:c14n0 <http://schema.org/logo> _:c14n7 .
_:c14n0 <http://schema.org/name> "Skeptical News" .
_:c14n0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Organization> .
_:c14n1 <http://schema.org/author> _:c14n6 .
_:c14n1 <http://schema.org/claimReviewed> "The world is flat" .
_:c14n1 <http://schema.org/datePublished> "2016-06-22"^^<http://schema.org/Date> .
_:c14n1 <http://schema.org/itemReviewed> _:c14n5 .
_:c14n1 <http://schema.org/reviewRating> _:c14n3 .
_:c14n1 <http://schema.org/url> <http://example.com/news/science/worldisflat.html> .
_:c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/ClaimReview> .
_:c14n2 <http://schema.org/name> "T. Tellar" .
_:c14n2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
_:c14n3 <http://schema.org/alternateName> "False" .
_:c14n3 <http://schema.org/bestRating> "5" .
_:c14n3 <http://schema.org/ratingValue> "1" .
_:c14n3 <http://schema.org/worstRating> "1" .
_:c14n3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Rating> .
_:c14n4 <http://schema.org/author> _:c14n2 .
_:c14n4 <http://schema.org/datePublished> "2016-06-22"^^<http://schema.org/Date> .
_:c14n4 <http://schema.org/headline> "Square Earth - Flat earthers for the Internet age" .
_:c14n4 <http://schema.org/image> <https://example.com/photos/1x1/photo.jpg> .
_:c14n4 <http://schema.org/publisher> _:c14n0 .
_:c14n4 <http://schema.org/url> <http://skeptical.example.net/news/a122121> .
_:c14n4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/OpinionNewsArticle> .
_:c14n5 <http://schema.org/appearance> _:c14n4 .
_:c14n5 <http://schema.org/author> _:c14n8 .
_:c14n5 <http://schema.org/datePublished> "2016-06-20"^^<http://schema.org/Date> .
_:c14n5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Claim> .
_:c14n6 <http://schema.org/name> "Example.com science watch" .
_:c14n6 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Organization> .
_:c14n7 <http://schema.org/url> <https://example.com/logo.jpg> .
_:c14n7 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/ImageObject> .
_:c14n8 <http://schema.org/name> "Square World Society" .
_:c14n8 <http://schema.org/sameAs> <https://example.flatworlders.com/we-know-that-the-world-is-flat> .
_:c14n8 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Organization> .
validate (ctl-enter)
parsed ShExC schema, generated ShExJ (copy to input):
{
"type": "Schema",
"shapes": [
{
"type": "ShapeAnd",
"id": "http://shex.io/webapps/shex.js/doc/S1",
"shapeExprs": [
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/url",
"min": 1,
"max": -1,
"semActs": [
{
"type": "SemAct",
"name": "https://google.com/search/validation/validurl",
"code": "console.log('some url checking code here')"
}
]
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/datePublished",
"min": 0,
"max": 1,
"semActs": [
{
"type": "SemAct",
"name": "https://google.com/search/validation/validdate-time",
"code": "console.log('some datetime checking code here')"
}
]
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/claimReviewed"
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/itemReviewed",
"valueExpr": {
"type": "ShapeAnd",
"shapeExprs": [
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"valueExpr": {
"type": "NodeConstraint",
"values": [
"http://schema.org/CreativeWork"
]
}
}
},
{
"type": "ShapeOr",
"shapeExprs": [
{
"type": "ShapeNot",
"shapeExpr": {
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"valueExpr": {
"type": "NodeConstraint",
"values": [
"http://schema.org/CreativeWork"
]
}
}
}
},
{
"type": "ShapeAnd",
"shapeExprs": [
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/author",
"valueExpr": {
"type": "ShapeAnd",
"shapeExprs": [
{
"type": "ShapeOr",
"shapeExprs": [
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"valueExpr": {
"type": "NodeConstraint",
"values": [
"http://schema.org/Organization"
]
}
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"valueExpr": {
"type": "NodeConstraint",
"values": [
"http://schema.org/Person"
]
}
}
}
]
},
{
"type": "ShapeOr",
"shapeExprs": [
{
"type": "ShapeNot",
"shapeExpr": {
"type": "ShapeOr",
"shapeExprs": [
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"valueExpr": {
"type": "NodeConstraint",
"values": [
"http://schema.org/Organization"
]
}
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"valueExpr": {
"type": "NodeConstraint",
"values": [
"http://schema.org/Person"
]
}
}
}
]
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/name",
"min": 0,
"max": 1
}
}
]
}
]
},
"min": 0,
"max": 1
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/datePublished",
"min": 0,
"max": 1,
"semActs": [
{
"type": "SemAct",
"name": "https://google.com/search/validation/validdate-time",
"code": "console.log('some datetime checking code here')"
}
]
}
}
]
}
]
}
]
},
"min": 0,
"max": 1
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/author",
"valueExpr": {
"type": "ShapeAnd",
"shapeExprs": [
{
"type": "ShapeOr",
"shapeExprs": [
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"valueExpr": {
"type": "NodeConstraint",
"values": [
"http://schema.org/Organization"
]
}
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"valueExpr": {
"type": "NodeConstraint",
"values": [
"http://schema.org/Person"
]
}
}
}
]
},
{
"type": "ShapeOr",
"shapeExprs": [
{
"type": "ShapeNot",
"shapeExpr": {
"type": "ShapeOr",
"shapeExprs": [
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"valueExpr": {
"type": "NodeConstraint",
"values": [
"http://schema.org/Organization"
]
}
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"valueExpr": {
"type": "NodeConstraint",
"values": [
"http://schema.org/Person"
]
}
}
}
]
}
},
{
"type": "ShapeAnd",
"shapeExprs": [
{
"type": "ShapeOr",
"shapeExprs": [
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/name"
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/url"
}
}
]
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/url",
"min": 0,
"max": -1,
"semActs": [
{
"type": "SemAct",
"name": "https://google.com/search/validation/validurl",
"code": "console.log('some url checking code here')"
}
]
}
}
]
}
]
}
]
},
"min": 0,
"max": 1
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/reviewRating",
"valueExpr": {
"type": "ShapeAnd",
"shapeExprs": [
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"valueExpr": {
"type": "NodeConstraint",
"values": [
"http://schema.org/Rating"
]
}
}
},
{
"type": "ShapeOr",
"shapeExprs": [
{
"type": "ShapeNot",
"shapeExpr": {
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"valueExpr": {
"type": "NodeConstraint",
"values": [
"http://schema.org/Rating"
]
}
}
}
},
{
"type": "ShapeAnd",
"shapeExprs": [
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/alternateName"
}
},
{
"type": "ShapeAnd",
"shapeExprs": [
{
"type": "ShapeOr",
"shapeExprs": [
{
"type": "ShapeNot",
"shapeExpr": {
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/name"
}
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/alternateName",
"min": 0,
"max": 1
}
}
]
},
{
"type": "ShapeOr",
"shapeExprs": [
{
"type": "ShapeNot",
"shapeExpr": {
"type": "ShapeNot",
"shapeExpr": {
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/name"
}
}
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/alternateName",
"min": 1,
"max": -1
}
}
]
}
]
},
{
"type": "ShapeNot",
"shapeExpr": {
"type": "ShapeAnd",
"shapeExprs": [
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/alternateName"
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/name"
}
}
]
}
},
{
"type": "ShapeOr",
"shapeExprs": [
{
"type": "ShapeNot",
"shapeExpr": {
"type": "ShapeAnd",
"shapeExprs": [
{
"type": "ShapeOr",
"shapeExprs": [
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/ratingValue"
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/bestRating"
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/worstRating"
}
}
]
},
{
"type": "ShapeNot",
"shapeExpr": {
"type": "ShapeAnd",
"shapeExprs": [
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/ratingValue",
"valueExpr": {
"type": "NodeConstraint",
"pattern": "-1"
}
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/bestRating",
"valueExpr": {
"type": "NodeConstraint",
"pattern": "-1"
}
}
},
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/worstRating",
"valueExpr": {
"type": "NodeConstraint",
"pattern": "-1"
}
}
}
]
}
}
]
}
},
{
"type": "ShapeAnd",
"shapeExprs": [
{
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/ratingValue",
"valueExpr": {
"type": "ShapeOr",
"shapeExprs": [
{
"type": "NodeConstraint",
"pattern": "([0-9]+[\\.,]?[0-9]*)/([0-9]+[\\.,]?[0-9]*)"
},
{
"type": "NodeConstraint",
"pattern": "([0-9]+[\\.,]?[0-9]*)%"
},
{
"type": "NodeConstraint",
"pattern": "([0-9]+[\\.,]?[0-9]*)"
}
]
},
"min": 1,
"max": -1
}
},
{
"type": "ShapeOr",
"shapeExprs": [
{
"type": "ShapeNot",
"shapeExpr": {
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://schema.org/ratingValue",
"valueExpr": {
"type": "NodeConstraint",
"pattern": "([0-9]+[\\.,]?[0-9]*)"
},
"min": 1,
"max": -1
}
}
},
{
"type": "Shape",
"semActs": [
{
"type": "SemAct",
"name": "https://google.com/search/validation/validrating"
}
]
}
]
}
]
}
]
}
]
}
]
}
]
},
"min": 1,
"max": -1
}
}
]
}
],
"@context": "http://www.w3.org/ns/shex.jsonld"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment