<!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>DRPD: Architecture for Intelligent Interaction with RDF Pre xes</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Dominik Tomaszuk</string-name>
          <email>d.tomaszuk@uwb.edu.pl</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Karol Litman</string-name>
          <email>karolks94@gmail.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Institute of Informatics, University of Bialystok ul. Ciolkowskiego 1M</institution>
          ,
          <addr-line>15-245 Bialystok</addr-line>
          ,
          <country country="PL">Poland</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Internationalized Resource Identi er (IRI) references are an inseparable part of the Semantic Web. Sometimes the references are difcult to remember, so many Resource Description Framework (RDF) serializations, e.g. Turtle, allow to shorten them. This paper describes how to nd the appropriate pre x, and resolved them to the full IRI reference. Many endpoints that provide information about pre xes and namespaces can exist in our architecture. The tools that we present are not as sensitive to failures as centralized solutions and let users use multiple pre x endpoints at the same time.</p>
      </abstract>
      <kwd-group>
        <kwd>RDF pre x</kwd>
        <kwd>namespaces</kwd>
        <kwd>decentralization</kwd>
        <kwd>Turtle</kwd>
        <kwd>REST- ful web service</kwd>
        <kwd>API</kwd>
        <kwd>intelligent clients</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>In this paper we present tools and methods that make access to pre xes more
decentralized and less prone to failures. We also propose an architecture for
decentralization namespace lookup services. Moreover, we introduce a serialization,
which allows to de ne endpoints that are compatible with our architecture.</p>
      <p>The paper is constructed according to sections. In Section 2 we present our
architecture and serialization. In Section 3 we demonstrate our tools and discuss
their user interface. The paper ends with conclusions.
2</p>
    </sec>
    <sec id="sec-2">
      <title>System Architecture</title>
      <p>
        Our architecture assumes the existence of many RESTful web services [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] with
their storages. Various types of applications can communicate with these web
services. The diagram of our architecture is shown in Fig. 1. Our demo system
consists of a web service (Subsection 2.1), a console application (Subsection 2.2),
a web application (Subsection 2.3), and a database (Subsection 2.4). All elements
of the system form a coherent whole and are based on the RESTful web service.
The single system in a DRPD architecture is presented in Fig. 2. The main
element of architecture is web service with open API. Di erent clients (e.g.
console application, web application) can use any endpoints that is compatible
with the API described below. In Subsection 2.2 we also propose Turtled, a
serialization that extends Turtle to support many endpoints resolving pre xes.
      </p>
      <p>Web app</p>
      <p>Console app
RESTful
web service</p>
      <p>Storage</p>
      <p>
        Web
