{% extends "base.html" %} {% block content %}

ShExStatements: Quick start

ShExStatements allows users to generate shape expressions from simple CSV statements or files. shexstatements can be used from the command line or can be accessed from a browser.

Online demonstration

Online demonstrations of shexstatements are available:

Manual setup

In order to test shexstatements locally from the command line or from the web browser, follow the instructions given below:

1. Terminal

Clone the ShExStatements repository.


$ git clone https://github.com/johnsamuelwrites/ShExStatements.git

Go to ShExStatements directory.


$ cd ShExStatements

Install modules required by ShExStatements (here: installing into a virtual environment).


$ python3 -m venv .venv
$ source ./.venv/bin/activate
$ pip3 install .

Consider an example CSV file language.csv in the folder examples/. The file contains an example description of a language on Wikidata. This file uses comma as a delimiter to separate the values. First three lines are used to specify the prefixes. And the remaining lines describe the different properties used to describe a language.


wd,<http://www.wikidata.org/entity/>,,,
wdt,<http://www.wikidata.org/prop/direct/>,,,
xsd,<http://www.w3.org/2001/XMLSchema#>,,,

@language,wdt:P31,wd:Q34770,,# instance of a language
@language,wdt:P1705,LITERAL,,# native name
@language,wdt:P17,.,+,# spoken in country
@language,wdt:P2989,.,+,# grammatical cases
@language,wdt:P282,.,+,# writing system
@language,wdt:P1098,.,+,# speakers
@language,wdt:P1999,.,*,# UNESCO language status
@language,wdt:P2341,.,+,# indigenous to

There are five columns in the CSV file.

Columns 1, 2, 3 are mandatory. Column 3 can be a special value like . (period to say 'any' value). The first three lines in the above file are used for specifying the prefixes. In this case, columns 3,4 and 5 are empty.

Cardinality can be any one of the following values

Run the following command for the above file.


$ ./shexstatements.sh examples/language.csv

The shape expression generated by ShExStatements will look like


PREFIX 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
}

CSV file can also contain delimiters like semicolon (;). Take for example, the following command works with a file using semi-colon as a delimiter. In this case, we precise the delimiter, using the --delim option.


$ ./shexstatements.sh examples/languagedelimsemicolon.csv --delim ";"

But sometimes, users may like to specify the header. In that case, they can make use of -s or --skipheader to tell the generator to skip the header (firsrt line of CSV).


$ ./shexstatements.sh --skipheader examples/languageheader.csv

2. Web interface

shexstatements can also be accessed from a web interface. Clone the ShExStatements repository.


$ git clone https://github.com/johnsamuelwrites/ShExStatements.git

Go to ShExStatements directory.


$ cd ShExStatements

Install modules required by ShExStatements (here: installing into a virtual environment).


$ python3 -m venv .venv
$ source ./.venv/bin/activate
$ pip3 install .

Now run the application.


$ ./shexstatements.sh -r  

Check the URL http://127.0.0.1:5000/.

{% endblock %}