Skip to content

Commit

Permalink
Merge pull request #19 from WSE-research/356-update-select-queries
Browse files Browse the repository at this point in the history
356 update select queries
  • Loading branch information
dschiese authored Oct 14, 2023
2 parents 09a346f + 12b65a7 commit c9ac18a
Show file tree
Hide file tree
Showing 36 changed files with 67 additions and 192 deletions.
20 changes: 13 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,28 @@ FROM ubuntu:20.04 AS qanary_commons
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y maven wget #git #openjdk-17-jre
RUN apt-get install -y git

WORKDIR /app
RUN wget https://github.com/WDAqua/Qanary/archive/refs/tags/v3.5.2.tar.gz
RUN tar -xzvf v3.5.2.tar.gz
WORKDIR /app/Qanary-3.5.2/qanary_commons
RUN git clone https://github.com/WDAqua/Qanary.git

WORKDIR /app/Qanary/qanary_commons
RUN mvn clean install -DskipTests
WORKDIR /app
RUN cp Qanary-3.5.2/qanary_commons/target/qa.commons-3.5.4.jar .
COPY dockerfile_scripts/extract_commons_version.sh /app/extract_commons_version.sh
RUN chmod +x /app/extract_commons_version.sh
RUN /app/extract_commons_version.sh

#Build Stage
FROM maven:latest AS build
WORKDIR /app
COPY ./src ./src
COPY ./pom.xml ./pom.xml
COPY --from=qanary_commons /app/qa.commons-3.5.4.jar .
COPY --from=qanary_commons /app/qa.commons.jar .
COPY --from=qanary_commons /app/jar_version .
# Installing the qa_commons dependency
RUN mvn install:install-file -Dfile=qa.commons-3.5.4.jar -DgroupId=eu.wdaqua.qanary -DartifactId=qa.commons -Dversion=3.5.4 -Dpackaging=jar
COPY dockerfile_scripts/install_commons_dependency.sh /app/install_commons_dependency.sh
RUN chmod +x /app/install_commons_dependency.sh
RUN /app/install_commons_dependency.sh
# build the app
RUN mvn clean install

Expand Down
9 changes: 9 additions & 0 deletions dockerfile_scripts/extract_commons_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cd target && ls
#JAR_FILE=$(find . -maxdepth 1 -type f -name "qa.commons-[0-9].[0-9].[0-9].jar")
#JAR_VERSION=$(echo $JAR_FILE | grep -oP 'qa.commons-\K\d+\.\d+\.\d+')
JAR_FILE=$(find . -maxdepth 1 -type f -name "qa.commons-[0-9].[0-9].[0-9].jar")
JAR_VERSION=$(echo $JAR_FILE | grep -oP 'qa.commons-\K\d+\.\d+\.\d+')
mv qa.commons-$JAR_VERSION.jar qa.commons.jar # Rename commons jar
cp qa.commons.jar /app
cd /app
echo $JAR_VERSION > jar_version # Create file involving jar-file
4 changes: 4 additions & 0 deletions dockerfile_scripts/install_commons_dependency.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
JAR_VERSION=$(cat jar_version | xargs)

