diff --git a/qanary_commons/src/main/java/eu/wdaqua/qanary/commons/triplestoreconnectors/QanaryTripleStoreConnector.java b/qanary_commons/src/main/java/eu/wdaqua/qanary/commons/triplestoreconnectors/QanaryTripleStoreConnector.java index 64a9a19c..29cd3138 100644 --- a/qanary_commons/src/main/java/eu/wdaqua/qanary/commons/triplestoreconnectors/QanaryTripleStoreConnector.java +++ b/qanary_commons/src/main/java/eu/wdaqua/qanary/commons/triplestoreconnectors/QanaryTripleStoreConnector.java @@ -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 diff --git a/qanary_commons/src/main/resources/queries/insert_one_AnnotationOfTypedLiteral.rq b/qanary_commons/src/main/resources/queries/insert_one_AnnotationOfTypedLiteral.rq new file mode 100644 index 00000000..8649deae --- /dev/null +++ b/qanary_commons/src/main/resources/queries/insert_one_AnnotationOfTypedLiteral.rq @@ -0,0 +1,36 @@ +PREFIX dbr: +PREFIX oa: +PREFIX qa: +PREFIX rdf: +PREFIX xsd: + +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) . +}