<!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>Ruby Semantic Web Pipes</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Daniel Hahn</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Michele Barbera</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Internet Open Solutions - Pisa (hahn</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>barbera)@netseven.it</string-name>
        </contrib>
      </contrib-group>
      <abstract>
        <p>Ruby SemPipes are based on the Semantic Web Pipes proposed by Giovanni Tummarello, Christian Morbidoni et. al. [1]. Semantic web pipes provide a mechanism similar to Yahoo! Pipes1, but work on semantic web data. They allow users to filter and recombine semantic web data on the fly (more information can be found in the cited work). The original Semantic Pipes also have some advanced features that are not touched here, such as the revocation of triples. Ruby SemPipes 2. are an intentionally simple reimplementation of the Semantic Web Pipes. They provide an easy “pipe description language” . Pipes can easily be created and modified from a script or application, the definitions are painless to read and they don't require the pipe developer to manually edit XML files or SPARQL queries. To make things simple, Ruby SemPipes treat all RDF graphs as enumerations of triples. A pipe itself is also an enumeration over it's result set and any enumeration of triples (including other pipes) can be used as an input for a pipe. Using Eyal Oren's ActiveRDF [2] library, it will be quite easy to provide input adapters that connect to “real” RDF endpoints and perform SPARQL queries. These adapters could then be used as input to a pipe. Conversely, output adapters could re-write the result of a pipe to a common storage format, such as RDF/XML. The first implementation of Ruby SemPipes contains a merge, filter and rewrite operator; a smushing operator is in the pipeline. The filter and rewrite operators allow a simple but powerful filtering (or rewriting) of triples using regular expression. In addition to the operators, pipes may also contain actions which allow the developer to manipulate triples programmatically. All built-in operators are themselves pipes written in the same way as user-created pipes. Each pipe takes on ore more sets of RDF triples as an input; the pipe itself will operate on the union (including duplicates) of the input sets - the merge operator will actually just remove duplicates from the input.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p># R e w r i t e Tim Berners Lee e n t r i e s
r e w r i t t e n _ t r i p l e s = r e w r i t e ( m e r g e d _ t r i p l e s ) do
r e w r i t e : a l l ,
"&lt;http : \ / \ / dbpedia . org \/ r e s o u r c e \/ Tim_Berners Lee&gt;" ,
"&lt;http : / /www. w3 . org / People / Berners Lee / card#i &gt;"
end
# Remove a l l t r i p l e s d e a l i n g w i t h A l i c e
s e l f . output = f i l t e r ( r e w r i t t e n _ t r i p l e s ) do</p>
      <p>r e j e c t : a l l "&lt;http : \ / \ / s t r a n g e w o r l d . com\\/ A l i c e "
end
end
# D e f i n e a n o t h e r p i p e
d e f i n e _ p i p e : another_pipe do
temp = new_pipe ( i n p u t )
s e l f . output = a c t i o n ( temp ) do | i n p u t |</p>
      <p>i n p u t . to_a &lt;&lt; [ @subject , @predicate , @object ]
end
end
# Use t h e p i p e</p>
      <p>AnotherPipe . new ( load_some_input ) . each { | t r i p l e | puts t r i p l e }
end</p>
      <p>Listing 1.1 shows a sample setup of two Ruby SemPipes. The first pipe merges
all input sets, then rewrites Tim Berners-Lee’s dbpedia URL with his own URL
and finally filters out all entries dealing with Alice. Pipes can be easily connected
using variables; the special variable input is used in the pipe description to
denote the pipe’s input. The self.output variable is used to assign a value to
the current pipe’s result set.</p>
      <p>The second pipe shows that other pipes can be used just as easily as the
built-in operators. The pipe also contains a generic action that adds a (complete
random) triple to the graph.</p>
      <p>Acknowledgements
This work has been supported by Discovery, an ECP 2005 CULT 038206 project
under the EC eContentplus programme. Of course we also like to acknowledge
the original work of Christian and Giovanni.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Morbidoni</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Polleres</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Phuoc</surname>
            ,
            <given-names>D.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tummarello</surname>
          </string-name>
          , G.:
          <article-title>Semantic web pipes</article-title>
          .
          <source>Technical report, DERI</source>
          (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Oren</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Debru</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gerke</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Haller</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Decker</surname>
            ,
            <given-names>S.:</given-names>
          </string-name>
          <article-title>ActiveRDF: Object-Oriented Semantic Web Programming</article-title>
          .
          <source>In: 16th International World Wide Web Conference (WWW2007)</source>
          , Banff, Alberta, Canada. (
          <volume>8</volume>
          -12 May,
          <year>2007</year>
          )
          <fpage>817</fpage>
          -
          <lpage>823</lpage>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>