<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Shape Designer for ShEx and SHACL Constraints</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Iovka Boneva</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jeremie Dusart</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Daniel Fernandez Alvarez</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jose Emilio Labra Gayo</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Inria</institution>
          ,
          <country country="FR">France</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Univ. Lille, CNRS, Centrale Lille, Inria, UMR 9189 - CRIStAL - Centre de Recherche en Informatique Signal et Automatique de Lille</institution>
          ,
          <addr-line>F-59000 Lille</addr-line>
          ,
          <country country="FR">France</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>University of Oviedo</institution>
          ,
          <country country="ES">Spain</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>We present Shape Designer, a graphical tool for building SHACL or ShEx constraints for an existing RDF dataset. Shape Designer allows to automatically extract complex constraints that are satis ed by the data. Its integrated shape editor and validator allow expert users to combine and modify these constraints in order to build an arbitrarily complex ShEx or SHACL schema.</p>
      </abstract>
      <kwd-group>
        <kwd>RDF validation</kwd>
        <kwd>SHACL</kwd>
        <kwd>ShEx</kwd>
        <kwd>Wikidata</kwd>
        <kwd>LOD quality</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>A Shape Designer project is associated with an RDF graph G and a ShEx
or SHACL schema under construction S. The language to use for the schema,
ShEx or SHACL, is xed at project creation. The GUI of Shape Designer is
shown in Fig. 1. It includes the following panels: (1) a list of shape patterns;
(2) a list of node selection queries; (3) an editing area containing the schema
under construction S; (4) a validation view (not shown in Fig. 1).</p>
      <p>The main functionality of Shape Designer is the automatic construction of a
(ShEx or SHACL) shape constraint. For a given node selection query Q and a
shape pattern P , it creates a shape constraint constr (Q; P ) that has a structure
as indicated by pattern P and that is satis ed by all the nodes of G in the result
of query Q. The constraint thus obtained can be added to the schema under
construction, or simply used to gather information about the data.
3</p>
    </sec>
    <sec id="sec-2">
      <title>Use Case : Constraint for every rdf:type</title>
      <p>We demonstrate how to construct a recursive ShEx schema S that has one
constraint for every rdfs:Class used in G and accounts for the references between
types. We use a dataset with uniform structure from DBTunes4.
Create the project. At project creation we choose the shape language, here ShEx,
and indicate to the tool where to nd the graph: in a local le, a local RDF4J
database, or through a SPARQL endpoint. A new project comes with a set
of prede ned useful patterns. For instance, pattern P1 = f rdf:type [ ] ; ~ g
is prede ned and indicates that the constraint to be constructed should
contain the list of possible values ([ ]) for property rdf:type, and a datatype or
4downloaded from http://dbtune.org/classical/ on June 16, 2019.</p>
      <p>Shape Designer for ShEx and SHACL Constraints
demo:Composition {
a [ mo:Composition ] ;
mo:composer [ composer:~ ];
mo:produced_work IRI * ;
bio:date xsd:integer ? ;
bio:place xsd:string ? }
:Shape_QComp_P2 {
mo:composer {</p>
      <p>a [ type:Composer ] }
mo:produced_work {</p>
      <p>a [ mo:MusicalWork ] } *
}
;
node kind value constraint ( ) for all other properties (~). We also ask the
tool to construct queries that select all nodes of some class, for all the classes
that appear as objects of rdf:type in the graph. For instance, query QComp =
SELECT ?x WHERE f?x a mo:Compositiong is generated by the tool. Note that
the pre xes de ned in the graph can be used in queries and in patterns.
Automatic construction of shapes. Now, given P1 and QComp, the tool inspects
the graph and constructs constr (QComp; P1) shown on the left hand side of
Fig. 2. Remark that the cardinality of each triple constraint was automatically
inferred from the data, among four possible cardinality constraints that are
exactly one, optional (?), at least one (+), and any number (*). We can choose
to add constr (QComp; P1) to the schema S under construction. By repeating the
construction of constr (QC ; P1) for all classes C, a novice user can build a schema
that models the data without need of mastering the shape constraint language.
For instance, we create shapes demo:Composer and demo:MusicalWork for the
nodes with classes type:Composer and mo:MusicalWork, respectively.
Validation. At any time the user can validate graph G against the schema under
construction S. The validation result is shown in a list and allows to explore the
neighbourhood of nodes to help understand validation errors.</p>
      <p>Shape patterns to explore the structure of the data. Automatic shape
