Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for AnnotationOfTypedLiteral #161

Merged
merged 1 commit into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) .
}