Package: shexstatements
ShExStatementsShExStatements allows the users to generate shape expressions from simple CSV statements or files.shexstatementscan be used from the command line as well as from the web interface.Quick startUsing pipSet up a virtual environment and installshexstatements.$ python3 -m venv .venv
$ source ./.venv/bin/activate
$ pip3 install shexstatementsRun the following command with anexample CSV file. The file contains an example description of a language on Wikidata. This file uses comma as a delimiter to separate the values.$ shexstatements.sh examples/language.csvBuild from sourceTerminalClone theShExStatementsrepository.$ git clone https://github.com/johnsamuelwrites/ShExStatements.gitGo toShExStatementsdirectory.$ cd ShExStatementsInstall modules required byShExStatements(here: installing into a virtual environment).$ python3 -m venv .venv
$ source ./.venv/bin/activate
$ pip3 install .Run the following command with an example CSV file. The file contains an example description of a language on Wikidata. This file uses comma as a delimiter to separate the values.$ ./shexstatements.sh examples/language.csvCSV file can use delimiters like;. Take for example, the following command works with a file using semi-colon as a delimiter.$ ./shexstatements.sh examples/languagedelimsemicolon.csv --delim ";"But sometimes, users may like to specify the header. In that case, they can make use of-sor--skipheaderto tell the generator to skip the header (firsrt line of CSV).$ ./shexstatements.sh --skipheader examples/languageheader.csvIn all the above cases, the shape expression generated byShExStatementswill look likePREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
start = @<language>
<language> {
  wdt:P31 [ wd:Q34770  ] ;# instance of a language
  wdt:P1705 LITERAL ;# native name
  wdt:P17 .+ ;# spoken in country
  wdt:P2989 .+ ;# grammatical cases
  wdt:P282 .+ ;# writing system
  wdt:P1098 .+ ;# speakers
  wdt:P1999 .* ;# UNESCO language status
  wdt:P2341 .+ ;# indigenous to
}Use-jor--shexjto generate ShEx JSON Syntax (ShExJ) instead of default ShEx Compact syntax (ShExC).$ ./shexstatements.sh --shexj examples/language.csvThe output will be similiar to:{"type":"Schema","start":"language","shapes":[{"type":"Shape","id":"language","expression":{}}]}It's also possible to use application profiles of the following formEntity_name,Property,Property_label,Mand,Repeat,Value,Value_type,Annotationand Shape expressions can be generated using the following form$ ./shexstatements.sh -ap --skipheader examples/languageap.csvObjectivesEasily generate shape expressions (ShEx) from CSV filesSimple syntaxDocumentation and examplesA detailed documentation can be foundhere. with a number of example CSV files in theexamplesfolder.Test cases and coverageAll the test cases can be run in  the following manner$ python3 -m tests.testsCode coverage report can also be generated by running the unit tests using the coverage tool.$ coverage run --source=shexstatements -m unittest tests.test
$ coverage report -mWeb interfaceshexstatementscan also be accessed from a web interface.
Clone theShExStatementsrepository.$ git clone https://github.com/johnsamuelwrites/ShExStatements.gitGo toShExStatementsdirectory.$ cd ShExStatementsInstall modules required byShExStatements(here: installing into a virtual environment).$ python3 -m venv .venv
$ source ./.venv/bin/activate
$ pip3 install .Now run the application.$ ./shexstatements.sh -rCheck the URLhttp://127.0.0.1:5000/APIShExStatements also has an API to generate ShEx from CSV and is describedhere.DemonstrationOnline demonstrations are also available:https://shexstatements.toolforge.org/https://tools.wmflabs.org/shexstatements/AuthorJohn SamuelContributorsAcknowledgementsWikidata CommunityArchives and ReleasesZenodoSoftware HeritageRelease NotesLicenceAll code are released under GPLv3+ licence. The associated documentation and other content are released underCC-BY-SA.