<!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>SWISH: An Integrated Semantic Web Notebook</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Wouter Beek</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jan Wielemaker</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>w.g.j.beek</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>j.wielemaker}@vu.nl</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Dept. of Computer Science, VU University Amsterdam</institution>
          ,
          <addr-line>NL</addr-line>
        </aff>
      </contrib-group>
      <pub-date>
        <year>1903</year>
      </pub-date>
      <abstract>
        <p>SPARQL editors like Yasgui [6] make it easier to write and inspect their results. Notebooks like Jupyter/IPython [5] already support computer- and data scientists in domains like statistics and machine learning. There is currently not an integrated notebook solution for Semantic Web programming that combines the strengths of SPARQL editors with the benefits of notebooks. The challenge is that Semantic Web formalisms are mostly logic-based and declarative, which does not always align naturally with imperative programming paradigm. SWISH takes a different approach by presenting an integrated notebook experience to the Semantic Web programmer that uses a declarative programming paradigm (SWI) as an integration layer.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
    </sec>
    <sec id="sec-2">
      <title>Requirements</title>
      <p>An integrated Semantic Web notebook must implement the following
requirements:
1. Be able to write queries in a modular way.
2. Be able to share these modules with others.
3. Be able to online collaborate with others on building, altering and combining
query modules.
4. Be able to interleave SPARQL patterns and filters with functions from other
programming paradigms (e.g., NLP, statistics, ML).
5. Be able to calculate query results under standardized and user-defined
entailment regimes.</p>
      <p>
        One of the main problems with existing SPARQL editors is that they do not allow
queries to be written in a modular way. This issue is only partially solved by
recent innovations like grlc [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] that allow full queries to be shared with others. The
problem is that SPARQL queries cannot be easily reused as self-contained
building blocks, which is possible in programming languages that allow self-contained
functions to be reused by other functions. The main challenge is that SPARQL,
like most other Semantic Web formalisms, follows a declarative paradigm. What
is needed is a programming paradigm that allows subqueries to be naturally
encapsulated in functions/predicates and modules (Requirement 1).
      </p>
      <p>Once queries can be written as modular code snippets, the online notebook
environment must allow these code snippets to be shared with other users
(Requirement 2). Existing technologies like ShareJS (1) make it easy for users to
collaboratively work on the same code. This functionality must be integrated
into a Semantic Web notebook as well (Requirement 3).</p>
      <p>In existing notebook systems one is not restricted to using only one
standardized syntax for querying. In fact, it is very important for data scientists to
be able to mix code from different programming and query languages
(Requirement 4). Use cases for these are evident in many areas, for instance the ability
to use Natural Language Processing (NLP) tools for fuzzy string matching (not
included in the SPARQL query language) or the ability to perform a statistical
test in R (2).</p>
      <p>The user must be able to perform entailment under arbitrary regimes. SPARQL
editors are tied to the restrictions of the entailment functionality that is exposed
by contemporary triples stores. Support for standardized entailment regimes
(RDF(S), OWL) is often partial and it is not always possible to specify
alternative entailment regimes or domain-specific custom rules. A Semantic Web
notebook should allow a user to specify her own deduction rules in addition to
standardized entailment regimes (Requirement 5).
3</p>
    </sec>
    <sec id="sec-3">
      <title>Implementation</title>
      <p>
        SWISH is implemented as a JavaScript (browser) client that runs in combination