construction can be used to gather information about the data. Consider pattern
P2 = f mo:~ f rdf:type [ ] g g. It indicates that we are interested only in
properties with namespace mo:, and we want to retrieve the lists of rdf:types of their
values. The shape constr (QComp; P2) is presented on the right-hand side of Fig. 2
and it shows that the values of property mo:composer have class type:Composer,
and the values of property mo:produced work have class mo:MusicalWork.
Editing the schema. Automatically inferred schemas use only subsets of the
ShEx and SHACL languages. For instance, they never use shape references. We
can create complex schemas by editing the schema under construction. For
instance, using the information gathered from constr (QComp; P2) we can introduce
shape references in demo:Composition in Fig. 2 as follows.</p>
      <p>mo:composer @demo:Composer ;
mo:produced_work @demo:MusicalWork *</p>
    </sec>
    <sec id="sec-3">
      <title>Use Case : Explore Wikidata</title>
      <p>Wikidata is (partially) crowd-sourced, thus highly heterogeneous. This is an
essential di erence compared to the rst use case in which nodes with same
rdf:type have very similar properties. Shape Designer can be used to understand
the structure of Wikidata entries and assert the quality of such entries for a
particular application in mind. We assume the reader familiar with the basic
concepts of Wikidata (direct properties, property statements, quali ers).</p>
      <p>Shape Designer o ers special support for Wikidata in the form of Wikidata
project type that comes with prede ned pre xes and patterns. Shape
construction and validation are performed by querying the Wikidata SPARQL endpoint,
therefore we put a limit on the number of query results. Validating the whole
Wikidata set or even all entities of given type is computationally prohibitive.
In this context the most useful feature of Shape Designer are patterns, as they
allow to focus on a particular kind of information in Wikidata. For instance, a
simple pattern for direct properties allows to get an idea on which properties
can be expected for entities of given type. More complex patterns can account
for the presence of absence of provenance information.
5</p>
    </sec>
    <sec id="sec-4">
      <title>Conclusion</title>
      <p>
        We have presented Shape Designer, a versatile tool for constructing shape
schemas or exploring RDF datasets designed to be usable by novices and experts.
Shape Designer uses ideas similar to several prototype tools for extracting ShEx
or SHACL constraints from RDF graphs or from Wikidata [
        <xref ref-type="bibr" rid="ref1 ref2 ref3 ref4 ref5">1,2,3,4,5</xref>
        ]. The
originality of Shape Designer lies in shape patterns that provide a general and
succinct way to parametrize the automatic shape construction, and its user interface
that integrates schema editor, validator, and a way to explore the data.
      </p>
      <p>Shape Designer is being actively developed, in particular by adding more
functionality for exploring Wikidata. In the near future we plan to extend shape
patterns and the schema construction algorithm so that even more complex
schemas could be built automatically, including recursive shapes.
Acknowledgments This work was partially funded by a grant from CPER Nord-Pas
de Calais/FEDER DATA Advanced data science and technologies 2015-2020, by the
ANR project DataCert ANR-15-CE39-0009, by the Spanish Ministry of Economy and
competitiveness (Society Challenges: TIN2017-88877-R), and by the \Severo Ochoa"
research program (BP17-88).</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Fernandez-Alvarez</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Garc</surname>
            a-Gonzalez,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Frey</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hellmann</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Labra</surname>
            <given-names>Gayo</given-names>
          </string-name>
          ,
          <string-name>
            <surname>J.E.</surname>
          </string-name>
          :
          <article-title>Inference of Latent Shape Expressions Associated to DBpedia Ontology</article-title>
          . In: International Semantic Web Conference (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>Labra</given-names>
            <surname>Gayo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.E.</given-names>
            ,
            <surname>Fernandez-Alvarez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            ,
            <surname>Garc</surname>
          </string-name>
          a-Gonzalez, H.:
          <article-title>RDFShape: An RDF playground based on Shapes</article-title>
          .
          <source>In: Proceedings of ISWC</source>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Principe</surname>
            ,
            <given-names>R.A.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Spahiu</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Palmonari</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rula</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>De Paoli</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Maurino</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>ABSTAT 1.0: Compute, Manage and Share Semantic Pro les of RDF Knowledge Graphs</article-title>
          .
          <source>In: European Semantic Web Conference</source>
          . pp.
          <volume>170</volume>
          {
          <issue>175</issue>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Spahiu</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Maurino</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Palmonari</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Towards Improving the Quality of Knowledge Graphs with Data-driven Ontology Patterns and SHACL</article-title>
          . In: WOP@ISWC
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Werkmeister</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          :
          <article-title>Schema Inference on Wikidata</article-title>
          .
          <source>Master Thesis</source>
          (
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>