Skip to content

Commit ac5dc99

Browse files
committed
Initial commit.
This includes the build, and the core of the data model for OWL2.
1 parent d6b33d3 commit ac5dc99

File tree

6 files changed

+192
-0
lines changed

6 files changed

+192
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
target/
2+
*.iml
3+
.idea/
4+
.history
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package uk.co.turingatemyhamster.owl2
2+
3+
/**
4+
* An abstraction of http://www.w3.org/TR/2012/REC-owl2-syntax-20121211/#IRIs
5+
*
6+
* @author Matthew Pocock
7+
*/
8+
trait Iri {
9+
10+
/** An IRI as defined in [http://www.w3.org/TR/2012/REC-owl2-syntax-20121211/#ref-rfc-3987 | RFC3987], enclosed in a
11+
* pair of < (U+3C) and > (U+3E) characters.
12+
*/
13+
type fullIRI
14+
15+
/** A finite sequence of characters matching the as PNAME_NS production of
16+
* [http://www.w3.org/TR/2012/REC-owl2-syntax-20121211/#ref-sparql | SPARQL].
17+
*/
18+
type prefixName
19+
20+
/** A finite sequence of characters matching the PNAME_LN production of
21+
* [http://www.w3.org/TR/2012/REC-owl2-syntax-20121211/#ref-sparql | SPARQL].
22+
*/
23+
type abbreviatedIRI
24+
25+
/** A full or abbreviated IRI.
26+
*/
27+
type IRI
28+
29+
/** A fullIRI is an IRI. */
30+
implicit def fullIRI_isa_IRI: fullIRI <:< IRI
31+
32+
/** An abbreviatedIRI is an IRI. */
33+
implicit def abbreviatedIRI_isa_IRI: abbreviatedIRI <:< IRI
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package uk.co.turingatemyhamster.owl2
2+
3+
/**
4+
* An abstraction of: http://www.w3.org/TR/2012/REC-owl2-syntax-20121211/#Ontologies
5+
*
6+
* @author Matthew Pocock
7+
*/
8+
trait Ontologys {
9+
10+
importedPackages : Iri =>
11+
12+
type Ontology
13+
14+
def Ontology : OntologyApi
15+
16+
trait OntologyApi {
17+
def apply(directlyImportsDocuments: List[IRI],
18+
ontologyIRI: Option[IRI],
19+
versionIRI: Option[IRI],
20+
ontologyAnnotation: List[Annotation],
21+
axioms: List[Axiom]): Ontology
22+
def unapply(o: Ontology): Option[(List[IRI], Option[IRI], Option[IRI], List[Annotation], List[Axiom])]
23+
}
24+
25+
type Annotation
26+
27+
def Annotation : AnnotationApi
28+
29+
trait AnnotationApi {
30+
def unapply(annotation: Annotation): Some[List[Annotation]]
31+
}
32+
33+
type Axiom
34+
35+
def Axiom : AxiomApi
36+
37+
trait AxiomApi {
38+
def unapply(axiom: Axiom): Some[List[Annotation]]
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package uk.co.turingatemyhamster
2+
package owl2
3+
package ast
4+
5+
6+
sealed trait IRI
7+
8+
/** A full IRI string, without the wrapping < (U+3C) and > (U+3E) characters. */
9+
case class FullIRI(iriString: String) extends IRI
10+
11+
/** A prefix string, matching the as PNAME_NS production of SPARQL. */
12+
case class PrefixName(prefixString: String)
13+
14+
/** An abbreviated IRI, matching the PNAME_LN production of SPARQL. */
15+
case class AbbreviatedIRI(abbreviatedString: String) extends IRI
16+
17+
trait IriImpl extends owl2.Iri {
18+
19+
override final type fullIRI = ast.FullIRI
20+
override final type prefixName = ast.PrefixName
21+
override final type abbreviatedIRI = ast.AbbreviatedIRI
22+
override final type IRI = ast.IRI
23+
24+
override final implicit def fullIRI_isa_IRI: fullIRI <:< IRI = $conforms[fullIRI]
25+
26+
override final implicit def abbreviatedIRI_isa_IRI: abbreviatedIRI <:< IRI = $conforms[abbreviatedIRI]
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package uk.co.turingatemyhamster
2+
package owl2
3+
package ast
4+
5+
/**
6+
*
7+
*
8+
* @author Matthew Pocock
9+
*/
10+
trait OntologysImpl extends owl2.Ontologys {
11+
12+
importedPackages : owl2.Iri =>
13+
14+
override type Ontology = ast.Ontology[IRI, Annotation, Axiom]
15+
16+
override final val Ontology: OntologyApi = new OntologyApi {
17+
override def apply(directlyImports: List[IRI],
18+
ontologyIRI: Option[IRI],
19+
versionIRI: Option[IRI],
20+
ontologyAnnotation: List[Annotation],
21+
axioms: List[Axiom]) = ast.Ontology(directlyImports, ontologyIRI, versionIRI, ontologyAnnotation, axioms)
22+
23+
override def unapply(o: Ontology) = ast.Ontology.unapply(o)
24+
}
25+
26+
override final type Annotation = ast.Annotation
27+
28+
override final val Annotation: AnnotationApi = new AnnotationApi {
29+
override def unapply(annotation: Annotation) = Some(annotation.annotationAnnotations)
30+
}
31+
32+
override final type Axiom = ast.Axiom
33+
34+
override final val Axiom: AxiomApi = new AxiomApi {
35+
override def unapply(axiom: Axiom) = Some(axiom.axiomAnnotations)
36+
}
37+
}
38+
39+
// constraint: versionIRI.isDefined ==> ontologyIRI.isDefined
40+
// Could encode as:
41+
// case class OntologyURI(uriValue: IRI, versionIRI: Option[IRI])
42+
case class Ontology[IRI, Annotation, Axiom](directlyImportsDocuments: List[IRI],
43+
ontologyIRI: Option[IRI],
44+
versionIRI: Option[IRI],
45+
ontologyAnnotations: List[Annotation],
46+
axioms: List[Axiom])
47+
48+
trait Annotation {
49+
def annotationAnnotations: List[Annotation]
50+
}
51+
52+
trait Axiom {
53+
def axiomAnnotations: List[Annotation]
54+
}

project/Build.scala

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import sbt._
2+
import sbt.Keys._
3+
4+
5+
object Owl2Build extends Build {
6+
7+
val logger = ConsoleLogger()
8+
9+
val baseVersion = "0.1.0"
10+
11+
lazy val core = project.settings(
12+
organization := "uk.co.turingatemyhamster",
13+
scalaVersion := "2.11.4",
14+
crossScalaVersions := Seq("2.11.4", "2.10.4"),
15+
scalacOptions ++= Seq("-deprecation", "-unchecked"),
16+
version := baseVersion,
17+
resolvers += Resolver.url(
18+
"bintray-scalajs-releases",
19+
url("http://dl.bintray.com/scala-js/scala-js-releases/"))(
20+
Resolver.ivyStylePatterns),
21+
resolvers += "bintray/non" at "http://dl.bintray.com/non/maven",
22+
resolvers ++= Seq("snapshots", "releases").map(Resolver.sonatypeRepo),
23+
resolvers += "spray repo" at "http://repo.spray.io",
24+
resolvers += "Scalaz Bintray Repo" at "http://dl.bintray.com/scalaz/releases",
25+
resolvers += "drdozer Bintray Repo" at "http://dl.bintray.com/content/drdozer/maven",
26+
publishMavenStyle := true,
27+
//repository in bintray := "maven",
28+
//bintrayOrganization in bintray := None,
29+
licenses +=("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html"))
30+
)
31+
32+
}
33+

0 commit comments

Comments
 (0)