--- a/rdf/src/main/scala/RDF.scala Fri Jan 07 12:48:27 2011 -0500
+++ b/rdf/src/main/scala/RDF.scala Fri Jan 07 12:50:06 2011 -0500
@@ -2,10 +2,10 @@
trait RDFModel {
- import org.w3.algebraic._
+ import org.w3.isomorphic._
type IRI
- val IRI : Algebraic1[String, IRI]
+ val IRI : Isomorphic1[String, IRI]
// it should actually be an Ordered Set
type Graph <: Traversable[Triple]
@@ -16,41 +16,41 @@
}
type Triple
- val Triple : Algebraic3[Subject, Predicate, Object, Triple]
+ val Triple : Isomorphic3[Subject, Predicate, Object, Triple]
type BNode
- val BNode : Algebraic1[String, BNode]
+ val BNode : Isomorphic1[String, BNode]
// sealed type Node: NodeIRI NodeBNode
type Node
type NodeIRI <: Node
type NodeBNode <: Node
- val NodeIRI : Algebraic1[IRI, NodeIRI]
- val NodeBNode : Algebraic1[BNode, NodeBNode]
+ val NodeIRI : Isomorphic1[IRI, NodeIRI]
+ val NodeBNode : Isomorphic1[BNode, NodeBNode]
type Subject
type SubjectNode <: Subject
- val SubjectNode : Algebraic1[Node, SubjectNode]
+ val SubjectNode : Isomorphic1[Node, SubjectNode]
type Predicate
type PredicateIRI <: Predicate
- val PredicateIRI : Algebraic1[IRI, PredicateIRI]
+ val PredicateIRI : Isomorphic1[IRI, PredicateIRI]
type Object
type ObjectNode <: Object
type ObjectLiteral <: Object
- val ObjectNode : Algebraic1[Node, ObjectNode]
- val ObjectLiteral : Algebraic1[Literal, ObjectLiteral]
+ val ObjectNode : Isomorphic1[Node, ObjectNode]
+ val ObjectLiteral : Isomorphic1[Literal, ObjectLiteral]
// val lexicalForm:String
type Literal
type PlainLiteral <: Literal
type TypedLiteral <: Literal
- val PlainLiteral : Algebraic2[String, Option[LangTag], PlainLiteral]
- val TypedLiteral : Algebraic2[String, IRI, TypedLiteral]
+ val PlainLiteral : Isomorphic2[String, Option[LangTag], PlainLiteral]
+ val TypedLiteral : Isomorphic2[String, IRI, TypedLiteral]
type LangTag
- val LangTag : Algebraic1[String, LangTag]
+ val LangTag : Isomorphic1[String, LangTag]
val StringDatatype = IRI("http://www.w3.org/2001/XMLSchema#string")
val IntegerDatatype = IRI("http://www.w3.org/2001/XMLSchema#integer")
@@ -76,10 +76,10 @@
trait RDF extends RDFModel {
- import org.w3.algebraic._
+ import org.w3.isomorphic._
case class IRI(iri:String) { override def toString = '"' + iri + '"' }
- object IRI extends Algebraic1[String, IRI]
+ object IRI extends Isomorphic1[String, IRI]
type Graph = Set[Triple]
val Graph = new Object {
@@ -89,112 +89,112 @@
}
case class Triple (s:Subject, p:Predicate, o:Object)
- object Triple extends Algebraic3[Subject, Predicate, Object, Triple]
+ object Triple extends Isomorphic3[Subject, Predicate, Object, Triple]
case class BNode(label:String)
- object BNode extends Algebraic1[String, BNode]
+ object BNode extends Isomorphic1[String, BNode]
sealed trait Node
case class NodeIRI(i:IRI) extends Node
- object NodeIRI extends Algebraic1[IRI, NodeIRI]
+ object NodeIRI extends Isomorphic1[IRI, NodeIRI]
case class NodeBNode(b:BNode) extends Node
- object NodeBNode extends Algebraic1[BNode, NodeBNode]
+ object NodeBNode extends Isomorphic1[BNode, NodeBNode]
sealed trait Subject
case class SubjectNode(n:Node) extends Subject
- object SubjectNode extends Algebraic1[Node, SubjectNode]
+ object SubjectNode extends Isomorphic1[Node, SubjectNode]
sealed trait Predicate
case class PredicateIRI(i:IRI) extends Predicate
- object PredicateIRI extends Algebraic1[IRI, PredicateIRI]
+ object PredicateIRI extends Isomorphic1[IRI, PredicateIRI]
sealed trait Object
case class ObjectNode(n:Node) extends Object
- object ObjectNode extends Algebraic1[Node, ObjectNode]
+ object ObjectNode extends Isomorphic1[Node, ObjectNode]
case class ObjectLiteral (n:Literal) extends Object
- object ObjectLiteral extends Algebraic1[Literal, ObjectLiteral]
+ object ObjectLiteral extends Isomorphic1[Literal, ObjectLiteral]
sealed abstract class Literal(val lexicalForm:String)
case class PlainLiteral(override val lexicalForm:String, langtag:Option[LangTag]) extends Literal(lexicalForm) {
override def toString = "\"" + lexicalForm + "\"" + { if (langtag.isDefined) langtag.get }
}
- object PlainLiteral extends Algebraic2[String, Option[LangTag], PlainLiteral]
+ object PlainLiteral extends Isomorphic2[String, Option[LangTag], PlainLiteral]
case class TypedLiteral(override val lexicalForm:String, datatype:IRI) extends Literal(lexicalForm) {
override def toString = "\"" + lexicalForm + "\"^^" + datatype
}
- object TypedLiteral extends Algebraic2[String, IRI, TypedLiteral]
+ object TypedLiteral extends Isomorphic2[String, IRI, TypedLiteral]
case class LangTag(s:String)
- object LangTag extends Algebraic1[String, LangTag]
+ object LangTag extends Isomorphic1[String, LangTag]
}
-
-
-object rdf {
-
- case class Graph(triples:Set[Triple])
- object Graph {
- 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:Subject, p:Predicate, o:Object)
-
-sealed abstract class Node // factor out IRIs and BNodes
-case class NodeIRI(i:IRI) extends Node
-implicit def iri2nodeiri(i:IRI):Node = NodeIRI(i)
-case class NodeBNode(b:BNode) extends Node
-implicit def bnode2nodebnode(b:BNode):Node = NodeBNode(b)
-
-sealed abstract class Subject
-case class SubjectNode(n:Node) extends Subject
-implicit def node2subjectnode(n:Node):Subject = SubjectNode(n)
-implicit def iri2subjectnode(i:IRI):Subject = SubjectNode(i)
-implicit def bnode2subjectnode(b:BNode):Subject = SubjectNode(b)
-
-sealed abstract class Predicate
-case class PredicateIRI(i:IRI) extends Predicate
-implicit def iri2predicateiri(i:IRI):Predicate = PredicateIRI(i)
+object RDF extends RDF
-sealed abstract class Object
-case class ObjectNode(n:Node) extends Object
-implicit def node2objectnode(n:Node):Object = ObjectNode(n)
-implicit def iri2objectnode(i:IRI):Object = ObjectNode(i)
-implicit def bnode2objectnode(b:BNode):Object = ObjectNode(b)
-case class ObjectLiteral (n:Literal) extends Object
-
-case class IRI(iri:String) {
- override def toString = '"' + iri + '"'
-}
-case class BNode(label:String)
-
- sealed abstract class Literal(val lexicalForm:String)
-
- case class PlainLiteral(override val lexicalForm:String, langtag:Option[LangTag]) extends Literal(lexicalForm) {
- override def toString = "\"" + lexicalForm + "\"" + { if (langtag.isDefined) langtag.get }
- }
- implicit def typed2object(i:TypedLiteral):Object = ObjectLiteral(i)
+// object rdf {
- case class TypedLiteral(override val lexicalForm:String, datatype:IRI) extends Literal(lexicalForm) {
- override def toString = "\"" + lexicalForm + "\"^^" + datatype
- }
- implicit def plain2object(b:PlainLiteral):Object = ObjectLiteral(b)
-
- case class LangTag(s:String)
+// case class Graph(triples:Set[Triple])
+// object Graph {
+// def empty:Graph = Graph(Set[Triple]())
+// def apply(elems:Triple*):Graph = Graph(Set[Triple](elems:_*))
+// def apply(it:Iterable[Triple]):Graph = Graph(it.toSet)
+// }
-val StringDatatype = IRI("http://www.w3.org/2001/XMLSchema#string")
-val IntegerDatatype = IRI("http://www.w3.org/2001/XMLSchema#integer")
-val DateDatatype = IRI("http://www.w3.org/2001/XMLSchema#date")
-val DateTimeDatatype = IRI("http://www.w3.org/2001/XMLSchema#dateTime")
+// case class Triple (s:Subject, p:Predicate, o:Object)
-}
+// sealed abstract class Node // factor out IRIs and BNodes
+// case class NodeIRI(i:IRI) extends Node
+// implicit def iri2nodeiri(i:IRI):Node = NodeIRI(i)
+// case class NodeBNode(b:BNode) extends Node
+// implicit def bnode2nodebnode(b:BNode):Node = NodeBNode(b)
-// object Literal {
-// val StringDatatype = Datatype(IRI("http://www.w3.org/2001/XMLSchema#string"))
-// val IntegerDatatype = Datatype(IRI("http://www.w3.org/2001/XMLSchema#integer"))
-// val DateDatatype = Datatype(IRI("http://www.w3.org/2001/XMLSchema#date"))
-// // val DateTimeDatatype = Datatype(IRI("http://www.w3.org/2001/XMLSchema#dateTime"))
+// sealed abstract class Subject
+// case class SubjectNode(n:Node) extends Subject
+// implicit def node2subjectnode(n:Node):Subject = SubjectNode(n)
+// implicit def iri2subjectnode(i:IRI):Subject = SubjectNode(i)
+// implicit def bnode2subjectnode(b:BNode):Subject = SubjectNode(b)
+
+// sealed abstract class Predicate
+// case class PredicateIRI(i:IRI) extends Predicate
+// implicit def iri2predicateiri(i:IRI):Predicate = PredicateIRI(i)
+
+// sealed abstract class Object
+// case class ObjectNode(n:Node) extends Object
+// implicit def node2objectnode(n:Node):Object = ObjectNode(n)
+// implicit def iri2objectnode(i:IRI):Object = ObjectNode(i)
+// implicit def bnode2objectnode(b:BNode):Object = ObjectNode(b)
+// case class ObjectLiteral (n:Literal) extends Object
+
+// case class IRI(iri:String) {
+// override def toString = '"' + iri + '"'
+// }
+// case class BNode(label:String)
+
+// sealed abstract class Literal(val lexicalForm:String)
+
+// case class PlainLiteral(override val lexicalForm:String, langtag:Option[LangTag]) extends Literal(lexicalForm) {
+// override def toString = "\"" + lexicalForm + "\"" + { if (langtag.isDefined) langtag.get }
+// }
+// implicit def typed2object(i:TypedLiteral):Object = ObjectLiteral(i)
+
+// case class TypedLiteral(override val lexicalForm:String, datatype:IRI) extends Literal(lexicalForm) {
+// override def toString = "\"" + lexicalForm + "\"^^" + datatype
+// }
+// implicit def plain2object(b:PlainLiteral):Object = ObjectLiteral(b)
+
+// case class LangTag(s:String)
+
+// val StringDatatype = IRI("http://www.w3.org/2001/XMLSchema#string")
+// val IntegerDatatype = IRI("http://www.w3.org/2001/XMLSchema#integer")
+// val DateDatatype = IRI("http://www.w3.org/2001/XMLSchema#date")
+// val DateTimeDatatype = IRI("http://www.w3.org/2001/XMLSchema#dateTime")
+
// }
+// // object Literal {
+// // val StringDatatype = Datatype(IRI("http://www.w3.org/2001/XMLSchema#string"))
+// // val IntegerDatatype = Datatype(IRI("http://www.w3.org/2001/XMLSchema#integer"))
+// // val DateDatatype = Datatype(IRI("http://www.w3.org/2001/XMLSchema#date"))
+// // // val DateTimeDatatype = Datatype(IRI("http://www.w3.org/2001/XMLSchema#dateTime"))
+// // }
+
--- a/turtle/src/main/scala/turtle.scala Fri Jan 07 12:48:27 2011 -0500
+++ b/turtle/src/main/scala/turtle.scala Fri Jan 07 12:50:06 2011 -0500
@@ -1,7 +1,7 @@
package org.w3.sw.turtle
import org.w3.sw.RDFModel
-//import org.w3.sw.{rdf => RDFModel}
+//import org.w3.sw.{RDF => RDFModel}
import scala.util.parsing.combinator._
import java.net.URI
@@ -16,7 +16,6 @@
import MyParsers._
case class Turtle(RDFModel:RDFModel) extends JavaTokenParsers {
-//case class Turtle() extends JavaTokenParsers {
import RDFModel._
@@ -79,10 +78,10 @@
stringLiteral~"^^"~qnameORuri ^^
{
case lit~"^^"~dt => TypedLiteral(lit.substring(1,lit.size - 1), dt match {
- case IRI("http://www.w3.org/2001/XMLSchema#string") => StringDatatype
+ case IRI("http://www.w3.org/2001/XMLSchema#string") => StringDatatype
case IRI("http://www.w3.org/2001/XMLSchema#integer") => IntegerDatatype
- case IRI("http://www.w3.org/2001/XMLSchema#date" ) => DateDatatype
- case "http://www.w3.org/2001/XMLSchema#dateTime" => DateTimeDatatype
+ case IRI("http://www.w3.org/2001/XMLSchema#date") => DateDatatype
+ case IRI("http://www.w3.org/2001/XMLSchema#dateTime") => DateTimeDatatype
case x => error("only programed to deal with string and integer, not " + x)
})
}