Skip to content

Commit 4d9b519

Browse files
committed
Added term labels to output.
1 parent ce0bbcd commit 4d9b519

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ organization := "org.monarchinitiative"
44

55
name := "dosdp-scala"
66

7-
version := "0.0.2"
7+
version := "0.0.3"
88

99
scalaVersion := "2.11.8"
1010

src/main/scala/org/monarchinitiative/dosdp/SPARQL.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ ${triplesFor(dosdp).mkString("\n")}
3636
}
3737

3838
def selectFor(dosdp: DOSDP): String = {
39-
val variables = dosdp.axiomTemplates.flatMap(selectVariables)
39+
val axVariables = axiomVariables(dosdp)
40+
val variables = axVariables ++ axVariables.map(_ + "__label")
4041
if (variables.isEmpty) "*" else variables.toSeq.sorted.mkString(" ")
4142
}
4243

44+
private def axiomVariables(dosdp: DOSDP): Set[String] = dosdp.axiomTemplates.flatMap(selectVariables)
45+
4346
private val DOSDPVariable = s"^${DOSDP.variablePrefix}(.+)".r
4447

4548
def selectVariables(axiom: OWLAxiom): Set[String] =
@@ -56,7 +59,8 @@ ${triplesFor(dosdp).mkString("\n")}
5659
case (variable, named: OWLClass) => Seq(s"?${DOSDP.processedVariable(variable)} rdfs:subClassOf* <${named.getIRI}> .")
5760
case (variable, expression) => Seq(s"?${DOSDP.processedVariable(variable)} rdfs:subClassOf ${expression.asOMN} .")
5861
}
59-
axiomTriples ++ variableTriples
62+
val labelTriples = axiomVariables(dosdp).map(v => s"OPTIONAL { ?$v rdfs:label ${v}__label . }")
63+
axiomTriples ++ variableTriples ++ labelTriples
6064
}
6165

6266
def triples(axiom: OWLAxiom): Seq[String] = axiom match {
@@ -117,7 +121,7 @@ ${triplesFor(dosdp).mkString("\n")}
117121
val listLengthTriple = s"$node owl:intersectionOf/${and.getOperands.toSeq.map(_ => "rdf:rest").mkString("/")} rdf:nil ."
118122
(node, (intersectionTriples.toSeq :+ listLengthTriple) ++ operandTriplesList.toSeq.flatten ++ filters)
119123
}
120-
case or: OWLObjectUnionOf => ???
124+
case or: OWLObjectUnionOf => ???
121125
case only: OWLObjectAllValuesFrom => ???
122126
}
123127

0 commit comments

Comments
 (0)