Skip to content

Commit

Permalink
Merge pull request #1 from weso/master
Browse files Browse the repository at this point in the history
Update from weso/srdf master
  • Loading branch information
ralphtq authored Aug 19, 2022
2 parents d0c6eb5 + 724a55d commit 20a8a63
Show file tree
Hide file tree
Showing 12 changed files with 377 additions and 247 deletions.
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lazy val scala212 = "2.12.15"
lazy val scala212 = "2.12.16"
lazy val scala213 = "2.13.8"
lazy val scala3 = "3.1.3"

Expand All @@ -11,11 +11,11 @@ lazy val supportedScalaVersions = List(
val Java11 = JavaSpec.temurin("11") // "[email protected]"
// val Java8 = JavaSpec.temurin("8") // "[email protected]"

lazy val utilsVersion = "0.2.24"
lazy val utilsVersion = "0.2.25"

// Dependency versions
lazy val catsVersion = "2.7.0"
lazy val catsEffectVersion = "3.3.12"
lazy val catsVersion = "2.8.0"
lazy val catsEffectVersion = "3.3.14"
lazy val circeVersion = "0.14.2"
lazy val declineVersion = "2.2.0"
lazy val fs2Version = "3.2.7"
Expand Down
29 changes: 29 additions & 0 deletions modules/srdf/src/main/scala/es/weso/rdf/nodes/RDFHTMLLiteral.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package es.weso.rdf.nodes
import cats.implicits._

case class RDFHTMLLiteral(lexicalForm: String) extends Literal {
val rdfSyntax = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
val RDFHTMLDatatypeIRI: IRI = IRI(rdfSyntax + "HTML")

override val dataType: IRI = RDFHTMLDatatypeIRI

override def isLangLiteral = false
override def hasLang(lang: Lang) = false

override def toString: String = {
"\"" + lexicalForm + "\"^^rdf:HTML"
}

override def getLexicalForm = lexicalForm

override def isEqualTo(other: RDFNode): Either[String, Boolean] = other match {
case RDFHTMLLiteral(lf) => (lf == lexicalForm).asRight
case _ => false.asRight
}

def lessThan(other: RDFNode): Either[String, Boolean] = other match {
case RDFHTMLLiteral(lf) => (lexicalForm < lf).asRight
case _ =>
s"Cannot compare RDF HTML literal $this < $other which is not an RDF HTML literal".asLeft
}
}
2 changes: 2 additions & 0 deletions modules/srdf/src/main/scala/es/weso/rdf/nodes/RDFNode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ object RDFNode {
val xsd = "http://www.w3.org/2001/XMLSchema#"
val rdfSyntax = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
val StringDatatypeIRI = IRI(xsd + "string")
val RDFHTMLDatatypeIRI = IRI(rdfSyntax + "HTML") // RH20220819
val RDFXMLDatatypeIRI = IRI(rdfSyntax + "XML") // RH20220819
val LangStringDatatypeIRI = IRI(rdfSyntax + "langString")
val BooleanDatatypeIRI = IRI(xsd + "boolean")
val IntegerDatatypeIRI = IRI(xsd + "integer")
Expand Down
29 changes: 29 additions & 0 deletions modules/srdf/src/main/scala/es/weso/rdf/nodes/RDFXMLLiteral.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package es.weso.rdf.nodes
import cats.implicits._

case class RDFXMLLiteral(lexicalForm: String) extends Literal {
val rdfSyntax = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
val RDFXMLDatatypeIRI: IRI = IRI(rdfSyntax + "XMLLiteral")

override val dataType: IRI = RDFXMLDatatypeIRI

override def isLangLiteral = false
override def hasLang(lang: Lang) = false

override def toString: String = {
"\"" + lexicalForm + "\"^^rdf:XMLLiteral"
}

override def getLexicalForm = lexicalForm

override def isEqualTo(other: RDFNode): Either[String, Boolean] = other match {
case RDFXMLLiteral(lf) => (lf == lexicalForm).asRight
case _ => false.asRight
}

def lessThan(other: RDFNode): Either[String, Boolean] = other match {
case RDFXMLLiteral(lf) => (lexicalForm < lf).asRight
case _ =>
s"Cannot compare RDF HTML literal $this < $other which is not an RDF HTML literal".asLeft
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ trait RDFParser {

def checkString(obj: RDFNode, p:IRI): RDFParser[String] = obj match {
case StringLiteral(str) => parseOk(str)
case RDFHTMLLiteral(str) => parseOk(str) // RH20220819
case RDFXMLLiteral(str) => parseOk(str) // RH20220819
case _ => parseFail("Value of predicate " + p + " must be a string literal but it is: " + obj)
}

Expand Down Expand Up @@ -553,6 +555,8 @@ trait RDFParser {
} yield v

def checkString(n: RDFNode): RDFParser[String] = n match {
case s: RDFHTMLLiteral => parseOk(s.getLexicalForm) // RH20220819
case s: RDFXMLLiteral => parseOk(s.getLexicalForm) // RH20220819
case s: StringLiteral => parseOk(s.getLexicalForm)
case _ => parseFail(s"Expected string literal for node $n")
}
Expand Down
Loading

0 comments on commit 20a8a63

Please sign in to comment.