Created
September 16, 2022 17:10
-
-
Save danbri/cfe48569a584944d22913a4a734546bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load @shexjs/node to get file: access | |
const ShExLoader = require('@shexjs/node')({ | |
rdfjs: require('n3') // use N3 parser to parse Turtle | |
}) | |
// | |
/* | |
const text = require('fs').readFileSync('./claim_review_shex.ttl', 'utf-8') | |
const mediaType = 'text/turtle' | |
const schemaSources = { turtle: [ | |
{ text, mediaType } // read 1 file with fixed media type | |
] } | |
*/ | |
// {format: "shexc", URL: "http://a.example/s2.shex"}, | |
// specify ShExC | |
const text = require('fs').readFileSync('./ClaimReview.shex', 'utf-8') | |
// const schemaSources = { shexc: [ { text } ] } | |
const schemaSources = { "format": "shexc", "URL": "https://example/.net/", "text": text } | |
// Modules needed to parse ShEx schema from RDF graph | |
const validator = require('@shexjs/validator'); | |
const schema = require('@shexjs/cli/lib/ShExR.cjs.js'); | |
const rdfjsdb = require('@shexjs/neighborhood-rdfjs').ctor; | |
// Invoke loader with: | |
ShExLoader.load( | |
schemaSources, // schema sources | |
null, // data sources | |
{ graphParser: { validator, schema, rdfjsdb } } // for parsing ShExR | |
).then( | |
// When loaded, | |
({schema}) => // dump the resulting schema. | |
console.log(schema) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment