Skip to content

Commit

Permalink
add support for AnnotationOfTypedLiteral
Browse files Browse the repository at this point in the history
  • Loading branch information
heinpa committed Jun 5, 2023
1 parent e5a170e commit 478020c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ public static String getHighestScoreAnnotationOfAnswerInGraph(URI graph) throws
return query.toString();
}

/**
* add AnnotationAnswer and AnnotationOfAnswerType to allow annotating typed literals
* as it may be required by Qanary QueryBuilder components
*
* @param bindings
* @return
* @throws IOException
*/
public static String insertAnnotationOfTypedLiteral(QuerySolutionMap bindings) throws IOException {
return readFileFromResourcesWithMap("/queries/insert_one_AnnotationOfTypedLiteral.rq", bindings);
}

/**
* add AnnotationOfAnswerSPARQL as it is done typically in Qanary QueryBuilder
* components
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX oa: <http://www.w3.org/ns/openannotation/core/>
PREFIX qa: <http://www.wdaqua.eu/qa#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

INSERT {
GRAPH ?graph {
?newAnnotation rdf:type qa:AnnotationAnswer .
?newAnnotation oa:hasTarget ?targetQuestion .
?newAnnotation oa:hasBody ?answer .
?newAnnotation qa:score ?confidence .
?newAnnotation oa:annotatedAt ?time .
?newAnnotation oa:annotatedBy ?application .

?answer rdf:type qa:Answer .
?answer rdf:value ?answerValue .

?newTypeAnnotation rdf:type qa:AnnotationOfAnswerType .
?newTypeAnnotation oa:hasTarget ?targetQuestion .
?newTypeAnnotation oa:hasBody ?annotationOfAnswerType .
?newTypeAnnotation qa:score ?confidence .
?newTypeAnnotation oa:annotatedAt ?time .
?newTypeAnnotation oa:annotatedBy ?application .

?answerType rdf:type qa:AnswerType .
?answerType rdf:value ?answerDataType .
}
}
WHERE {
BIND (IRI(str(RAND())) AS ?newAnnotation) .
BIND (IRI(str(RAND())) AS ?answer) .
BIND (IRI(str(RAND())) AS ?newTypeAnnotation) .
BIND (IRI(str(RAND())) AS ?answerType) .
BIND (now() as ?time) .
}

0 comments on commit 478020c

Please sign in to comment.