--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/aRDF/algebraic/src/main/scala/Algebraic.scala Sun Feb 05 21:37:53 2012 -0500
@@ -0,0 +1,31 @@
+package org.w3.algebraic
+
+trait UnApply0[R] {
+ def unapply(r: R): Boolean
+}
+
+trait AlgebraicDataType0[R] extends Function0[R] with UnApply0[R]
+
+trait UnApply1[T, R] {
+ def unapply(r: R): Option[T]
+}
+
+trait AlgebraicDataType1[T, R] extends Function1[T, R] with UnApply1[T, R]
+
+trait UnApply2[T1, T2, R] {
+ def unapply(r: R): Option[(T1, T2)]
+}
+
+/**
+ * basically, you have to implement both following functions
+ * def apply(t1:T1, t2:T2):R
+ * def unapply(r:R):Option[(T1, T2)]
+ */
+trait AlgebraicDataType2[T1, T2, R] extends Function2[T1, T2, R] with UnApply2[T1, T2, R]
+
+trait UnApply3[T1, T2, T3, R] {
+ def unapply(r: R): Option[(T1, T2, T3)]
+}
+
+trait AlgebraicDataType3[T1, T2, T3, R] extends Function3[T1, T2, T3, R] with UnApply3[T1, T2, T3, R]
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/aRDF/graph-isomorphism/src/main/scala/GraphIsomorphism.scala Sun Feb 05 21:37:53 2012 -0500
@@ -0,0 +1,7 @@
+package org.w3.rdf
+
+abstract class GraphIsomorphism[M <: Model](val m: M) {
+
+ def isIsomorphicWith(g1: m.Graph, g2: m.Graph): Boolean
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/aRDF/jena/src/main/scala/GraphIsomorphismForJenaModel.scala Sun Feb 05 21:37:53 2012 -0500
@@ -0,0 +1,11 @@
+package org.w3.rdf
+
+import org.w3.rdf.jena._
+
+object GraphIsomorphismForJenaModel extends GraphIsomorphism[JenaModel.type](JenaModel) {
+
+ def isIsomorphicWith(g1: m.Graph, g2: m.Graph): Boolean =
+ g1.jenaGraph isIsomorphicWith g2.jenaGraph
+
+
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/aRDF/jena/src/main/scala/JenaModel.scala Sun Feb 05 21:37:53 2012 -0500
@@ -0,0 +1,113 @@
+package org.w3.rdf.jena
+
+import org.w3.rdf._
+import com.hp.hpl.jena.graph.{Graph => JenaGraph, Triple => JenaTriple, Node => JenaNode, _}
+import com.hp.hpl.jena.rdf.model.{AnonId}
+import com.hp.hpl.jena.datatypes.{RDFDatatype, TypeMapper}
+
+import org.w3.algebraic._
+
+object JenaModel extends Model {
+
+ class Graph(val jenaGraph: JenaGraph) extends GraphInterface {
+ def iterator: Iterator[Triple] = new Iterator[Triple] {
+ val iterator = jenaGraph.find(JenaNode.ANY, JenaNode.ANY, JenaNode.ANY)
+ def hasNext = iterator.hasNext
+ def next = iterator.next
+ }
+ def ++(other: Graph):Graph = {
+ val g = Factory.createDefaultGraph
+ iterator foreach { t => g add t }
+ other.iterator foreach { t => g add t }
+ new Graph(g)
+ }
+
+ }
+
+ object Graph extends GraphCompanionObject {
+ def fromJena(jenaGraph: JenaGraph): Graph = new Graph(jenaGraph)
+ def empty: Graph = new Graph(Factory.createDefaultGraph)
+ def apply(elems: Triple*): Graph = apply(elems.toIterable)
+ def apply(it: Iterable[Triple]): Graph = {
+ val jenaGraph = Factory.createDefaultGraph
+ it foreach { t => jenaGraph add t }
+ new Graph(jenaGraph)
+ }
+ }
+
+ type Triple = JenaTriple
+ object Triple extends AlgebraicDataType3[Node, IRI, Node, Triple] {
+ def apply(s: Node, p: IRI, o: Node): Triple = {
+ val predicate = NodeIRI(p)
+ JenaTriple.create(s, predicate, o)
+ }
+ def unapply(t: Triple): Option[(Node, IRI, Node)] =
+ (t.getSubject, t.getPredicate, t.getObject) match {
+ case (Node(s), NodeIRI(p), Node(o)) => Some((s, p, o))
+ case _ => None
+ }
+ }
+
+ type Node = JenaNode
+ object Node {
+ def unapply(node: JenaNode): Option[Node] =
+ if (node.isURI || node.isBlank || node.isLiteral) Some(node) else None
+ }
+
+ type NodeIRI = JenaNode
+ object NodeIRI extends AlgebraicDataType1[IRI, NodeIRI] {
+ def apply(iri: IRI): NodeIRI = { val IRI(s) = iri ; JenaNode.createURI(s).asInstanceOf[Node_URI] }
+ def unapply(node: NodeIRI): Option[IRI] = if (node.isURI) Some(IRI(node.getURI)) else None
+ }
+
+ type NodeBNode = JenaNode
+ object NodeBNode extends AlgebraicDataType1[BNode, NodeBNode] {
+ def apply(node: BNode): NodeBNode = node
+ def unapply(node: NodeBNode): Option[BNode] = if (node.isBlank) Some(node.asInstanceOf[Node_Blank]) else None
+ }
+
+ type NodeLiteral = JenaNode
+ object NodeLiteral extends AlgebraicDataType1[Literal, NodeLiteral] {
+ def apply(literal: Literal): NodeLiteral = literal
+ def unapply(node: NodeLiteral): Option[Literal] =
+ if (node.isLiteral) Some(node.asInstanceOf[Node_Literal]) else None
+ }
+
+ case class IRI(iri: String) { override def toString = '"' + iri + '"' }
+ object IRI extends AlgebraicDataType1[String, IRI]
+
+ type BNode = Node_Blank
+ object BNode extends AlgebraicDataType1[String, BNode] {
+ def apply(label: String): BNode = {
+ val id = AnonId.create(label)
+ JenaNode.createAnon(id).asInstanceOf[Node_Blank]
+ }
+ def unapply(bn: BNode): Option[String] =
+ if (bn.isBlank) Some(bn.getBlankNodeId.getLabelString) else None
+ }
+
+ lazy val mapper = TypeMapper.getInstance
+
+ type Literal = Node_Literal
+ object Literal extends AlgebraicDataType3[String, Option[LangTag], Option[IRI], Literal] {
+ def apply(lit: String, langtagOption: Option[LangTag], datatypeOption: Option[IRI]): Literal = {
+ JenaNode.createLiteral(
+ lit,
+ langtagOption map { _.s } getOrElse null,
+ datatypeOption map { i => mapper.getTypeByName(i.iri) } getOrElse null
+ ).asInstanceOf[Node_Literal]
+ }
+ def unapply(literal: Literal): Option[(String, Option[LangTag], Option[IRI])] =
+ if (literal.isLiteral)
+ Some((
+ literal.getLiteralLexicalForm.toString,
+ { val l = literal.getLiteralLanguage; if (l != "") Some(LangTag(l)) else None },
+ Option(literal.getLiteralDatatype).map{typ => IRI(typ.getURI)}))
+ else
+ None
+ }
+
+ case class LangTag(s: String)
+ object LangTag extends AlgebraicDataType1[String, LangTag]
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/aRDF/jena/src/main/scala/JenaTransformers.scala Sun Feb 05 21:37:53 2012 -0500
@@ -0,0 +1,7 @@
+package org.w3.rdf.jena
+
+import org.w3.rdf._
+
+object ScalaToJena extends Transformer[ScalaModel.type, JenaModel.type](ScalaModel, JenaModel)
+
+object JenaToScala extends Transformer[JenaModel.type, ScalaModel.type](JenaModel, ScalaModel)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/aRDF/jena/src/test/resources/card.n3 Sun Feb 05 21:37:53 2012 -0500
@@ -0,0 +1,238 @@
+# N3
+# Personal information in machine-readable form
+#
+# This (card.n3) is Tim Berners-Lee's FOAF file. It is a data file with the
+# sort of information which would be on a home page.
+# This is RDF data.
+# This is written in Notation3 - see http://www.w3.org/DesignIssues/Notation3
+# See alternatively the RDF/XML file card.rdf generated from this.
+# Use the uri <http://www.w3.org/People/Berners-Lee/card> to refer to this
+# file independent of the format.
+# Use the uri <http://www.w3.org/People/Berners-Lee/card#i> to refer to Tim BL.
+#
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix doap: <http://usefulinc.com/ns/doap#>.
+@prefix : <http://www.w3.org/2000/10/swap/pim/contact#>.
+@prefix s: <http://www.w3.org/2000/01/rdf-schema#>.
+@prefix cc: <http://creativecommons.org/ns#>.
+@prefix dc: <http://purl.org/dc/elements/1.1/>.
+@prefix dct: <http://purl.org/dc/terms/>.
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix owl: <http://www.w3.org/2002/07/owl#>.
+@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>.
+@prefix w3c: <http://www.w3.org/data#>.
+@prefix card: <http://www.w3.org/People/Berners-Lee/card#>.
+@prefix cert: <http://www.w3.org/ns/auth/cert#> .
+@prefix rsa: <http://www.w3.org/ns/auth/rsa#> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
+
+# About this document:
+# The <> (the empty URI) means "this document".
+
+ <> a foaf:PersonalProfileDocument;
+ cc:license <http://creativecommons.org/licenses/by-nc/3.0/>;
+ dc:title "Tim Berners-Lee's FOAF file";
+ foaf:maker card:i;
+ foaf:primaryTopic card:i.
+
+# Below we introduce a FOAF file I have write access to, which the tabulator
+# will let me edit.
+
+
+# Turn off this section to turn off the live editing of the FOAF file extension.
+# This is where my list of people I know is:
+
+card:i rdfs:seeAlso <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf>. # Suggest fetch it
+<http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf>
+ a foaf:PersonalProfileDocument; # Suitable place to edit
+ cc:license <http://creativecommons.org/licenses/by-nc/3.0/>;
+ dc:title "Tim Berners-Lee's editable FOAF file";
+ foaf:maker card:i;
+ foaf:primaryTopic card:i.
+
+
+
+############## Stuff about me
+
+w3c:W3C foaf:member card:i.
+<http://dig.csail.mit.edu/data#DIG> foaf:member card:i.
+
+card:i
+ s:label "Tim Berners-Lee"; # For generic user interfaces etc
+ a :Male;
+ foaf:based_near [geo:lat "42.361860"; geo:long "-71.091840"];
+
+ :office [
+ :phone <tel:+1-617-253-5702>;
+ geo:location [geo:lat "42.361860"; geo:long "-71.091840"];
+ :address [
+ :street "32 Vassar Street";
+ :street2 "MIT CSAIL Room 32-G524";
+ :city "Cambridge";
+ :postalCode "02139";
+ :country "USA"
+ ]
+ ];
+ :publicHomePage <../Berners-Lee/>;
+ :homePage <../Berners-Lee/>; # hack - follows by RDFS from line above
+ # The W3C structure data uses this as an IFP
+# is foaf:member of w3c:W3C; # SYNTAX NOT IN TURTLE :-(
+ :assistant card:amy;
+
+# Using FOAF vocabulary:
+
+ a foaf:Person;
+ # The idea is that this is the one I would suggest you use and
+ # I use for myself, which can lead to others.
+ :preferredURI "http://www.w3.org/People/Berners-Lee/card#i"; # experimental
+ foaf:mbox <mailto:timbl@w3.org>;
+ foaf:mbox_sha1sum "965c47c5a70db7407210cef6e4e6f5374a525c5c";
+ foaf:openid <http://www.w3.org/People/Berners-Lee/>;
+ foaf:img <http://www.w3.org/Press/Stock/Berners-Lee/2001-europaeum-eighth.jpg>;
+
+ foaf:family_name "Berners-Lee";
+ foaf:givenname "Timothy";
+ foaf:title "Sir".
+
+
+card:i
+ foaf:homepage <http://www.w3.org/People/Berners-Lee/>;
+ foaf:mbox <mailto:timbl@w3.org>;
+ # foaf:mbox_sha1sum "1839a1cc2e719a85ea7d9007f587b2899cd94064";
+ foaf:name "Timothy Berners-Lee";
+ foaf:nick "TimBL", "timbl";
+ foaf:phone <tel:+1-(617)-253-5702>;
+ # foaf:schoolHomepage <http://www.w3.org/People/Berners-Lee>;
+
+
+ foaf:account <http://twitter.com/timberners_lee>,
+ <http://en.wikipedia.org/wiki/User:Timbl>,
+ <http://identi.ca/timbl>;
+
+ # foaf:workInfoHomepage <http://www.w3.org/People/Berners-Lee>;
+ foaf:workplaceHomepage <http://www.w3.org/>.
+
+
+## Facebook
+
+card:i owl:sameAs <http://graph.facebook.com/512908782#>. # FB RDF feed from 2011/9
+
+
+### W3C's list of talks
+
+ card:i s:seeAlso <http://www.w3.org/2007/11/Talks/search/query?date=All+past+and+future+talks&event=None&activity=None&name=Tim+Berners-Lee&country=None&language=None&office=None&rdfOnly=yes&submit=Submit>.
+
+##### My Web ID cert
+# As of 2012-01-14:
+
+ <#i> cert:key [ a cert:RSAPublicKey;
+ cert:modulus """d7a0e91eedddcc905d5eccd1e412ab0c5bdbe118fa99b7132d915452f0b09af5ebc0096ca1dbdeec32723f5ddd2b05564e2ce67effba8e86778e114a02a3907c2e6c6b28cf16fee77d0ef0c44d2e3ccd3e0b6e8cfdd197e3aa86ec199980729af4451f7999bce55eb34bd5a5350470463700f7308e372bdb6e075e0bb8a8dba93686fa4ae51317a44382bb09d09294c1685b1097ffd59c446ae567faece6b6aa27897906b524a64989bd48cfeaec61d12cc0b63ddb885d2dadb0b358c666aa93f5a443fb91fc2a3dc699eb46159b05c5758c9f13ed2844094cc539e582e11de36c6733a67b5125ef407b329ef5e922ca5746a5ffc67b650b4ae36610fca0cd7b"""^^xsd:hexBinary ;
+ cert:exponent "65537"^^xsd:integer ] .
+
+
+
+# Pre 2012:
+#card:i is cert:identity of [
+# a rsa:RSAPublicKey;
+# rsa:public_exponent "65537"^cert:decimal ;
+# rsa:modulus
+#
+# """d7 a0 e9 1e ed dd cc 90 5d 5e cc d1 e4 12 ab 0c
+#5b db e1 18 fa 99 b7 13 2d 91 54 52 f0 b0 9a f5
+#eb c0 09 6c a1 db de ec 32 72 3f 5d dd 2b 05 56
+#4e 2c e6 7e ff ba 8e 86 77 8e 11 4a 02 a3 90 7c
+#2e 6c 6b 28 cf 16 fe e7 7d 0e f0 c4 4d 2e 3c cd
+#3e 0b 6e 8c fd d1 97 e3 aa 86 ec 19 99 80 72 9a
+#f4 45 1f 79 99 bc e5 5e b3 4b d5 a5 35 04 70 46
+#37 00 f7 30 8e 37 2b db 6e 07 5e 0b b8 a8 db a9
+#36 86 fa 4a e5 13 17 a4 43 82 bb 09 d0 92 94 c1
+#68 5b 10 97 ff d5 9c 44 6a e5 67 fa ec e6 b6 aa
+#27 89 79 06 b5 24 a6 49 89 bd 48 cf ea ec 61 d1
+#2c c0 b6 3d db 88 5d 2d ad b0 b3 58 c6 66 aa 93
+#f5 a4 43 fb 91 fc 2a 3d c6 99 eb 46 15 9b 05 c5
+#75 8c 9f 13 ed 28 44 09 4c c5 39 e5 82 e1 1d e3
+#6c 67 33 a6 7b 51 25 ef 40 7b 32 9e f5 e9 22 ca
+#57 46 a5 ff c6 7b 65 0b 4a e3 66 10 fc a0 cd 7b"""^cert:hex ;
+# ] .
+
+
+#old cert modulus:
+#"84554e39b67f5e3912068773655d855d222fa2c05cd9784693f8919aa46a61be703069c5f3266eebc21d6bb429ee47fac347b012eb7d#a8b1e4b02f7680e39767b0086f1fd48b9a420de3e70df9c2504c87006e7722ab6df210dec768dae454e65b31752379d7032dd22696465#62593d8b5c621860a0f929ad64b9dce1d6cb12f"^cert:hex ;
+
+
+
+
+
+
+##### Things I am involved in -- DOAP
+
+card:i is doap:developer of <http://www.w3.org/2000/10/swap/data#Cwm>,
+ <http://dig.csail.mit.edu/2005/ajar/ajaw/data#Tabulator>.
+
+
+# BBC Catalogue links: # Clumsy .. need to give people URIs. Now offline :-(
+# card:i foaf:homepage <http://open.bbc.co.uk/catalogue/infax/contributor/169456>;
+# s:seeAlso <http://open.bbc.co.uk/catalogue/xml/contributor/169456>.
+
+
+# Advogato is geek social netorking site (2008)
+card:i owl:sameAs <http://www.advogato.org/person/timbl/foaf.rdf#me>.
+
+##### Identi.ca identity
+card:i owl:sameAs <http://identi.ca/user/45563>.
+
+# The (2006/11) DBLP database
+card:i owl:sameAs <http://www4.wiwiss.fu-berlin.de/dblp/resource/person/100007>.
+
+# Bizer et al's RDF mashup of Amazon
+card:i owl:sameAs <http://www4.wiwiss.fu-berlin.de/bookmashup/persons/Tim+Berners-Lee>.
+
+<http://www4.wiwiss.fu-berlin.de/booksMeshup/books/006251587X> dc:title
+"Weaving the Web: The Original Design and Ultimate Destiny of the World Wide Web";
+ dc:creator card:i.
+
+# More from Chris Bizer: the dbpedia scrape of Wikipedia
+# @@@ Commented out temporaily as it was getting slow from redirecting each ontology term
+# <http://dbpedia.org/resource/Tim_Berners-Lee> owl:sameAs card:i.
+
+# MIT IAP course
+
+<http://dig.csail.mit.edu/2007/01/camp/data#course> foaf:maker card:i.
+
+# WWW2006 stuff:
+# <#i> owl:sameAs http://www.ecs.soton.ac.uk/~dt2/dlstuff/www2006_data#tim_berners-lee
+#
+
+
+
+####### 2011 WW2011
+
+<http://www.w3.org/2011/Talks/0331-hyderabad-tbl/data#talk>
+ dct:title "Designing the Web for an Open Society";
+ foaf:maker card:i.
+
+<http://www.ecs.soton.ac.uk/~dt2/dlstuff/www2006_data#panel-panelk01>
+ s:label "The Next Wave of the Web (Plenary Panel)";
+ :participant card:i.
+
+<http://wiki.ontoworld.org/index.php/_IRW2006>
+ :participant card:i.
+
+<http://wiki.ontoworld.org/index.php/_IRW2006>
+ dc:title "Identity, Reference and the Web workshop 2006".
+
+card:i foaf:weblog
+<http://dig.csail.mit.edu/breadcrumbs/blog/4> .
+<http://dig.csail.mit.edu/breadcrumbs/blog/4>
+ rdfs:seeAlso <http://dig.csail.mit.edu/breadcrumbs/blog/feed/4>; # Sigh
+ dc:title "timbl's blog";
+# is foaf:weblog of card:i;
+ foaf:maker card:i.
+
+<../../DesignIssues/Overview.html> # Has RDFA in it
+ dc:title "Design Issues for the World Wide Web";
+ foaf:maker card:i.
+
+#ends
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/aRDF/jena/src/test/resources/card.ttl Sun Feb 05 21:37:53 2012 -0500
@@ -0,0 +1,112 @@
+#Processed by Id: cwm.py,v 1.197 2007/12/13 15:38:39 syosi Exp
+ # using base file:///devel/WWW/People/Berners-Lee/card.n3
+ @prefix : <http://xmlns.com/foaf/0.1/> .
+ @prefix B: <http://www.w3.org/People/Berners-Lee/> .
+ @prefix Be: <./> .
+ @prefix blog: <http://dig.csail.mit.edu/breadcrumbs/blog/> .
+ @prefix card: <http://www.w3.org/People/Berners-Lee/card#> .
+ @prefix cc: <http://creativecommons.org/ns#> .
+ @prefix cert: <http://www.w3.org/ns/auth/cert#> .
+ @prefix con: <http://www.w3.org/2000/10/swap/pim/contact#> .
+ @prefix dc: <http://purl.org/dc/elements/1.1/> .
+ @prefix dct: <http://purl.org/dc/terms/> .
+ @prefix doap: <http://usefulinc.com/ns/doap#> .
+ @prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
+ @prefix owl: <http://www.w3.org/2002/07/owl#> .
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+ @prefix s: <http://www.w3.org/2000/01/rdf-schema#> .
+ @prefix w3c: <http://www.w3.org/data#> .
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+
+ <../../DesignIssues/Overview.html> dc:title "Design Issues for the World Wide Web";
+ :maker card:i .
+
+ <> rdf:type :PersonalProfileDocument;
+ cc:license <http://creativecommons.org/licenses/by-nc/3.0/>;
+ dc:title "Tim Berners-Lee's FOAF file";
+ :maker card:i;
+ :primaryTopic card:i .
+
+ <#i> cert:key [
+ rdf:type cert:RSAPublicKey;
+ cert:exponent 65537;
+ cert:modulus "d7a0e91eedddcc905d5eccd1e412ab0c5bdbe118fa99b7132d915452f0b09af5ebc0096ca1dbdeec32723f5ddd2b05564e2ce67effba8e86778e114a02a3907c2e6c6b28cf16fee77d0ef0c44d2e3ccd3e0b6e8cfdd197e3aa86ec199980729af4451f7999bce55eb34bd5a5350470463700f7308e372bdb6e075e0bb8a8dba93686fa4ae51317a44382bb09d09294c1685b1097ffd59c446ae567faece6b6aa27897906b524a64989bd48cfeaec61d12cc0b63ddb885d2dadb0b358c666aa93f5a443fb91fc2a3dc699eb46159b05c5758c9f13ed2844094cc539e582e11de36c6733a67b5125ef407b329ef5e922ca5746a5ffc67b650b4ae36610fca0cd7b"^^xsd:hexBinary ] .
+
+ <http://dig.csail.mit.edu/2005/ajar/ajaw/data#Tabulator> doap:developer card:i .
+
+ <http://dig.csail.mit.edu/2007/01/camp/data#course> :maker card:i .
+
+ <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf> rdf:type :PersonalProfileDocument;
+ cc:license <http://creativecommons.org/licenses/by-nc/3.0/>;
+ dc:title "Tim Berners-Lee's editable FOAF file";
+ :maker card:i;
+ :primaryTopic card:i .
+
+ blog:4 dc:title "timbl's blog";
+ s:seeAlso <http://dig.csail.mit.edu/breadcrumbs/blog/feed/4>;
+ :maker card:i .
+
+ <http://dig.csail.mit.edu/data#DIG> :member card:i .
+
+ <http://wiki.ontoworld.org/index.php/_IRW2006> dc:title "Identity, Reference and the Web workshop 2006";
+ con:participant card:i .
+
+ <http://www.ecs.soton.ac.uk/~dt2/dlstuff/www2006_data#panel-panelk01> s:label "The Next Wave of the Web (Plenary Panel)";
+ con:participant card:i .
+
+ <http://www.w3.org/2000/10/swap/data#Cwm> doap:developer card:i .
+
+ <http://www.w3.org/2011/Talks/0331-hyderabad-tbl/data#talk> dct:title "Designing the Web for an Open Society";
+ :maker card:i .
+
+ card:i rdf:type con:Male,
+ :Person;
+ s:label "Tim Berners-Lee";
+ s:seeAlso <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf>,
+ <http://www.w3.org/2007/11/Talks/search/query?date=All+past+and+future+talks&event=None&activity=None&name=Tim+Berners-Lee&country=None&language=None&office=None&rdfOnly=yes&submit=Submit>;
+ con:assistant card:amy;
+ con:homePage Be:;
+ con:office [
+ con:address [
+ con:city "Cambridge";
+ con:country "USA";
+ con:postalCode "02139";
+ con:street "32 Vassar Street";
+ con:street2 "MIT CSAIL Room 32-G524" ];
+ con:phone <tel:+1-617-253-5702>;
+ geo:location [
+ geo:lat "42.361860";
+ geo:long "-71.091840" ] ];
+ con:preferredURI "http://www.w3.org/People/Berners-Lee/card#i";
+ con:publicHomePage Be:;
+ owl:sameAs <http://graph.facebook.com/512908782#>,
+ <http://identi.ca/user/45563>,
+ <http://www.advogato.org/person/timbl/foaf.rdf#me>,
+ <http://www4.wiwiss.fu-berlin.de/bookmashup/persons/Tim+Berners-Lee>,
+ <http://www4.wiwiss.fu-berlin.de/dblp/resource/person/100007>;
+ :account <http://en.wikipedia.org/wiki/User:Timbl>,
+ <http://identi.ca/timbl>,
+ <http://twitter.com/timberners_lee>;
+ :based_near [
+ geo:lat "42.361860";
+ geo:long "-71.091840" ];
+ :family_name "Berners-Lee";
+ :givenname "Timothy";
+ :homepage B:;
+ :img <http://www.w3.org/Press/Stock/Berners-Lee/2001-europaeum-eighth.jpg>;
+ :mbox <mailto:timbl@w3.org>;
+ :mbox_sha1sum "965c47c5a70db7407210cef6e4e6f5374a525c5c";
+ :name "Timothy Berners-Lee";
+ :nick "TimBL",
+ "timbl";
+ :openid B:;
+ :phone <tel:+1-(617)-253-5702>;
+ :title "Sir";
+ :weblog blog:4;
+ :workplaceHomepage <http://www.w3.org/> .
+
+ w3c:W3C :member card:i .
+
+ <http://www4.wiwiss.fu-berlin.de/booksMeshup/books/006251587X> dc:creator card:i;
+ dc:title "Weaving the Web: The Original Design and Ultimate Destiny of the World Wide Web" .
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/aRDF/jena/src/test/scala/JenaTest.scala Sun Feb 05 21:37:53 2012 -0500
@@ -0,0 +1,34 @@
+package org.w3.rdf
+
+import org.junit.Test
+import org.junit.Assert._
+import java.io._
+import com.hp.hpl.jena._
+import com.hp.hpl.jena.rdf.model._
+import com.hp.hpl.jena.graph._
+import org.w3.rdf.jena._
+
+class JenaTest {
+
+ @Test()
+ def mytest(): Unit = {
+ val file = new File("jena/src/test/resources/card.ttl")
+ println(file.getAbsolutePath)
+ val model = ModelFactory.createDefaultModel()
+ model.getReader("TURTLE").read(model, new FileReader("jena/src/test/resources/card.ttl"), "http://www.w3.org/People/Berners-Lee/card")
+
+ val jenaGraph = JenaModel.Graph.fromJena(model.getGraph)
+// println(jenaGraph)
+
+ val scalaGraph = JenaToScala.transform(jenaGraph)
+
+ val jenaGraphAgain: JenaModel.Graph = ScalaToJena.transform(scalaGraph)
+
+// println(jenaGraphAgain)
+
+ // assertTrue(jenaGraph.jenaGraph isIsomorphicWith jenaGraphAgain.jenaGraph)
+ assertTrue(GraphIsomorphismForJenaModel.isIsomorphicWith(jenaGraph, jenaGraphAgain))
+
+ }
+
+}
\ No newline at end of file
--- a/aRDF/project/build.scala Sun Feb 05 17:46:59 2012 -0500
+++ b/aRDF/project/build.scala Sun Feb 05 21:37:53 2012 -0500
@@ -19,23 +19,54 @@
import BuildSettings._
- val mySettings = Seq(
- resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/",
- resolvers += "apache-repo-releases" at "http://repository.apache.org/content/repositories/releases/",
-// resolvers += Resolver.url("Play", url("http://download.playframework.org/ivy-releases/"))(Resolver.ivyStylePatterns),
- libraryDependencies += "org.apache.jena" % "jena-arq" % "2.9.0-incubating",
- libraryDependencies += "com.novocode" % "junit-interface" % "0.8" % "test",
-// libraryDependencies += "com.typesafe" %% "play-mini" % "2.0-RC1-SNAPSHOT",
-// mainClass in (Compile, run) := Some("play.core.server.NettyServer")
- libraryDependencies += "com.typesafe.akka" % "akka-actor" % "2.0-M3"
+ val testDeps =
+ Seq(libraryDependencies += "com.novocode" % "junit-interface" % "0.8" % "test")
+
+ val jenaDeps =
+ Seq(
+ resolvers += "apache-repo-releases" at "http://repository.apache.org/content/repositories/releases/",
+ libraryDependencies += "org.apache.jena" % "jena-arq" % "2.9.0-incubating")
+
+ lazy val pimpMyRdf = Project(
+ id = "pimp-my-rdf",
+ base = file("."),
+ settings = buildSettings,
+ aggregate = Seq(
+ algebraic,
+ rdfModel,
+ graphIsomorphism,
+ transformer,
+ jena))
+
+ lazy val algebraic = Project(
+ id = "algebraic",
+ base = file("algebraic"),
+ settings = buildSettings
)
- lazy val project = Project(
- id = "aRDF",
- base = file("."),
- settings = buildSettings ++ mySettings
- )
+ lazy val rdfModel = Project(
+ id = "rdf-model",
+ base = file("rdf-model"),
+ settings = buildSettings
+ ) dependsOn (algebraic)
+ lazy val graphIsomorphism = Project(
+ id = "graph-isomorphism",
+ base = file("graph-isomorphism"),
+ settings = buildSettings
+ ) dependsOn (rdfModel)
+
+ lazy val transformer = Project(
+ id = "transformer",
+ base = file("transformer"),
+ settings = buildSettings
+ ) dependsOn (rdfModel)
+
+ lazy val jena = Project(
+ id = "jena",
+ base = file("jena"),
+ settings = buildSettings ++ jenaDeps ++ testDeps
+ ) dependsOn (rdfModel, graphIsomorphism, transformer)
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/aRDF/rdf-model/src/main/scala/Model.scala Sun Feb 05 21:37:53 2012 -0500
@@ -0,0 +1,47 @@
+package org.w3.rdf
+
+import org.w3.algebraic._
+
+trait Model {
+
+ trait GraphInterface extends Iterable[Triple] { self =>
+ def ++(other: Graph): Graph
+ }
+ type Graph <: GraphInterface
+ type Triple
+ type Node
+ type NodeIRI <: Node
+ type NodeBNode <: Node
+ type NodeLiteral <: Node
+ type IRI
+ type BNode
+ type Literal
+ type LangTag
+
+ trait GraphCompanionObject {
+ def empty: Graph
+ def apply(elems: Triple*): Graph
+ def apply(it: Iterable[Triple]): Graph
+ }
+
+ val Graph: GraphCompanionObject
+
+ val Triple: AlgebraicDataType3[Node, IRI, Node, Triple]
+
+ val NodeIRI: AlgebraicDataType1[IRI, NodeIRI]
+ val NodeBNode: AlgebraicDataType1[BNode, NodeBNode]
+ val NodeLiteral: AlgebraicDataType1[Literal, NodeLiteral]
+
+ val IRI : AlgebraicDataType1[String, IRI]
+
+ val BNode: AlgebraicDataType1[String, BNode]
+
+ val Literal: AlgebraicDataType3[String, Option[LangTag], Option[IRI], Literal]
+
+ val LangTag: AlgebraicDataType1[String, LangTag]
+
+}
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/aRDF/rdf-model/src/main/scala/ScalaModel.scala Sun Feb 05 21:37:53 2012 -0500
@@ -0,0 +1,45 @@
+package org.w3.rdf
+
+import org.w3.algebraic._
+
+object ScalaModel extends Model {
+
+
+ case class Graph(triples: Set[Triple]) extends GraphInterface {
+ def iterator = triples.iterator
+ def ++(other: Graph): Graph = Graph(triples ++ other.triples)
+ }
+
+ object Graph extends GraphCompanionObject {
+ def empty: Graph = Graph(Set[Triple]())
+ def apply(elems: Triple*): Graph = Graph(Set[Triple](elems:_*))
+ def apply(it: Iterable[Triple]): Graph = Graph(it.toSet)
+ }
+
+ case class Triple (s: Node, p: IRI, o: Node)
+ object Triple extends AlgebraicDataType3[Node, IRI, Node, Triple]
+
+ sealed trait Node
+
+ case class NodeIRI(i: IRI) extends Node
+ object NodeIRI extends AlgebraicDataType1[IRI, NodeIRI]
+
+ case class NodeBNode(b: BNode) extends Node
+ object NodeBNode extends AlgebraicDataType1[BNode, NodeBNode]
+
+ case class NodeLiteral(lit: Literal) extends Node
+ object NodeLiteral extends AlgebraicDataType1[Literal, NodeLiteral]
+
+ case class IRI(iri: String) { override def toString = '"' + iri + '"' }
+ object IRI extends AlgebraicDataType1[String, IRI]
+
+ case class BNode(label: String)
+ object BNode extends AlgebraicDataType1[String, BNode]
+
+ case class Literal(lexicalForm: String, langtag: Option[LangTag], datatype: Option[IRI])
+ object Literal extends AlgebraicDataType3[String, Option[LangTag], Option[IRI], Literal]
+
+ case class LangTag(s: String)
+ object LangTag extends AlgebraicDataType1[String, LangTag]
+
+}
--- a/aRDF/src/main/scala/Algebraic.scala Sun Feb 05 17:46:59 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-package org.w3.algebraic
-
-trait UnApply0[R] {
- def unapply(r: R): Boolean
-}
-
-trait AlgebraicDataType0[R] extends Function0[R] with UnApply0[R]
-
-trait UnApply1[T, R] {
- def unapply(r: R): Option[T]
-}
-
-trait AlgebraicDataType1[T, R] extends Function1[T, R] with UnApply1[T, R]
-
-trait UnApply2[T1, T2, R] {
- def unapply(r: R): Option[(T1, T2)]
-}
-
-/**
- * basically, you have to implement both following functions
- * def apply(t1:T1, t2:T2):R
- * def unapply(r:R):Option[(T1, T2)]
- */
-trait AlgebraicDataType2[T1, T2, R] extends Function2[T1, T2, R] with UnApply2[T1, T2, R]
-
-trait UnApply3[T1, T2, T3, R] {
- def unapply(r: R): Option[(T1, T2, T3)]
-}
-
-trait AlgebraicDataType3[T1, T2, T3, R] extends Function3[T1, T2, T3, R] with UnApply3[T1, T2, T3, R]
-
--- a/aRDF/src/main/scala/GraphIsomorphism.scala Sun Feb 05 17:46:59 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-package org.w3.rdf
-
-abstract class GraphIsomorphism[M <: Model](val m: M) {
-
- def isIsomorphicWith(g1: m.Graph, g2: m.Graph): Boolean
-
-}
--- a/aRDF/src/main/scala/GraphIsomorphismForJenaModel.scala Sun Feb 05 17:46:59 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-package org.w3.rdf
-
-import org.w3.rdf.jena._
-
-object GraphIsomorphismForJenaModel extends GraphIsomorphism[JenaModel.type](JenaModel) {
-
- def isIsomorphicWith(g1: m.Graph, g2: m.Graph): Boolean =
- g1.jenaGraph isIsomorphicWith g2.jenaGraph
-
-
-}
\ No newline at end of file
--- a/aRDF/src/main/scala/JenaModel.scala Sun Feb 05 17:46:59 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-package org.w3.rdf.jena
-
-import org.w3.rdf._
-import com.hp.hpl.jena.graph.{Graph => JenaGraph, Triple => JenaTriple, Node => JenaNode, _}
-import com.hp.hpl.jena.rdf.model.{AnonId}
-import com.hp.hpl.jena.datatypes.{RDFDatatype, TypeMapper}
-
-import org.w3.algebraic._
-
-object JenaModel extends Model {
-
- class Graph(val jenaGraph: JenaGraph) extends GraphInterface {
- def iterator: Iterator[Triple] = new Iterator[Triple] {
- val iterator = jenaGraph.find(JenaNode.ANY, JenaNode.ANY, JenaNode.ANY)
- def hasNext = iterator.hasNext
- def next = iterator.next
- }
- def ++(other: Graph):Graph = {
- val g = Factory.createDefaultGraph
- iterator foreach { t => g add t }
- other.iterator foreach { t => g add t }
- new Graph(g)
- }
-
- }
-
- object Graph extends GraphCompanionObject {
- def fromJena(jenaGraph: JenaGraph): Graph = new Graph(jenaGraph)
- def empty: Graph = new Graph(Factory.createDefaultGraph)
- def apply(elems: Triple*): Graph = apply(elems.toIterable)
- def apply(it: Iterable[Triple]): Graph = {
- val jenaGraph = Factory.createDefaultGraph
- it foreach { t => jenaGraph add t }
- new Graph(jenaGraph)
- }
- }
-
- type Triple = JenaTriple
- object Triple extends AlgebraicDataType3[Node, IRI, Node, Triple] {
- def apply(s: Node, p: IRI, o: Node): Triple = {
- val predicate = NodeIRI(p)
- JenaTriple.create(s, predicate, o)
- }
- def unapply(t: Triple): Option[(Node, IRI, Node)] =
- (t.getSubject, t.getPredicate, t.getObject) match {
- case (Node(s), NodeIRI(p), Node(o)) => Some((s, p, o))
- case _ => None
- }
- }
-
- type Node = JenaNode
- object Node {
- def unapply(node: JenaNode): Option[Node] =
- if (node.isURI || node.isBlank || node.isLiteral) Some(node) else None
- }
-
- type NodeIRI = JenaNode
- object NodeIRI extends AlgebraicDataType1[IRI, NodeIRI] {
- def apply(iri: IRI): NodeIRI = { val IRI(s) = iri ; JenaNode.createURI(s).asInstanceOf[Node_URI] }
- def unapply(node: NodeIRI): Option[IRI] = if (node.isURI) Some(IRI(node.getURI)) else None
- }
-
- type NodeBNode = JenaNode
- object NodeBNode extends AlgebraicDataType1[BNode, NodeBNode] {
- def apply(node: BNode): NodeBNode = node
- def unapply(node: NodeBNode): Option[BNode] = if (node.isBlank) Some(node.asInstanceOf[Node_Blank]) else None
- }
-
- type NodeLiteral = JenaNode
- object NodeLiteral extends AlgebraicDataType1[Literal, NodeLiteral] {
- def apply(literal: Literal): NodeLiteral = literal
- def unapply(node: NodeLiteral): Option[Literal] =
- if (node.isLiteral) Some(node.asInstanceOf[Node_Literal]) else None
- }
-
- case class IRI(iri: String) { override def toString = '"' + iri + '"' }
- object IRI extends AlgebraicDataType1[String, IRI]
-
- type BNode = Node_Blank
- object BNode extends AlgebraicDataType1[String, BNode] {
- def apply(label: String): BNode = {
- val id = AnonId.create(label)
- JenaNode.createAnon(id).asInstanceOf[Node_Blank]
- }
- def unapply(bn: BNode): Option[String] =
- if (bn.isBlank) Some(bn.getBlankNodeId.getLabelString) else None
- }
-
-// type Subject = JenaNode
-// type SubjectNode = JenaNode
-// object SubjectNode extends AlgebraicDataType1[Node, SubjectNode] {
-// def apply(node: Node): SubjectNode = node
-// def unapply(node: SubjectNode): Option[Node] = Some(node)
-// }
-// type SubjectLiteral = JenaNode
-// object SubjectLiteral extends AlgebraicDataType1[Node, SubjectLiteral] {
-// def apply(node: Node): SubjectLiteral = node
-// def unapply(node: SubjectLiteral): Option[Node] = Some(node)
-// }
-//
-// type Predicate = JenaNode
-// type PredicateIRI = JenaNode
-// object PredicateIRI extends AlgebraicDataType1[IRI, PredicateIRI] {
-// def apply(iri: IRI): PredicateIRI = { val IRI(s) = iri ; JenaNode.createURI(s) }
-// def unapply(node: PredicateIRI): Option[IRI] = if (node.isURI) Some(IRI(node.getURI)) else None
-// }
-//
-// type Object = JenaNode
-// type ObjectNode = JenaNode
-// object ObjectNode extends AlgebraicDataType1[Node, ObjectNode] {
-// def apply(node: Node): ObjectNode = node
-// def unapply(node: ObjectNode): Option[Node] =
-// if (node.isURI || node.isBlank) Some(node) else None
-// }
-// type ObjectLiteral = JenaNode
-// object ObjectLiteral extends AlgebraicDataType1[Literal, ObjectLiteral] {
-// def apply(literal: Literal): ObjectLiteral = literal
-// def unapply(node: ObjectLiteral): Option[Literal] =
-// if (node.isLiteral) Some(node.asInstanceOf[Node_Literal]) else None
-// }
-
- lazy val mapper = TypeMapper.getInstance
-
- type Literal = Node_Literal
- object Literal extends AlgebraicDataType3[String, Option[LangTag], Option[IRI], Literal] {
- def apply(lit: String, langtagOption: Option[LangTag], datatypeOption: Option[IRI]): Literal = {
- JenaNode.createLiteral(
- lit,
- langtagOption map { _.s } getOrElse null,
- datatypeOption map { i => mapper.getTypeByName(i.iri) } getOrElse null
- ).asInstanceOf[Node_Literal]
- }
- def unapply(literal: Literal): Option[(String, Option[LangTag], Option[IRI])] =
- if (literal.isLiteral)
- Some((
- literal.getLiteralLexicalForm.toString,
- { val l = literal.getLiteralLanguage; if (l != "") Some(LangTag(l)) else None },
- Option(literal.getLiteralDatatype).map{typ => IRI(typ.getURI)}))
- else
- None
- }
-
- case class LangTag(s: String)
- object LangTag extends AlgebraicDataType1[String, LangTag]
-
-}
--- a/aRDF/src/main/scala/Model.scala Sun Feb 05 17:46:59 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-package org.w3.rdf
-
-import org.w3.algebraic._
-
-trait Model {
-
- trait GraphInterface extends Iterable[Triple] { self =>
- def ++(other: Graph): Graph
- }
- type Graph <: GraphInterface
- type Triple
- type Node
- type NodeIRI <: Node
- type NodeBNode <: Node
- type NodeLiteral <: Node
- type IRI
- type BNode
- type Literal
- type LangTag
-
- trait GraphCompanionObject {
- def empty: Graph
- def apply(elems: Triple*): Graph
- def apply(it: Iterable[Triple]): Graph
- }
-
- val Graph: GraphCompanionObject
-
- val Triple: AlgebraicDataType3[Node, IRI, Node, Triple]
-
- val NodeIRI: AlgebraicDataType1[IRI, NodeIRI]
- val NodeBNode: AlgebraicDataType1[BNode, NodeBNode]
- val NodeLiteral: AlgebraicDataType1[Literal, NodeLiteral]
-
- val IRI : AlgebraicDataType1[String, IRI]
-
- val BNode: AlgebraicDataType1[String, BNode]
-
- val Literal: AlgebraicDataType3[String, Option[LangTag], Option[IRI], Literal]
-
- val LangTag: AlgebraicDataType1[String, LangTag]
-
-}
-
-
-
-
--- a/aRDF/src/main/scala/ScalaModel.scala Sun Feb 05 17:46:59 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-package org.w3.rdf
-
-import org.w3.algebraic._
-
-object ScalaModel extends Model {
-
-
- case class Graph(triples: Set[Triple]) extends GraphInterface {
- def iterator = triples.iterator
- def ++(other: Graph): Graph = Graph(triples ++ other.triples)
- }
-
- object Graph extends GraphCompanionObject {
- def empty: Graph = Graph(Set[Triple]())
- def apply(elems: Triple*): Graph = Graph(Set[Triple](elems:_*))
- def apply(it: Iterable[Triple]): Graph = Graph(it.toSet)
- }
-
- case class Triple (s: Node, p: IRI, o: Node)
- object Triple extends AlgebraicDataType3[Node, IRI, Node, Triple]
-
- sealed trait Node
-
- case class NodeIRI(i: IRI) extends Node
- object NodeIRI extends AlgebraicDataType1[IRI, NodeIRI]
-
- case class NodeBNode(b: BNode) extends Node
- object NodeBNode extends AlgebraicDataType1[BNode, NodeBNode]
-
- case class NodeLiteral(lit: Literal) extends Node
- object NodeLiteral extends AlgebraicDataType1[Literal, NodeLiteral]
-
- case class IRI(iri: String) { override def toString = '"' + iri + '"' }
- object IRI extends AlgebraicDataType1[String, IRI]
-
- case class BNode(label: String)
- object BNode extends AlgebraicDataType1[String, BNode]
-
- case class Literal(lexicalForm: String, langtag: Option[LangTag], datatype: Option[IRI])
- object Literal extends AlgebraicDataType3[String, Option[LangTag], Option[IRI], Literal]
-
- case class LangTag(s: String)
- object LangTag extends AlgebraicDataType1[String, LangTag]
-
-}
--- a/aRDF/src/main/scala/Transformer.scala Sun Feb 05 17:46:59 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-package org.w3.rdf
-
-class Transformer[ModelA <: Model, ModelB <: Model](val a: ModelA, val b: ModelB) {
-
- def transform(graph: a.Graph): b.Graph =
- b.Graph(graph map transformTriple)
-
- def transformTriple(t: a.Triple): b.Triple = {
- val a.Triple(s, p, o) = t
- b.Triple(
- transformNode(s),
- transformIRI(p),
- transformNode(o))
- }
-
- def transformNode(n: a.Node): b.Node = n match {
- case a.NodeIRI(iri) => b.NodeIRI(transformIRI(iri))
- case a.NodeBNode(label) => b.NodeBNode(transformBNode(label))
- case a.NodeLiteral(literal) => b.NodeLiteral(transformLiteral(literal))
- }
-
- def transformIRI(iri: a.IRI): b.IRI = {
- val a.IRI(i) = iri
- b.IRI(i)
- }
-
- def transformBNode(bn: a.BNode): b.BNode = {
- val a.BNode(label) = bn
- b.BNode(label)
- }
-
- def transformLiteral(literal: a.Literal): b.Literal = {
- import a._
- val a.Literal(lit: String, langtagOption: Option[LangTag], datatypeOption: Option[IRI]) = literal
- b.Literal(
- lit,
- langtagOption map { case a.LangTag(lang) => b.LangTag(lang)},
- datatypeOption map transformIRI)
- }
-
-}
-
-import org.w3.rdf.jena.JenaModel
-
-object ScalaToJena extends Transformer[ScalaModel.type, JenaModel.type](ScalaModel, JenaModel)
-
-object JenaToScala extends Transformer[JenaModel.type, ScalaModel.type](JenaModel, ScalaModel)
--- a/aRDF/src/test/resources/card.n3 Sun Feb 05 17:46:59 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,238 +0,0 @@
-# N3
-# Personal information in machine-readable form
-#
-# This (card.n3) is Tim Berners-Lee's FOAF file. It is a data file with the
-# sort of information which would be on a home page.
-# This is RDF data.
-# This is written in Notation3 - see http://www.w3.org/DesignIssues/Notation3
-# See alternatively the RDF/XML file card.rdf generated from this.
-# Use the uri <http://www.w3.org/People/Berners-Lee/card> to refer to this
-# file independent of the format.
-# Use the uri <http://www.w3.org/People/Berners-Lee/card#i> to refer to Tim BL.
-#
-@prefix foaf: <http://xmlns.com/foaf/0.1/> .
-@prefix doap: <http://usefulinc.com/ns/doap#>.
-@prefix : <http://www.w3.org/2000/10/swap/pim/contact#>.
-@prefix s: <http://www.w3.org/2000/01/rdf-schema#>.
-@prefix cc: <http://creativecommons.org/ns#>.
-@prefix dc: <http://purl.org/dc/elements/1.1/>.
-@prefix dct: <http://purl.org/dc/terms/>.
-@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
-@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
-@prefix owl: <http://www.w3.org/2002/07/owl#>.
-@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>.
-@prefix w3c: <http://www.w3.org/data#>.
-@prefix card: <http://www.w3.org/People/Berners-Lee/card#>.
-@prefix cert: <http://www.w3.org/ns/auth/cert#> .
-@prefix rsa: <http://www.w3.org/ns/auth/rsa#> .
-@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
-
-# About this document:
-# The <> (the empty URI) means "this document".
-
- <> a foaf:PersonalProfileDocument;
- cc:license <http://creativecommons.org/licenses/by-nc/3.0/>;
- dc:title "Tim Berners-Lee's FOAF file";
- foaf:maker card:i;
- foaf:primaryTopic card:i.
-
-# Below we introduce a FOAF file I have write access to, which the tabulator
-# will let me edit.
-
-
-# Turn off this section to turn off the live editing of the FOAF file extension.
-# This is where my list of people I know is:
-
-card:i rdfs:seeAlso <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf>. # Suggest fetch it
-<http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf>
- a foaf:PersonalProfileDocument; # Suitable place to edit
- cc:license <http://creativecommons.org/licenses/by-nc/3.0/>;
- dc:title "Tim Berners-Lee's editable FOAF file";
- foaf:maker card:i;
- foaf:primaryTopic card:i.
-
-
-
-############## Stuff about me
-
-w3c:W3C foaf:member card:i.
-<http://dig.csail.mit.edu/data#DIG> foaf:member card:i.
-
-card:i
- s:label "Tim Berners-Lee"; # For generic user interfaces etc
- a :Male;
- foaf:based_near [geo:lat "42.361860"; geo:long "-71.091840"];
-
- :office [
- :phone <tel:+1-617-253-5702>;
- geo:location [geo:lat "42.361860"; geo:long "-71.091840"];
- :address [
- :street "32 Vassar Street";
- :street2 "MIT CSAIL Room 32-G524";
- :city "Cambridge";
- :postalCode "02139";
- :country "USA"
- ]
- ];
- :publicHomePage <../Berners-Lee/>;
- :homePage <../Berners-Lee/>; # hack - follows by RDFS from line above
- # The W3C structure data uses this as an IFP
-# is foaf:member of w3c:W3C; # SYNTAX NOT IN TURTLE :-(
- :assistant card:amy;
-
-# Using FOAF vocabulary:
-
- a foaf:Person;
- # The idea is that this is the one I would suggest you use and
- # I use for myself, which can lead to others.
- :preferredURI "http://www.w3.org/People/Berners-Lee/card#i"; # experimental
- foaf:mbox <mailto:timbl@w3.org>;
- foaf:mbox_sha1sum "965c47c5a70db7407210cef6e4e6f5374a525c5c";
- foaf:openid <http://www.w3.org/People/Berners-Lee/>;
- foaf:img <http://www.w3.org/Press/Stock/Berners-Lee/2001-europaeum-eighth.jpg>;
-
- foaf:family_name "Berners-Lee";
- foaf:givenname "Timothy";
- foaf:title "Sir".
-
-
-card:i
- foaf:homepage <http://www.w3.org/People/Berners-Lee/>;
- foaf:mbox <mailto:timbl@w3.org>;
- # foaf:mbox_sha1sum "1839a1cc2e719a85ea7d9007f587b2899cd94064";
- foaf:name "Timothy Berners-Lee";
- foaf:nick "TimBL", "timbl";
- foaf:phone <tel:+1-(617)-253-5702>;
- # foaf:schoolHomepage <http://www.w3.org/People/Berners-Lee>;
-
-
- foaf:account <http://twitter.com/timberners_lee>,
- <http://en.wikipedia.org/wiki/User:Timbl>,
- <http://identi.ca/timbl>;
-
- # foaf:workInfoHomepage <http://www.w3.org/People/Berners-Lee>;
- foaf:workplaceHomepage <http://www.w3.org/>.
-
-
-## Facebook
-
-card:i owl:sameAs <http://graph.facebook.com/512908782#>. # FB RDF feed from 2011/9
-
-
-### W3C's list of talks
-
- card:i s:seeAlso <http://www.w3.org/2007/11/Talks/search/query?date=All+past+and+future+talks&event=None&activity=None&name=Tim+Berners-Lee&country=None&language=None&office=None&rdfOnly=yes&submit=Submit>.
-
-##### My Web ID cert
-# As of 2012-01-14:
-
- <#i> cert:key [ a cert:RSAPublicKey;
- cert:modulus """d7a0e91eedddcc905d5eccd1e412ab0c5bdbe118fa99b7132d915452f0b09af5ebc0096ca1dbdeec32723f5ddd2b05564e2ce67effba8e86778e114a02a3907c2e6c6b28cf16fee77d0ef0c44d2e3ccd3e0b6e8cfdd197e3aa86ec199980729af4451f7999bce55eb34bd5a5350470463700f7308e372bdb6e075e0bb8a8dba93686fa4ae51317a44382bb09d09294c1685b1097ffd59c446ae567faece6b6aa27897906b524a64989bd48cfeaec61d12cc0b63ddb885d2dadb0b358c666aa93f5a443fb91fc2a3dc699eb46159b05c5758c9f13ed2844094cc539e582e11de36c6733a67b5125ef407b329ef5e922ca5746a5ffc67b650b4ae36610fca0cd7b"""^^xsd:hexBinary ;
- cert:exponent "65537"^^xsd:integer ] .
-
-
-
-# Pre 2012:
-#card:i is cert:identity of [
-# a rsa:RSAPublicKey;
-# rsa:public_exponent "65537"^cert:decimal ;
-# rsa:modulus
-#
-# """d7 a0 e9 1e ed dd cc 90 5d 5e cc d1 e4 12 ab 0c
-#5b db e1 18 fa 99 b7 13 2d 91 54 52 f0 b0 9a f5
-#eb c0 09 6c a1 db de ec 32 72 3f 5d dd 2b 05 56
-#4e 2c e6 7e ff ba 8e 86 77 8e 11 4a 02 a3 90 7c
-#2e 6c 6b 28 cf 16 fe e7 7d 0e f0 c4 4d 2e 3c cd
-#3e 0b 6e 8c fd d1 97 e3 aa 86 ec 19 99 80 72 9a
-#f4 45 1f 79 99 bc e5 5e b3 4b d5 a5 35 04 70 46
-#37 00 f7 30 8e 37 2b db 6e 07 5e 0b b8 a8 db a9
-#36 86 fa 4a e5 13 17 a4 43 82 bb 09 d0 92 94 c1
-#68 5b 10 97 ff d5 9c 44 6a e5 67 fa ec e6 b6 aa
-#27 89 79 06 b5 24 a6 49 89 bd 48 cf ea ec 61 d1
-#2c c0 b6 3d db 88 5d 2d ad b0 b3 58 c6 66 aa 93
-#f5 a4 43 fb 91 fc 2a 3d c6 99 eb 46 15 9b 05 c5
-#75 8c 9f 13 ed 28 44 09 4c c5 39 e5 82 e1 1d e3
-#6c 67 33 a6 7b 51 25 ef 40 7b 32 9e f5 e9 22 ca
-#57 46 a5 ff c6 7b 65 0b 4a e3 66 10 fc a0 cd 7b"""^cert:hex ;
-# ] .
-
-
-#old cert modulus:
-#"84554e39b67f5e3912068773655d855d222fa2c05cd9784693f8919aa46a61be703069c5f3266eebc21d6bb429ee47fac347b012eb7d#a8b1e4b02f7680e39767b0086f1fd48b9a420de3e70df9c2504c87006e7722ab6df210dec768dae454e65b31752379d7032dd22696465#62593d8b5c621860a0f929ad64b9dce1d6cb12f"^cert:hex ;
-
-
-
-
-
-
-##### Things I am involved in -- DOAP
-
-card:i is doap:developer of <http://www.w3.org/2000/10/swap/data#Cwm>,
- <http://dig.csail.mit.edu/2005/ajar/ajaw/data#Tabulator>.
-
-
-# BBC Catalogue links: # Clumsy .. need to give people URIs. Now offline :-(
-# card:i foaf:homepage <http://open.bbc.co.uk/catalogue/infax/contributor/169456>;
-# s:seeAlso <http://open.bbc.co.uk/catalogue/xml/contributor/169456>.
-
-
-# Advogato is geek social netorking site (2008)
-card:i owl:sameAs <http://www.advogato.org/person/timbl/foaf.rdf#me>.
-
-##### Identi.ca identity
-card:i owl:sameAs <http://identi.ca/user/45563>.
-
-# The (2006/11) DBLP database
-card:i owl:sameAs <http://www4.wiwiss.fu-berlin.de/dblp/resource/person/100007>.
-
-# Bizer et al's RDF mashup of Amazon
-card:i owl:sameAs <http://www4.wiwiss.fu-berlin.de/bookmashup/persons/Tim+Berners-Lee>.
-
-<http://www4.wiwiss.fu-berlin.de/booksMeshup/books/006251587X> dc:title
-"Weaving the Web: The Original Design and Ultimate Destiny of the World Wide Web";
- dc:creator card:i.
-
-# More from Chris Bizer: the dbpedia scrape of Wikipedia
-# @@@ Commented out temporaily as it was getting slow from redirecting each ontology term
-# <http://dbpedia.org/resource/Tim_Berners-Lee> owl:sameAs card:i.
-
-# MIT IAP course
-
-<http://dig.csail.mit.edu/2007/01/camp/data#course> foaf:maker card:i.
-
-# WWW2006 stuff:
-# <#i> owl:sameAs http://www.ecs.soton.ac.uk/~dt2/dlstuff/www2006_data#tim_berners-lee
-#
-
-
-
-####### 2011 WW2011
-
-<http://www.w3.org/2011/Talks/0331-hyderabad-tbl/data#talk>
- dct:title "Designing the Web for an Open Society";
- foaf:maker card:i.
-
-<http://www.ecs.soton.ac.uk/~dt2/dlstuff/www2006_data#panel-panelk01>
- s:label "The Next Wave of the Web (Plenary Panel)";
- :participant card:i.
-
-<http://wiki.ontoworld.org/index.php/_IRW2006>
- :participant card:i.
-
-<http://wiki.ontoworld.org/index.php/_IRW2006>
- dc:title "Identity, Reference and the Web workshop 2006".
-
-card:i foaf:weblog
-<http://dig.csail.mit.edu/breadcrumbs/blog/4> .
-<http://dig.csail.mit.edu/breadcrumbs/blog/4>
- rdfs:seeAlso <http://dig.csail.mit.edu/breadcrumbs/blog/feed/4>; # Sigh
- dc:title "timbl's blog";
-# is foaf:weblog of card:i;
- foaf:maker card:i.
-
-<../../DesignIssues/Overview.html> # Has RDFA in it
- dc:title "Design Issues for the World Wide Web";
- foaf:maker card:i.
-
-#ends
-
--- a/aRDF/src/test/resources/card.ttl Sun Feb 05 17:46:59 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-#Processed by Id: cwm.py,v 1.197 2007/12/13 15:38:39 syosi Exp
- # using base file:///devel/WWW/People/Berners-Lee/card.n3
- @prefix : <http://xmlns.com/foaf/0.1/> .
- @prefix B: <http://www.w3.org/People/Berners-Lee/> .
- @prefix Be: <./> .
- @prefix blog: <http://dig.csail.mit.edu/breadcrumbs/blog/> .
- @prefix card: <http://www.w3.org/People/Berners-Lee/card#> .
- @prefix cc: <http://creativecommons.org/ns#> .
- @prefix cert: <http://www.w3.org/ns/auth/cert#> .
- @prefix con: <http://www.w3.org/2000/10/swap/pim/contact#> .
- @prefix dc: <http://purl.org/dc/elements/1.1/> .
- @prefix dct: <http://purl.org/dc/terms/> .
- @prefix doap: <http://usefulinc.com/ns/doap#> .
- @prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
- @prefix owl: <http://www.w3.org/2002/07/owl#> .
- @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
- @prefix s: <http://www.w3.org/2000/01/rdf-schema#> .
- @prefix w3c: <http://www.w3.org/data#> .
- @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
-
- <../../DesignIssues/Overview.html> dc:title "Design Issues for the World Wide Web";
- :maker card:i .
-
- <> rdf:type :PersonalProfileDocument;
- cc:license <http://creativecommons.org/licenses/by-nc/3.0/>;
- dc:title "Tim Berners-Lee's FOAF file";
- :maker card:i;
- :primaryTopic card:i .
-
- <#i> cert:key [
- rdf:type cert:RSAPublicKey;
- cert:exponent 65537;
- cert:modulus "d7a0e91eedddcc905d5eccd1e412ab0c5bdbe118fa99b7132d915452f0b09af5ebc0096ca1dbdeec32723f5ddd2b05564e2ce67effba8e86778e114a02a3907c2e6c6b28cf16fee77d0ef0c44d2e3ccd3e0b6e8cfdd197e3aa86ec199980729af4451f7999bce55eb34bd5a5350470463700f7308e372bdb6e075e0bb8a8dba93686fa4ae51317a44382bb09d09294c1685b1097ffd59c446ae567faece6b6aa27897906b524a64989bd48cfeaec61d12cc0b63ddb885d2dadb0b358c666aa93f5a443fb91fc2a3dc699eb46159b05c5758c9f13ed2844094cc539e582e11de36c6733a67b5125ef407b329ef5e922ca5746a5ffc67b650b4ae36610fca0cd7b"^^xsd:hexBinary ] .
-
- <http://dig.csail.mit.edu/2005/ajar/ajaw/data#Tabulator> doap:developer card:i .
-
- <http://dig.csail.mit.edu/2007/01/camp/data#course> :maker card:i .
-
- <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf> rdf:type :PersonalProfileDocument;
- cc:license <http://creativecommons.org/licenses/by-nc/3.0/>;
- dc:title "Tim Berners-Lee's editable FOAF file";
- :maker card:i;
- :primaryTopic card:i .
-
- blog:4 dc:title "timbl's blog";
- s:seeAlso <http://dig.csail.mit.edu/breadcrumbs/blog/feed/4>;
- :maker card:i .
-
- <http://dig.csail.mit.edu/data#DIG> :member card:i .
-
- <http://wiki.ontoworld.org/index.php/_IRW2006> dc:title "Identity, Reference and the Web workshop 2006";
- con:participant card:i .
-
- <http://www.ecs.soton.ac.uk/~dt2/dlstuff/www2006_data#panel-panelk01> s:label "The Next Wave of the Web (Plenary Panel)";
- con:participant card:i .
-
- <http://www.w3.org/2000/10/swap/data#Cwm> doap:developer card:i .
-
- <http://www.w3.org/2011/Talks/0331-hyderabad-tbl/data#talk> dct:title "Designing the Web for an Open Society";
- :maker card:i .
-
- card:i rdf:type con:Male,
- :Person;
- s:label "Tim Berners-Lee";
- s:seeAlso <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf>,
- <http://www.w3.org/2007/11/Talks/search/query?date=All+past+and+future+talks&event=None&activity=None&name=Tim+Berners-Lee&country=None&language=None&office=None&rdfOnly=yes&submit=Submit>;
- con:assistant card:amy;
- con:homePage Be:;
- con:office [
- con:address [
- con:city "Cambridge";
- con:country "USA";
- con:postalCode "02139";
- con:street "32 Vassar Street";
- con:street2 "MIT CSAIL Room 32-G524" ];
- con:phone <tel:+1-617-253-5702>;
- geo:location [
- geo:lat "42.361860";
- geo:long "-71.091840" ] ];
- con:preferredURI "http://www.w3.org/People/Berners-Lee/card#i";
- con:publicHomePage Be:;
- owl:sameAs <http://graph.facebook.com/512908782#>,
- <http://identi.ca/user/45563>,
- <http://www.advogato.org/person/timbl/foaf.rdf#me>,
- <http://www4.wiwiss.fu-berlin.de/bookmashup/persons/Tim+Berners-Lee>,
- <http://www4.wiwiss.fu-berlin.de/dblp/resource/person/100007>;
- :account <http://en.wikipedia.org/wiki/User:Timbl>,
- <http://identi.ca/timbl>,
- <http://twitter.com/timberners_lee>;
- :based_near [
- geo:lat "42.361860";
- geo:long "-71.091840" ];
- :family_name "Berners-Lee";
- :givenname "Timothy";
- :homepage B:;
- :img <http://www.w3.org/Press/Stock/Berners-Lee/2001-europaeum-eighth.jpg>;
- :mbox <mailto:timbl@w3.org>;
- :mbox_sha1sum "965c47c5a70db7407210cef6e4e6f5374a525c5c";
- :name "Timothy Berners-Lee";
- :nick "TimBL",
- "timbl";
- :openid B:;
- :phone <tel:+1-(617)-253-5702>;
- :title "Sir";
- :weblog blog:4;
- :workplaceHomepage <http://www.w3.org/> .
-
- w3c:W3C :member card:i .
-
- <http://www4.wiwiss.fu-berlin.de/booksMeshup/books/006251587X> dc:creator card:i;
- dc:title "Weaving the Web: The Original Design and Ultimate Destiny of the World Wide Web" .
-
--- a/aRDF/src/test/scala/ModelSpec.scala Sun Feb 05 17:46:59 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-package org.w3.rdf
-
-import org.junit.Test
-import org.junit.Assert._
-import java.io._
-import com.hp.hpl.jena._
-import com.hp.hpl.jena.rdf.model._
-import com.hp.hpl.jena.graph._
-import org.w3.rdf.jena._
-
-class ModelSpec {
-
- @Test()
- def mytest(): Unit = {
-
- val model = ModelFactory.createDefaultModel()
- model.getReader("TURTLE").read(model, new FileReader("src/test/resources/card.ttl"), "http://www.w3.org/People/Berners-Lee/card")
-
- val jenaGraph = JenaModel.Graph.fromJena(model.getGraph)
-// println(jenaGraph)
-
- val scalaGraph = JenaToScala.transform(jenaGraph)
-
- val jenaGraphAgain: JenaModel.Graph = ScalaToJena.transform(scalaGraph)
-
-// println(jenaGraphAgain)
-
- // assertTrue(jenaGraph.jenaGraph isIsomorphicWith jenaGraphAgain.jenaGraph)
- assertTrue(GraphIsomorphismForJenaModel.isIsomorphicWith(jenaGraph, jenaGraphAgain))
-
- }
-
-}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/aRDF/transformer/src/main/scala/Transformer.scala Sun Feb 05 21:37:53 2012 -0500
@@ -0,0 +1,41 @@
+package org.w3.rdf
+
+class Transformer[ModelA <: Model, ModelB <: Model](val a: ModelA, val b: ModelB) {
+
+ def transform(graph: a.Graph): b.Graph =
+ b.Graph(graph map transformTriple)
+
+ def transformTriple(t: a.Triple): b.Triple = {
+ val a.Triple(s, p, o) = t
+ b.Triple(
+ transformNode(s),
+ transformIRI(p),
+ transformNode(o))
+ }
+
+ def transformNode(n: a.Node): b.Node = n match {
+ case a.NodeIRI(iri) => b.NodeIRI(transformIRI(iri))
+ case a.NodeBNode(label) => b.NodeBNode(transformBNode(label))
+ case a.NodeLiteral(literal) => b.NodeLiteral(transformLiteral(literal))
+ }
+
+ def transformIRI(iri: a.IRI): b.IRI = {
+ val a.IRI(i) = iri
+ b.IRI(i)
+ }
+
+ def transformBNode(bn: a.BNode): b.BNode = {
+ val a.BNode(label) = bn
+ b.BNode(label)
+ }
+
+ def transformLiteral(literal: a.Literal): b.Literal = {
+ import a._
+ val a.Literal(lit: String, langtagOption: Option[LangTag], datatypeOption: Option[IRI]) = literal
+ b.Literal(
+ lit,
+ langtagOption map { case a.LangTag(lang) => b.LangTag(lang)},
+ datatypeOption map transformIRI)
+ }
+
+}