In our proposed architecture, we assume the existence of many RESTful web
services [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. The main part of the architecture are web services, which are based
HTTP request
POST method
      </p>
      <p>IRI /api/prepare
HTTP
request</p>
      <p>HTTP response</p>
      <p>JSON
on REST architecture. We implemented our web service in the Limonade3
microframework. This microframework o ers a number of functions that facilitate
the implementation of services based on HTTP(S) protocol methods.</p>
      <p>The key function of our tool is to modify the Turtle's documents. This
operation nds pre xes that do not have declared namespaces and choose the best one.
Finally, the document is displayed in the body of the response. The supported
formats are Turtle, JSON-LD, N-Triples, and RDF/XML.</p>
      <p>One of the most important functionalities of the web service is searching
for namespaces for a speci c pre x. To receive data, the GET method should be
used. When a client calls the web service, documents containing the speci ed
pre x are retrieved from the database. If there is no namespace, the response
code is 404. The default serialization is JSON-LD, but we support also Turtle.
To receive Turtle data the Accept header with the text/turtle value should be
used. A response return 15 items by default. The limit parameter after query
string is used to change the number of displayed elements.</p>
      <p>Our tool supports namespace declarations for Turtle, RDF/XML, RDFa,
JSON-LD serializations, SPARQL query language, plain text, CSV and TSV
data formats. To receive a declaration in these formats the GET method sould be
used. The returned data can be in plain text or in Turtle.</p>
      <p>
        Being signed in a user receive the access to perform additional operations.
For this purpose, the OAuth2 [
        <xref ref-type="bibr" rid="ref5 ref6">5,6</xref>
        ] is used to authenticate users, which allows
to identify users using well-known OAuth2 servers such as Google, Facebook,
Twitter, Github, etc. To perform the operations that required authentication,
the Authorization header with the Bearer access-token value should be sent.
An authenticated user can add new namespaces to a given pre x. To successfully
      </p>
      <sec id="sec-2-1">
        <title>3 https://limonade-php.github.io/</title>
        <p>add a namespace, user should send a JSON-LD document by using the POST
method.</p>
        <p>The second operation requiring authentication is voting. Having a namespace,
we can vote 'for' (plus) or 'against' (minus) using the POST method. In one pre x
we have the possibility to add one plus and many minuses. If one make a mistake,
she/he can delete the vote by using the DELETE method. If the POST method is
executed successfully the response 201 code is returned, and if the resource is
already exists the 409 code is returned.</p>
        <p>
          Another feature of the web service is the ability to preview popular pre xes
that have the most votes. To receive that answer, a user should send GET method.
The response can be in the JSON-LD or in Turtle. It supports the pagination
using the Hydra vocabulary [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ]. In this URL user can set two parameters: offset
and page. The rst parameter de nes how many pre xes can be displayed per
a page, while the second parameter indicate the current page.
2.2
        </p>
        <p>
          Turtled and Console Application
In this subsection we propose Turtled. It is a serialization that extends Turtle
to support many decentralized RESTful web services. We expand the Turtle
grammar to the @prefix endpoint directive, which points to various web
services that resolve pre xes. Listing 1.1 shows an extended grammar of Turtle in
EBNF.
[
          <xref ref-type="bibr" rid="ref3">3</xref>
          ] d i r e c t i v e ::= p r e f i x I D j base j s p a r q l P r e f i x
[ 5 e ] endpoint ::= j' @sppraerfqi xlBeansde point ' IRIREF ' . '
        </p>
        <p>j endpoint</p>
        <sec id="sec-2-1-1">
          <title>Listing 1.1. Turtled grammar</title>
          <p>Another independent part of our architecture is the console application,
which aims to show the use of the web service (see Subsection 2.1). This console
application works according to the following steps. In the rst step, the script
nds the @prefix endpoint directive in the Turtle/Turtled document that
contains the web service IRI references. As a result, the web service returns a
response about successful or negative modi cation of the Turtle document. If the
script receive a negative response, it attempt to send to the other existing web
service form the second @prefix endpoint directive.
2.3</p>
          <p>Web Application
A web application is designed to support the web service (Subsection 2.1), which
is designed to send HTTP requests and present data in a user-friendly form. Each
webpage is described using RDFa. The application is adapted to mobile devices.
The elements on the webpages have been separated so that a user can click
exactly on one element in the mobile devices.</p>
          <p>The application at the top has a menu to help you navigate the site. In the
upper right corner there is the Sign in to get permission button which allows
users to sign in. Being signed in, a user get permission to manage namespaces.
On the main page of the site there is also a search engine that helps to nd a
speci c pre x.</p>
          <p>After entering the pre x, the middle part of the page is reloaded. Below the
menu there is a header that inform about the current pre x. A user can vote for
the namespace with plus or minus by clicking the appropriate button. When a
user click Add alternative namespace, a text box appears and let a user to add
a new namespace. At the bottom of the page there are a few data formats with
current pre x and namespace.</p>
          <p>The web application also can show the popular pre xes. The key feature of
our application is the preparation of Turtled documents (see Subsection 3).
2.4</p>
          <p>
            Database
The part that collects data is a database based on JSON documents and the
REST architecture [
            <xref ref-type="bibr" rid="ref4">4</xref>
            ] which is CouchDB [
            <xref ref-type="bibr" rid="ref2">2</xref>
            ]. It is document-oriented database
that focuses on having a scalable architecture. CouchDB can be used in scalable
and distributed systems. This database uses replication to propagate application
changes across participating nodes. We choose that database management
system because it could ensure fault-tolerance, which is important feature for web
application.
          </p>
          <p>Each occurring document in the database is an object representing a
namespace. The database diagram is shown in Fig 3.</p>
          <p>document JSON
+ namespace: string
+ prefix: string
+ pluses: object
+ minuses: object
+ score: int</p>
          <p>pluses
+ Google: string []
+ Facebook: string []
+ Github: string []
+ Reddit: string []</p>
          <p>minuses
+ Google: string []
+ Facebook: string []
+ Github: string []
+ Reddit: string []</p>
          <p>document JSON
+ _id: string
+ account_id: string
+ expires: object
+ minuses: object
The RESTful web service can be tested at https://prefix.chemskos.com/
api/. One of the main functionalities is nding namespaces of pre x. This
operation requires GET method. Listing 1.2 shows the namespaces related to pre xes.
c u r l X GET ' https : / / p r e f i x . chemskos . com/ api / f o a f ' n
H ' accept : t e x t / t u r t l e '</p>
          <p>Listing 1.2. Request in curl showing namespaces</p>
          <p>The obtained data can be in JSON-LD or Turtle formats. If there are not
any pre xes, it will be returned 404 error. Listing 1.3 shows response containing
namespaces in Turtle format.
@prefix p r e s : &lt;http : / / i i . uwb . edu . p l / p r e f i x r e s o l v e r#&gt; .
[ ] &lt;p r e s : namespaces&gt; (
[
&lt;p r e s : namespace&gt; " http : / / xmlns . com/ f o a f /0.1/" ;
&lt;p r e s : score &gt; 1 ;
]
) .</p>
        </sec>
        <sec id="sec-2-1-2">
          <title>Listing 1.3. Response showing namespaces</title>
          <p>
            The response to access the namespace declaration is shown in Listing 1.4. The
supported formats are Turtle, RDF/XML, RDFa, JSON-LD, SPARQL, CSV,
and TSV. Additionally, we add support for a plain namespace that can be used
independently of RDF serialization. This can de ned by Well-Known URIs [
            <xref ref-type="bibr" rid="ref8">8</xref>
            ].
c u r l X GET n
' https : / / p r e f i x . chemskos . com/ api / f o a f / formats / r d f /xml ' n
H ' accept : t e x t / plain '
          </p>
          <p>Listing 1.4. Request in curl for declaration namespace</p>
          <p>Namespaces are added using POST method. The active access token is
necessary to perform function. The request has been shown on Listing 1.5.
c u r l X POST n
' https : / / p r e f i x . chemskos . com/ api / f o a f ' n
H ' accept : a p p l i c a t i o n / l d+json ' n
H ' A u t h o r i z a t i o n : Bearer a c c e s s token ' n
d 'f
" @context " : f" p r e s " : " http : / / i i . uwb . edu . p l / p r e f i x r e s o l v e r #"g,
"@id " : " https : / / p r e f i x . chemskos . com/ api / f o a f " ,
" p r e s : namespace " : " http : / / namespace . com/ ns#"
g '</p>
          <p>Listing 1.5. Request in curl for creating a new namespace</p>
          <p>Displaying popular pre xes can be presented in JSON-LD or Turtle
serializations. The request has been shown on Listing 1.6
c u r l X GET n
' https : / / p r e f i x . chemskos . com/ api / popular ' n
H ' accept : t e x t / t u r t l e ' n</p>
          <p>Listing 1.6. Request in curl showing popular pre xes</p>
          <p>The last functionality is submitting Turtled or Turtle documents. After
modi cation the RDF le can be downloaded. Listing 1.7 shows the submission of
Turtled. After transformation N-Triples is expected.
c u r l X POST n
' https : / / p r e f i x . chemskos . com/ api / prepare ' n
H ' accept : a p p l i c a t i o n /n t r i p l e s ' n
F f i l e =@ p a t h t o f i l e . t t l</p>
          <p>Listing 1.7. Submitting Turtled document</p>
          <p>The source code can be found on
https://github.com/KarolLitman/Dictionaryof-RDF-Pre xes-webservice.</p>
          <p>The API documentation was created, which facilitates the understanding
of the service in a readable manner. The documentation consists of queries
that can be performed on the RESTful web service. Additionally, by clicking
on a given method, a user obtains sample source code, structure of the query,
required parameters and displaying all possible errors in the method.
Swagger4 was used to create the API documentation. It can be found on https:
//prefix.chemskos.com/api/doc/. The documentation shows samples of
usage in various programming languages.</p>
          <p>The web application can be viewed at https://prefix.chemskos.com/. The
application at the top has a menu to help users navigate the site. The menu
contains hyperlinks for the Home page, Popular page and Prepare document
page. In the right corner there is the Sign in to get permission button which
allows a user to sign in. In Fig. 4 the web page with found pre x is presented.</p>
          <p>The use of the web application has been presented on the screencast and
published on https://www.youtube.com/watch?v=-hSYA8epMlA. The
source code can be found on
https://github.com/KarolLitman/Dictionary-ofRDF-Pre xes-webapp.</p>
          <p>The use of the console application has been presented on the screencast and
published on https://www.youtube.com/watch?v=O4tjuo1BB24. The
screencast shows how the application deals with broken endpoints. The source
code can be found on https://github.com/KarolLitman/Dictionary-of-RDF-Pre
xesbashscript.</p>
        </sec>
      </sec>
      <sec id="sec-2-2">
        <title>4 http://docs.swagger.io/spec.html</title>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Conclusions</title>
      <p>Decentralization is the key to resilience in Internet applications. In this paper
we present a DRPD architecture that are decentralized. We demonstrate four
elements of our architecture: RESTful web service with documented API, web
application with client-side that remote calling resources from our endpoint,
console application that also use our web service, and RESTful document-oriented
database. Moreover, we propose Turtled serialization that supports endpoints
that are compatible with our architecture.</p>
      <p>We have taken an initial step in easier delivery of pre xes and namespaces.
In future work we would like to extend this work to other serializations that use
pre xes. The next key challenge will be to provide more decentralized way of
addressing the pre x endpoints e.g. using Magnet URI scheme or ni URI scheme.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>Ben</given-names>
            <surname>Adida</surname>
          </string-name>
          ,
          <string-name>
            <surname>Shane</surname>
            <given-names>McCarron</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>Ivan</given-names>
            <surname>Herman</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Mark</given-names>
            <surname>Birbeck</surname>
          </string-name>
          .
          <source>RDFa Core 1</source>
          .
          <fpage>1</fpage>
          -
          <string-name>
            <given-names>Third</given-names>
            <surname>Edition</surname>
          </string-name>
          . W3C recommendation,
          <issue>W3C</issue>
          ,
          <year>March 2015</year>
          . http://www.w3.org/ TR/2015/REC-rdfa-core-
          <volume>20150317</volume>
          /.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>J</given-names>
            <surname>Chris Anderson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Jan</given-names>
            <surname>Lehnardt</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Noah</given-names>
            <surname>Slater. CouchDB: The De nitive Guide</surname>
          </string-name>
          : Time to
          <string-name>
            <surname>Relax. O'Reilly Media</surname>
          </string-name>
          , Inc.,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>Tim</given-names>
            <surname>Bray</surname>
          </string-name>
          , Andrew Layman, Richard Tobin, and
          <string-name>
            <given-names>Dave</given-names>
            <surname>Hollander</surname>
          </string-name>
          .
          <article-title>Namespaces in XML 1.1 (Second Edition)</article-title>
          .
          <source>W3C recommendation, W3C</source>
          ,
          <year>August 2006</year>
          . http: //www.w3.org/TR/2006/REC-xml-names11-
          <volume>20060816</volume>
          /.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4. Roy T Fielding and Richard N Taylor.
          <article-title>Architectural styles and the design of network-based software architectures</article-title>
          , volume
          <volume>7</volume>
          . University of California,
          <source>Irvine Doctoral dissertation</source>
          ,
          <year>2000</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>D.</given-names>
            <surname>Hardt</surname>
          </string-name>
          .
          <source>The OAuth 2.0 Authorization Framework. RFC 6749</source>
          , RFC Editor,
          <year>October 2012</year>
          . http://www.rfc-editor.
          <source>org/rfc/rfc6749.txt.</source>
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>M.</given-names>
            <surname>Jones</surname>
          </string-name>
          and
          <string-name>
            <given-names>D.</given-names>
            <surname>Hardt</surname>
          </string-name>
          .
          <source>The OAuth 2.0 Authorization Framework: Bearer Token Usage. RFC 6750</source>
          , RFC Editor,
          <year>October 2012</year>
          . http://www.rfc-editor.
          <source>org/rfc/ rfc6750.txt.</source>
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>Markus</given-names>
            <surname>Lanthaler</surname>
          </string-name>
          , Gregg Kellogg, and
          <string-name>
            <given-names>Manu</given-names>
            <surname>Sporny</surname>
          </string-name>
          .
          <article-title>JSON-LD 1.0. W3C recommendation, W3C</article-title>
          ,
          <year>January 2014</year>
          . http://www.w3.org/TR/2014/ REC-json-ld-
          <volume>20140116</volume>
          /.
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>M.</given-names>
            <surname>Nottingham</surname>
          </string-name>
          and
          <string-name>
            <given-names>E.</given-names>
            <surname>Hammer-Lahav</surname>
          </string-name>
          .
          <article-title>De ning Well-Known Uniform Resource Identi ers (URIs)</article-title>
          .
          <source>RFC 5785</source>
          , RFC Editor,
          <year>April 2010</year>
          . http://www.rfc-editor.
          <source>org/rfc/rfc5785.txt.</source>
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>Eric</given-names>
            <surname>Prud</surname>
          </string-name>
          <article-title>'hommeaux and Gavin Carothers</article-title>
          .
          <source>RDF 1</source>
          .1 Turtle. W3C recommendation,
          <issue>W3C</issue>
          ,
          <year>February 2014</year>
          . http://www.w3.org/TR/2014/REC-turtle-
          <volume>20140225</volume>
          /.
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <article-title>Guus Schreiber and Fabien Gandon. RDF 1.1 XML Syntax</article-title>
          .
          <article-title>W3C recommendation, W3C</article-title>
          ,
          <year>February 2014</year>
          . http://www.w3.org/TR/2014/ REC-rdf
          <string-name>
            <surname>-</surname>
          </string-name>
          syntax-grammar-
          <volume>20140225</volume>
          /.
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Manu</surname>
            <given-names>Sporny</given-names>
          </string-name>
          , Ivan Herman,
          <source>Ben Adida, and Mark Birbeck. RDFa 1</source>
          .1 Primer - Third
          <string-name>
            <surname>Edition</surname>
          </string-name>
          . W3C note, W3C,
          <year>March 2015</year>
          . http://www.w3.org/TR/2015/ NOTE-rdfa-primer-
          <volume>20150317</volume>
          /.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>