with the Prolog-based ClioPatria triple store [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. The client/server
communication is implemented by using Pengines [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. A Pengine is a Prolog engine that
can be controlled through (remote) HTTP requests. It allows Prolog queries
to be performed from within JavaScript. Since arbitrary programs can be
executed, SWISH is not limited to functionality that is provided by standardized
Semantic Web query languages like SPARQL. For instance, the user can choose
to perform SQL and Datalog queries in addition to SPARQL queries. She can
perform entailment under a domain-specific or otherwise non-standard regime
in addition to RDF(S) and OWL.
      </p>
      <p>On the server-side code is executed within a sandboxed environment for
security and sustainability reasons. If full/unrestricted functionality is needed at
the server-side a user can deploy a remote or local SWISH instance herself by
cloning the SWISH repository3.
4</p>
    </sec>
    <sec id="sec-4">
      <title>Illustration</title>
      <p>As an example we take the following SPARQL query that enumerates labor
strikes that took place in Amsterdam in 1903:
1 See https://github.com/share/ShareJS
2 See https://www.r-project.org/
3 See https://github.com/SWI-Prolog/swish</p>
      <p>SELECT ?strike ?days ?workers ?place ?date ?place
WHERE {
?strike ex:days ?days .
?strike ex:workers ?workers .
?strike ex:place ?place
FILTER (langMatches(lang(?place), "nl"))
FILTER (lcase(str(?place)) = "Haarlem")
?strike ex:date ?date .</p>
      <p>FILTER (year(?date) == 1903)
}
LIMIT 10
In SWISH we can write any SPARQL query by using the rdf/3 predicate that
implements Simple Graph Pattern queries. SPARQL FILTER expressions are
implemented using a Domain-Specific Language extension (DSL): lang_matches/2
shows how this works (notation between curly braces). sounds/2 performs ‘sounds
like’ string matching as implemented by the NLP metaphone algorithm. This
illustrates how custom functions can be applied as filters within the query.4
strike_by_place_and_year(Strike, PlaceMatch, Year)
:rdf(Strike, ex:numberOfDays, NumDays),
rdf(Strike, ex:numberOfWorkers, NumWorkers),
rdf(Strike, ex:place, Place),
{lang_matches(Place, nl)},
4 Using lcase/2 would have replicated the SPARQL query.</p>
      <p>The predicate strike_by_place_and_year/3 has advantages over the SPARQL
version. The Prolog predicate can be used to enumerate the labor strikes in any
city and in any year. It can also be reused in other queries. Since SWISH
programs can be shared online, the Prolog predicate can also be reused in someone
else’s query. This functionality allows developers to incrementally build more
sophisticated queries on top of existing, proven and tested building blocks. This
is an effective way to avoid the large and complex SPARQL queries often found
in existing Semantic Web applications.
5</p>
    </sec>
    <sec id="sec-5">
      <title>Use cases &amp; Conclusion</title>
      <p>
        SWISH is able to support a variety of use cases. Recently TRILL-on-SWISH [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]
was released: a fuzzy OWL reasoner built on top of SWISH. It illustrates that
SWISH can be used to provide functionality that no existing SPARQL editor or
Semantic Web-compatible notebook can provide: reasoning over a non-standard
entailment regime5. SWISH development is still ongoing. The LOD
Laundromat team is currently using SWISH in order to expose the next version of
LOD Laundromat [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] for others to query online.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Beek</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rietveld</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bazoobandi</surname>
            ,
            <given-names>H.R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wielemaker</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Schlobach</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          : LOD Laundromat:
          <article-title>A uniform way of publishing other people's dirty data</article-title>
          .
          <source>In: ISWC</source>
          <year>2014</year>
          , pp.
          <fpage>213</fpage>
          -
          <lpage>228</lpage>
          . Springer (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Bellodi</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lamma</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Riguzzi</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zese</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cota</surname>
          </string-name>
          , G.:
          <article-title>A web system for reasoning with probabilistic OWL</article-title>
          .
          <source>Software: Practice and Experience</source>
          (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Lager</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wielemaker</surname>
          </string-name>
          , J.: Pengines:
          <article-title>Web logic programming made easy</article-title>
          .
          <source>Theory and Practice of Logic Programming</source>
          <volume>14</volume>
          (
          <issue>4-5</issue>
          ),
          <fpage>539</fpage>
          -
          <lpage>552</lpage>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Meroño-Peñuela</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hoekstra</surname>
          </string-name>
          , R.:
          <article-title>grlc makes GitHub taste like Linked Data APIs</article-title>
          .
          <source>In: Proceedings of the Services and Applications over Linked APIs and Data workshop</source>
          , ESWC (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Ragan-Kelley</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Perez</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Granger</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kluyver</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ivanov</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Frederic</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bussonier</surname>
            ,
            <given-names>M.:</given-names>
          </string-name>
          <article-title>The Jupyter/IPython architecture: a unified view of computational research, from interactive exploration to communication and publication</article-title>
          .
          <source>In: AGU Fall Meeting Abstracts</source>
          . vol.
          <volume>1</volume>
          , p.
          <volume>07</volume>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Rietveld</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hoekstra</surname>
          </string-name>
          , R.: Yasgui:
          <article-title>Not just another SPARQL client</article-title>
          .
          <source>In: Extended Semantic Web Conference</source>
          . pp.
          <fpage>78</fpage>
          -
          <lpage>86</lpage>
          . Springer (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Wielemaker</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Beek</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hildebrand</surname>
          </string-name>
          , M.,
          <string-name>
            <surname>van Ossenbruggen</surname>
            ,
            <given-names>J.:</given-names>
          </string-name>
          <article-title>ClioPatria: A SWI-Prolog infrastructure for the Semantic Web</article-title>
          .
          <source>Semantic Web Journal</source>
          <volume>7</volume>
          (
          <issue>5</issue>
          ),
          <fpage>529</fpage>
          -
          <lpage>541</lpage>
          (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>5 See http://trill.lamping.unife.it/</mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>