<!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>Discovering and Using Functions via Content Negotiation</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Ben De Meester</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Anastasia Dimou</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ruben Verborgh</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Erik Mannens</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Data Science Lab</institution>
          ,
          <country country="BE">Belgium</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Ghent University</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>Data has been made reusable and machine-interpretable by publishing it as Linked Data. However, automatically processing Linked Data is not fully achieved yet, as manual e ort is still needed to integrate existing tools and libraries within a certain technology stack. To enable automatic processing, we propose exposing functions and methods as Linked Data, and publishing it in di erent programming languages. Content negotiation can be used to cater to di erent technology stacks, and common, technology-independent identi ers make them discoverable. As such, we can enable automatic processing of Linked Data across formats and technology stacks. By using discovery endpoints, similar to those used to discover vocabularies and ontologies, the publication of these functions can remain decentralized.</p>
      </abstract>
      <kwd-group>
        <kwd>Content Negotiation</kwd>
        <kwd>Function</kwd>
        <kwd>Linked Data</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>By publishing data as Linked Data, we are moving to a Web of integrated,
reusable, and machine-interpretable data. However, to process that data, we need
processing instructions. E.g., calculating a distance between two points [x1, y1]
and [x2, y2] can be done using the Euclidean distance. This, in JavaScript,
could be calculated as Math.sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ).</p>
      <p>Libraries and repositories of common functions and methods exist1, but
integrating them still requires manual e ort to 'glue' the di erent libraries together.
Human intervention is needed, as functions are implemented in di erent
technologies, and the way of executing these functions is not declared semantically,
thus ruling out machine-interpretability.</p>
      <p>
        At the same time, there are many ongoing e orts to integrate processing