# Install commons-dependency
mvn install:install-file -Dfile=qa.commons.jar -DgroupId=eu.wdaqua.qanary -DartifactId=qa.commons -Dversion=$JAR_VERSION -Dpackaging=jar
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.wse</groupId>
<artifactId>qanary-explanation-service</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<name>Qanary explanation service</name>
<description>Webservice for rule-based explanation of QA-Systems as well as specific components</description>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ public class ExplanationService {
// Holds request query for declared annotations types
private static final Map<String, String> annotationsTypeAndQuery = new HashMap<>() {{
// AnnotationOfInstance
put("annotationofspotinstance", "/queries/queries_for_annotation_types/annotations_of_spot_intance_query.rq");
put("annotationofinstance", "/queries/queries_for_annotation_types/annotations_of_instance_query.rq");
put("annotationofanswersparql", "/queries/queries_for_annotation_types/annotations_of_answer_sparql.rq");
put("annotationofrelation", "/queries/queries_for_annotation_types/annotations_of_relation_query.rq");
put("annotationofanswerjson", "/queries/queries_for_annotation_types/annotations_of_answer_json_query.rq");
put("annotationofquestiontranslation", "/queries/queries_for_annotation_types/annotations_of_question_translation_query.rq");
put("annotationofquestionlanguage", "/queries/queries_for_annotation_types/annotations_of_question_language_query.rq");
put("annotationofspotinstance", "/queries/select_all_AnnotationOfSpotInstance.rq");
put("annotationofinstance", "/queries/select_all_AnnotationOfInstance.rq");
put("annotationofanswersparql", "/queries/select_all_AnnotationOfAnswerSPARQL.rq");
put("annotationofrelation", "/queries/select_all_AnnotationOfRelation.rq");
put("annotationofanswerjson", "/queries/select_all_AnnotationOfAnswerJson.rq");
put("annotationofquestiontranslation", "/queries/select_all_AnnotationOfQuestionTranslation.rq");
put("annotationofquestionlanguage", "/queries/select_all_AnnotationOfQuestionLanguage.rq");
}};
// Holds explanation templates for the declared annotation types
private static final Map<String, String> annotationTypeExplanationTemplate = new HashMap<>() {{
Expand All @@ -72,6 +72,7 @@ public class ExplanationService {
private ExplanationSparqlRepository explanationSparqlRepository;
@Autowired
private AnnotationsService annotationsService;

public ExplanationService() {
}

Expand Down Expand Up @@ -185,9 +186,9 @@ public String convertToDesiredFormat(String header, Model model) {
*/
public String buildSparqlQuery(String graphURI, String componentUri, String rawQuery) throws IOException {
QuerySolutionMap bindingsForSparqlQuery = new QuerySolutionMap();
bindingsForSparqlQuery.add("graphURI", ResourceFactory.createResource(graphURI));
bindingsForSparqlQuery.add("graph", ResourceFactory.createResource(graphURI));
if (componentUri != null) // Extension for compatibility w/ explanation for specific component
bindingsForSparqlQuery.add("componentURI", ResourceFactory.createResource(componentUri));
bindingsForSparqlQuery.add("annotatedBy", ResourceFactory.createResource(componentUri));

return QanaryTripleStoreConnector.readFileFromResourcesWithMap(rawQuery, bindingsForSparqlQuery);

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
am ${createdAt} eine SPARQL-query ausgeführt und folgende JSON zurückgegeben ' ${answerJson} ' &{mit einer Konfidenz von ${score}}&
am ${annotatedAt} eine SPARQL-query ausgeführt und folgende JSON zurückgegeben ' ${hasBody} ' &{mit einer Konfidenz von ${score}}&
Original file line number Diff line number Diff line change
@@ -1 +1 @@
on ${createdAt} a SPARQL-query was executed and returned the following JSON ' ${answerJson} ' &{with a confidence of ${score}}&
on ${annotatedAt} a SPARQL-query was executed and returned the following JSON ' ${hasBody} ' &{with a confidence of ${score}}&
Original file line number Diff line number Diff line change
@@ -1 +1 @@
am ${createdAt} mit einer Konfidenz von ${score} die SPARQL-query ' ${body} '
am ${annotatedAt} mit einer Konfidenz von ${score} die SPARQL-query ' ${hasBody} '
Original file line number Diff line number Diff line change
@@ -1 +1 @@
on ${createdAt} with a confidence of ${score} the SPARQL-query ' ${body} '
on ${annotatedAt} with a confidence of ${score} the SPARQL-query ' ${hasBody} '
Original file line number Diff line number Diff line change
@@ -1 +1 @@
am ${createdAt} &{mit einer Konfidenz von ${score}}& die Resource ${body}
am ${annotatedAt} &{mit einer Konfidenz von ${score}}& die Resource ${hasBody}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
on ${createdAt} &{with a confidence of ${score}}& and the resource ${body}
on ${annotatedAt} &{with a confidence of ${score}}& and the resource ${hasBody}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
am ${createdAt} für die Frage mit der URI '${hasTarget}' die Sprache '${body}'
am ${annotatedAt} für die Frage mit der URI '${hasTarget}' die Sprache '${hasBody}'
Original file line number Diff line number Diff line change
@@ -1 +1 @@
at ${createdAt} for the question with the URI '${hasTarget}' the language '${body}'
at ${annotatedAt} for the question with the URI '${hasTarget}' the language '${hasBody}'
Original file line number Diff line number Diff line change
@@ -1 +1 @@
am ${createdAt} die Frage mit der ID '${question}' in "${translation}"
am ${annotatedAt} die Frage mit der ID '${hasTarget}' in "${hasBody}"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
at ${createdAt} the question with the ID '${question}' into "${translation}"
at ${annotatedAt} the question with the ID '${hasTarget}' into "${hasBody}"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
' ${body} ' am ${createdAt} &{beginnend bei ${start} und endend bei ${end}}& &{mit einer Konfidenz von ${score}}&
' ${hasBody} ' am ${annotatedAt} &{beginnend bei ${start} und endend bei ${end}}& &{mit einer Konfidenz von ${score}}&
Original file line number Diff line number Diff line change
@@ -1 +1 @@
' ${body} ' at ${createdAt} &{starting at ${start} and ending at ${end}}& &{with a confidence of ${score}}&
' ${hasBody} ' at ${annotatedAt} &{starting at ${start} and ending at ${end}}& &{with a confidence of ${score}}&
Original file line number Diff line number Diff line change
@@ -1 +1 @@
am ${createdAt} beginnend bei ${start} und endend an Position ${end}
am ${annotatedAt} beginnend bei ${start} und endend an Position ${end}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
at ${createdAt} starting from position ${start} and ending at position ${end}
at ${annotatedAt} starting from position ${start} and ending at position ${end}
2 changes: 1 addition & 1 deletion src/main/resources/queries/components_sparql_query.rq
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PREFIX oa: <http://www.w3.org/ns/openannotation/core/>
PREFIX qa: <http://www.wdaqua.eu/qa#>

SELECT DISTINCT ?component
FROM ?graphURI
FROM ?graph
WHERE {
?s oa:annotatedBy ?component .
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ PREFIX oa: <http://www.w3.org/ns/openannotation/core/>
PREFIX qa: <http://www.wdaqua.eu/qa#>

SELECT DISTINCT ?annotationType
FROM ?graphURI
FROM ?graph
WHERE {
?annotationId rdf:type ?annotationType .
?annotationId oa:annotatedBy ?componentURI .
?annotationId oa:annotatedBy ?annotatedBy .
}
2 changes: 1 addition & 1 deletion src/main/resources/queries/question_query.rq
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PREFIX oa: <http://www.w3.org/ns/openannotation/core/>
PREFIX qa: <http://www.wdaqua.eu/qa#>

SELECT DISTINCT ?source
FROM ?graphURI
FROM ?graph
WHERE {
?source ?p <urn:qanary:currentQuestion> .
}
Loading

0 comments on commit c9ac18a

Please sign in to comment.