instructions and (Linked Data) applications. For example, integrating
processing functions when mapping from non-RDF data to RDF data [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], adding
custom functions in SPARQL queries [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], or creating compositions of hypermedia
APIs [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. Also, a lot of ongoing work is focussed on specifying
implementationindependent processing instructions using Web services (such as Hydra [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]).
However, relying on Web services means that (1) the applications using them and the
1 See, e.g., https://www.npmjs.com/package/euclidean-distance
services themselves must always be online, which is not feasible in every context,
and (2) all input and output needs to be transferred over HTTP, which hurts
performance. This to be transferred data might be too trivial (e.g., calculating a
geographic distance between two data points), or too large to be easily handled
in practice (e.g., calculating aggregates over billion-triple local data).
      </p>
      <p>
        In this paper, we propose publishing technology-independent function
descriptions as Linked Data. These descriptions provide a common reference for
processing instructions across technology stacks (e.g., JavaScript snippets vs.
Web services). To integrate the processing instructions in di erent technology
stacks, content negotiation can be used to publish the same functions in di erent
implementations [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], either accessed remotely as a Web service or downloaded
locally to be automatically integrated in the local technology stack. This way,
we make similar methods in di erent programming languages available, just as
websites are made available in di erent human (natural) languages, or as
content is made available both for humans as for machines. This allows for more
automatic composition of processing instructions, thus building towards the
intelligent agents as initially envisioned when rst proposing the Semantic Web.
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Methodology</title>
      <p>The proposed methodology consists of the following parts (Figure 1):
1. provide technology-independent semantic descriptions of functions,
2. publish these functions, both their semantic description and the speci c
implementations (not necessarily all at the same place),
3. make the semantic descriptions discoverable and queryable, and
4. provide content negotiation to allow uniform access to di erent
implementations.</p>
      <p>
        We achieve the rst part of this methodology using for instance the
Function Ontology [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. The Function Ontology is a technology-independent way of
describing functions of various complexity, without any assumptions on
programming paradigms. It consists of only six base classes and ve relations. It
is used to describe a Function that possibly solves a certain Problem, and
possibly implements some Algorithms. The Function expects zero or more
Parameters and returns zero or more Outputs. An Execution executes a
certain Function by binding values to the Parameters. The Euclidean distance
function could thus be described as follows:
ex:euclidDistanceFn a fno:Function ;
fno:solves ex:EuclideanDistanceProblem ;
fno:expects ( ex:dataPoint1 ex:dataPoint2 ) ;
fno:returns ( xsd:double ) .
      </p>
      <p>We consider the Function Ontology as it is small and
technology/problemdomain independent, and thus allows for easier reuse2. Such a function
description serves as a common reference across technology stacks.
2 http://w3id.org/function/spec</p>
      <p>Discovering and Using Functions via Content Negotiation</p>
      <p>POST /_query
(1)</p>
      <p>Accept: application/x-javascript
_:a
fno:solves
ex:EuclideanDistanceProblem .
(2)Redirect 303
s2.example.com/euclidean.js
Web service</p>
      <p>JAVA function
s1.example.com
(0)</p>
      <p>JavaScript function
(3) function euclidean (points) { […] }
s2.example.com</p>
      <p>
        Just as Linked Open Vocabularies [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] provides for a discovery endpoint to
vocabularies and ontologies, functions can be submitted to similar discovery
endpoints (Figure 1 (0))3. No actual implementations are hosted on these endpoints,
but the semantic descriptions can be aggregated, and content negotiation can
be set up to direct the user to the di erent implementations across servers. For
example, when a user needs a certain functionality in a certain technology, she
can query discovery endpoints for functions that solve a given problem, and are
available in a speci c format (in the case of Figure 1 (1), a JavaScript snippet).
The discovery endpoint can then redirect (2) the user to a server hosting the
actual code (3).
3
      </p>
    </sec>
    <sec id="sec-3">
      <title>Discussion</title>
      <p>The proposed methodology uses widespread methods to publish and discover
functions, catered to di erent needs. However, they also inherit the same risks
as there are in the current Web: just as websites are not always accessible in
the language you prefer, functions might not be implemented in the technology
needed. Fortunately, similar workarounds can be used: as best-e ort automatic
translation systems can provide for translations of websites to your preferred
language, there exist engines that use emulation or code translation to allow
incorporating code snippets from a di erent programming language4.
3 This compares to a technology-independent https://www.haskell.org/hoogle/
(that helps users discover Haskell functions by type signature), but where the
semantics of a function is also taken into account.
4 See, e.g. the Nashorn engine to use JavaScript procedures within the Java Virtual</p>
      <p>Machine (https://blogs.oracle.com/nashorn/).</p>
      <p>
        Furthermore, the proposed methodology allows for choosing between remote
web services and locally downloaded methods. Depending on the context
(online/o ine, execution rate and/or data throughput) a user can decide whether
to use the online service, or download the method locally (given that both exist).
The latter would involve (automatically) integrating the downloaded code in the
parent application. Depending on the technology used, the client will need to
interpret the semantic description of a function, to know how to actually
execute a function. For Web services, many declarative description formats exist
to automatically derive this (e.g., Hydra [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]). For other technologies, additional
descriptions might be necessary.
4
      </p>
    </sec>
    <sec id="sec-4">
      <title>Conclusion</title>
      <p>Functions can be described semantically and technology-independent using the
Function Ontology. By publishing these descriptions alongside their
implementations, we provide a uniform access to similar functions for di erent technologies,
both accessible remotely and downloadable locally. These implementations can
exist distributed, but are made discoverable using centralized endpoints, similar
to widely adopted portals such as Linked Open Vocabularies. This in turn allows
for machine-interpretable and discoverable libraries of functions.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>De Meester</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dimou</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Verborgh</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mannens</surname>
            , E., Van de Walle,
            <given-names>R.:</given-names>
          </string-name>
          <article-title>An ontology to semantically declare and describe functions</article-title>
          .
          <source>In: Proceedings of the 13th ESWC: Satellite Events</source>
          (
          <year>2016</year>
          ), accepted for publication
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Debruyne</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>O'Sullivan</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          :
          <string-name>
            <surname>R2RML-F</surname>
          </string-name>
          :
          <article-title>Towards sharing and executing domain logic in R2RML mappings</article-title>
          .
          <source>In: Workshop on Linked Data on the Web</source>
          (
          <year>2016</year>
          ), http: //events.linkeddata.org/ldow2016/papers/LDOW2016_paper_14.pdf
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Fielding</surname>
          </string-name>
          , R.T.,
          <string-name>
            <surname>Reschke</surname>
          </string-name>
          , J.:
          <source>Hypertext Transfer Protocol (HTTP/1</source>
          .1):
          <article-title>Semantics and content { content negotiation</article-title>
          .
          <source>Tech. rep.</source>
          ,
          <string-name>
            <surname>IETF</surname>
          </string-name>
          (
          <year>June 2014</year>
          ), http://tools. ietf.org/html/rfc7231#
          <fpage>section</fpage>
          -
          <lpage>3</lpage>
          .4,
          <string-name>
            <surname>accessed</surname>
            <given-names>January</given-names>
          </string-name>
          26th,
          <year>2015</year>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Lanthaler</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          , Gutl, C.:
          <article-title>Hydra: A Vocabulary for Hypermedia-Driven Web APIs</article-title>
          . In: LDOW,
          <string-name>
            <surname>WWW</surname>
          </string-name>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Regalia</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Janowicz</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gao</surname>
            ,
            <given-names>S.:</given-names>
          </string-name>
          <article-title>VOLT: A provenance-producing, transparent SPARQL proxy for the on-demand computation of linked data and its application to spatiotemporally dependent data</article-title>
          .
          <source>In: The Semantic Web. Latest Advances and New Domains</source>
          (
          <year>2016</year>
          ), http://geog.ucsb.edu/~jano/eswc2016.pdf
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Vandenbussche</surname>
          </string-name>
          , P.Y.,
          <string-name>
            <surname>Atemezing</surname>
            ,
            <given-names>G.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Poveda-Villalon</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vatant</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>Linked Open Vocabularies (LOV): a gateway to reusable semantic vocabularies on the web</article-title>
          .
          <source>Semantic Web</source>
          (
          <year>2015</year>
          ), http://www.semantic
          <article-title>-web-journal</article-title>
          .net/system/files/ swj1178.pdf, accepted for publication
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Verborgh</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Arndt</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Van Hoecke</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>De Roo</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mels</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Steiner</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gabarro</surname>
            <given-names>Valles</given-names>
          </string-name>
          ,
          <string-name>
            <surname>J.:</surname>
          </string-name>
          <article-title>The pragmatic proof: Hypermedia API composition and execution</article-title>
          .
          <source>Theory and Practice of Logic Programming</source>
          (
          <year>2016</year>
          ), http://arxiv.org/ pdf/1512.07780v1.pdf, accepted for publication
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>