diff --git a/qanary-component-KG2KG-TranslateAnnotationsOfInstance/pom.xml b/qanary-component-KG2KG-TranslateAnnotationsOfInstance/pom.xml
index 98c0919c4..8ce7489d1 100644
--- a/qanary-component-KG2KG-TranslateAnnotationsOfInstance/pom.xml
+++ b/qanary-component-KG2KG-TranslateAnnotationsOfInstance/pom.xml
@@ -6,7 +6,7 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-KG2KG-TranslateAnnotationsOfInstance
- 0.1.4
+ 0.2.0
Qanary component KG2KG Translation of AnnotationOfInstance
org.springframework.boot
diff --git a/qanary-component-KG2KG-TranslateAnnotationsOfInstance/src/main/java/eu/wdaqua/qanary/component/KG2KGTranslateAnnotationsOfInstance.java b/qanary-component-KG2KG-TranslateAnnotationsOfInstance/src/main/java/eu/wdaqua/qanary/component/KG2KGTranslateAnnotationsOfInstance.java
index 0cf2aac09..c68457f03 100644
--- a/qanary-component-KG2KG-TranslateAnnotationsOfInstance/src/main/java/eu/wdaqua/qanary/component/KG2KGTranslateAnnotationsOfInstance.java
+++ b/qanary-component-KG2KG-TranslateAnnotationsOfInstance/src/main/java/eu/wdaqua/qanary/component/KG2KGTranslateAnnotationsOfInstance.java
@@ -35,7 +35,7 @@ public class KG2KGTranslateAnnotationsOfInstance extends QanaryComponent {
- depending on what is given the other resource is returned
*/
- private static final String ANNOTATION_OF_INSTANCE_RESOURCES_QUERY = "/queries/annotationsOfInstanceResourceQuery.rq";
+ private static final String ANNOTATION_OF_INSTANCE_RESOURCES_QUERY = "/queries/select_all_AnnotationOfInstance.rq";
private static final String DBPEDIA_TO_WIKIDATA_QUERY = "/queries/dbpediaToWikidata.rq";
private static final String WIKIDATA_TO_DBPEDIA_QUERY = "/queries/wikidataToDbpedia.rq";
private static final String INSERT_ANNOTATION_QUERY = "/queries/insert_one_annotation.rq";
@@ -99,7 +99,7 @@ public ResultSet fetchAnnotations(String graphID, final QanaryUtils qanaryUtils)
*/
public String getRequestQuery(String graphID) throws IOException {
QuerySolutionMap bindingsForQuery = new QuerySolutionMap();
- bindingsForQuery.add("graphID", ResourceFactory.createResource(graphID));
+ bindingsForQuery.add("graph", ResourceFactory.createResource(graphID));
return QanaryTripleStoreConnector.readFileFromResourcesWithMap(ANNOTATION_OF_INSTANCE_RESOURCES_QUERY, bindingsForQuery);
}
@@ -109,9 +109,9 @@ public List createAnnotationObjets(ResultSet resultSet
while (resultSet.hasNext()) {
QuerySolution entry = resultSet.next();
- String entryResource = entry.get("resource").toString();
+ String entryResource = entry.get("hasBody").toString();
double score = entry.get("score").asLiteral().getDouble();
- String targetQuestion = entry.get("targetQuestion").toString();
+ String targetQuestion = entry.get("hasSource").toString();
int start = entry.get("start").asLiteral().getInt();
int end = entry.get("end").asLiteral().getInt();
String annotationId = entry.get("annotationId").toString();
diff --git a/qanary-component-KG2KG-TranslateAnnotationsOfInstance/src/main/resources/queries/annotationsOfInstanceResourceQuery.rq b/qanary-component-KG2KG-TranslateAnnotationsOfInstance/src/main/resources/queries/annotationsOfInstanceResourceQuery.rq
deleted file mode 100644
index ef50932e4..000000000
--- a/qanary-component-KG2KG-TranslateAnnotationsOfInstance/src/main/resources/queries/annotationsOfInstanceResourceQuery.rq
+++ /dev/null
@@ -1,20 +0,0 @@
-# retrieve an annotation typed AnnotationOfInstance from the Qanary triplestore
-PREFIX qa:
-PREFIX oa:
-
-SELECT *
-FROM ?graphID
-WHERE {
- ?annotationId a qa:AnnotationOfInstance .
- ?annotationId oa:hasTarget [
- a oa:SpecificResource;
- oa:hasSource ?targetQuestion;
- oa:hasSelector [
- a oa:TextPositionSelector ;
- oa:start ?start ;
- oa:end ?end
- ]
- ] .
- ?annotationId oa:hasBody ?resource ;
- qa:score ?score .
-}
diff --git a/qanary-component-NED-AGDISTIS/pom.xml b/qanary-component-NED-AGDISTIS/pom.xml
index f5bffbb80..f69aaf553 100644
--- a/qanary-component-NED-AGDISTIS/pom.xml
+++ b/qanary-component-NED-AGDISTIS/pom.xml
@@ -4,8 +4,7 @@
4.0.0
qanary-component-NED-AGDISTIS
eu.wdaqua.qanary.component
- 4.4.0
-
+ 4.5.0
org.springframework.boot
spring-boot-starter-parent
diff --git a/qanary-component-NED-AGDISTIS/src/main/java/eu/wdaqua/qanary/component/agdistis/ned/Agdistis.java b/qanary-component-NED-AGDISTIS/src/main/java/eu/wdaqua/qanary/component/agdistis/ned/Agdistis.java
index 69ffabb83..415872a33 100644
--- a/qanary-component-NED-AGDISTIS/src/main/java/eu/wdaqua/qanary/component/agdistis/ned/Agdistis.java
+++ b/qanary-component-NED-AGDISTIS/src/main/java/eu/wdaqua/qanary/component/agdistis/ned/Agdistis.java
@@ -48,7 +48,7 @@
public class Agdistis extends QanaryComponent {
private static final Logger LOGGER = LoggerFactory.getLogger(Agdistis.class);
- private final String FILENAME_SPOTS_FROM_GRAPH = "/queries/select_all_spots_from_graph.rq";
+ private final String FILENAME_SPOTS_FROM_GRAPH = "/queries/select_all_AnnotationOfSpotInstance.rq";
private final String FILENAME_INSERT_ANNOTATION = "/queries/insert_one_annotation.rq";
private final String applicationName;
diff --git a/qanary-component-NED-AGDISTIS/src/main/resources/queries/select_all_spots_from_graph.rq b/qanary-component-NED-AGDISTIS/src/main/resources/queries/select_all_spots_from_graph.rq
deleted file mode 100644
index 89ebdc3a1..000000000
--- a/qanary-component-NED-AGDISTIS/src/main/resources/queries/select_all_spots_from_graph.rq
+++ /dev/null
@@ -1,19 +0,0 @@
-PREFIX qa:
-PREFIX oa:
-PREFIX xsd:
-
-SELECT ?start ?end
-FROM ?graph
-WHERE {
-?a a qa:AnnotationOfSpotInstance .
-?a oa:hasTarget [
- a oa:SpecificResource;
- oa:hasSource ?q;
- oa:hasSelector [
- a oa:TextPositionSelector ;
- oa:start ?start ;
- oa:end ?end
- ]
-] ;
-}
-ORDER BY ?start
diff --git a/qanary-component-NED-AGDISTIS/src/test/java/eu/wdaqua/qanary/component/agdistis/ned/AgdistisMockedTest.java b/qanary-component-NED-AGDISTIS/src/test/java/eu/wdaqua/qanary/component/agdistis/ned/AgdistisMockedTest.java
index 7a708e477..888c461d4 100644
--- a/qanary-component-NED-AGDISTIS/src/test/java/eu/wdaqua/qanary/component/agdistis/ned/AgdistisMockedTest.java
+++ b/qanary-component-NED-AGDISTIS/src/test/java/eu/wdaqua/qanary/component/agdistis/ned/AgdistisMockedTest.java
@@ -72,7 +72,7 @@ public void init() throws URISyntaxException, QanaryExceptionNoOrMultipleQuestio
ReflectionTestUtils.setField(this.mockedAgdistis, "myRestTemplate", this.myRestTemplate);
ReflectionTestUtils.setField(this.mockedAgdistis, "myCacheOfResponses", this.myCacheOfResponses);
ReflectionTestUtils.setField(this.mockedAgdistis, "apiUrl", this.apiUrl);
- ReflectionTestUtils.setField(this.mockedAgdistis, "FILENAME_SPOTS_FROM_GRAPH", "/queries/select_all_spots_from_graph.rq");
+ ReflectionTestUtils.setField(this.mockedAgdistis, "FILENAME_SPOTS_FROM_GRAPH", "/queries/select_all_AnnotationOfSpotInstance.rq");
ReflectionTestUtils.setField(this.mockedAgdistis, "FILENAME_INSERT_ANNOTATION", "/queries/insert_one_annotation.rq");
this.mockedQanaryQuestion = Mockito.mock(QanaryQuestion.class);
diff --git a/qanary-component-NED-DiambiguationClass-OKBQA/pom.xml b/qanary-component-NED-DiambiguationClass-OKBQA/pom.xml
index 2b3c9b235..d41c4142e 100644
--- a/qanary-component-NED-DiambiguationClass-OKBQA/pom.xml
+++ b/qanary-component-NED-DiambiguationClass-OKBQA/pom.xml
@@ -5,7 +5,7 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NED-DiambiguationClass-OKBQA
- 3.1.4
+ 3.2.0
org.springframework.boot
diff --git a/qanary-component-NED-DiambiguationClass-OKBQA/src/main/java/eu/wdaqua/qanary/component/diambiguationclass/ned/DiambiguationClass.java b/qanary-component-NED-DiambiguationClass-OKBQA/src/main/java/eu/wdaqua/qanary/component/diambiguationclass/ned/DiambiguationClass.java
index 3c2309d53..7609047b6 100644
--- a/qanary-component-NED-DiambiguationClass-OKBQA/src/main/java/eu/wdaqua/qanary/component/diambiguationclass/ned/DiambiguationClass.java
+++ b/qanary-component-NED-DiambiguationClass-OKBQA/src/main/java/eu/wdaqua/qanary/component/diambiguationclass/ned/DiambiguationClass.java
@@ -51,7 +51,7 @@ public class DiambiguationClass extends QanaryComponent {
private final String applicationName;
private String FILENAME_INSERT_ANNOTATION = "/queries/insert_one_annotation.rq";
- private String FILENAME_SELECT_ANNOTATED_LANGUAGES = "/queries/select_annotated_languages.rq";
+ private String FILENAME_SELECT_ANNOTATED_LANGUAGES = "/queries/select_all_AnnotationOfQuestionLanguage.rq";
public DiambiguationClass(@Value("${spring.application.name}") final String applicationName) {
this.applicationName = applicationName;
diff --git a/qanary-component-NED-DiambiguationClass-OKBQA/src/main/resources/queries/select_annotated_languages.rq b/qanary-component-NED-DiambiguationClass-OKBQA/src/main/resources/queries/select_annotated_languages.rq
deleted file mode 100644
index f5cac5fa7..000000000
--- a/qanary-component-NED-DiambiguationClass-OKBQA/src/main/resources/queries/select_annotated_languages.rq
+++ /dev/null
@@ -1,10 +0,0 @@
-PREFIX qa:
-
-SELECT ?lang
-FROM ?graph
-WHERE {
- ?q a qa:Question .
- ?anno ?q .
- ?anno ?lang .
- ?anno a qa:AnnotationOfQuestionLanguage .
-}
\ No newline at end of file
diff --git a/qanary-component-NED-Tagme/pom.xml b/qanary-component-NED-Tagme/pom.xml
index e463fc63b..456723192 100644
--- a/qanary-component-NED-Tagme/pom.xml
+++ b/qanary-component-NED-Tagme/pom.xml
@@ -5,7 +5,7 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-NED-Tagme
- 3.2.0
+ 3.3.0
org.springframework.boot
spring-boot-starter-parent
diff --git a/qanary-component-NED-Tagme/src/main/resources/queries/insert_one_annotation.rq b/qanary-component-NED-Tagme/src/main/resources/queries/insert_one_annotation.rq
index f3be0a099..debc327df 100644
--- a/qanary-component-NED-Tagme/src/main/resources/queries/insert_one_annotation.rq
+++ b/qanary-component-NED-Tagme/src/main/resources/queries/insert_one_annotation.rq
@@ -12,8 +12,8 @@ GRAPH ?graph {
a oa:TextPositionSelector ;
oa:start ?start ;
oa:end ?end ;
- qa:score ?score .
- ] .
+ qa:score ?score
+ ]
] .
?a oa:hasBody ?answer ;
oa:annotatedBy ?application ;
@@ -22,4 +22,4 @@ GRAPH ?graph {
WHERE {
BIND (IRI(str(RAND())) AS ?a) .
BIND (now() as ?time) .
-}
\ No newline at end of file
+}
diff --git a/qanary-component-QB-BirthDataWikidata/pom.xml b/qanary-component-QB-BirthDataWikidata/pom.xml
index fe868f252..532065a38 100644
--- a/qanary-component-QB-BirthDataWikidata/pom.xml
+++ b/qanary-component-QB-BirthDataWikidata/pom.xml
@@ -6,7 +6,6 @@
eu.wdaqua.qanary.component
qanary-component-QB-BirthDataWikidata
3.4.0
-
org.springframework.boot
spring-boot-starter-parent
@@ -34,6 +33,11 @@
+
+ eu.wdaqua.qanary
+ qa.commons
+ [3.5.4,4.0.0]
+
org.apache.logging.log4j
log4j-to-slf4j
diff --git a/qanary-component-QB-BirthDataWikidata/src/main/java/eu/wdaqua/component/qb/birthdata/wikidata/BirthDataQueryBuilder.java b/qanary-component-QB-BirthDataWikidata/src/main/java/eu/wdaqua/component/qb/birthdata/wikidata/BirthDataQueryBuilder.java
index 5cbcd75fe..aa42fdd60 100644
--- a/qanary-component-QB-BirthDataWikidata/src/main/java/eu/wdaqua/component/qb/birthdata/wikidata/BirthDataQueryBuilder.java
+++ b/qanary-component-QB-BirthDataWikidata/src/main/java/eu/wdaqua/component/qb/birthdata/wikidata/BirthDataQueryBuilder.java
@@ -44,7 +44,6 @@
@Component
public class BirthDataQueryBuilder extends QanaryComponent {
private static final Logger logger = LoggerFactory.getLogger(BirthDataQueryBuilder.class);
-
public static final String FILENAME_ANNOTATIONS = "/queries/getAnnotation.rq";
public static final String FILENAME_ANNOTATIONS_NAMED_ENTITY_FILTERED_FOR_WIKIDATA = "/queries/getAnnotationOfNamedEntityLinkedToSpecificKnowledgeGraph.rq";
@@ -152,12 +151,12 @@ public QanaryMessage process(QanaryMessage myQanaryMessage) throws Exception {
return myQanaryMessage;
}
-// // second, let's try to find a firstname and lastname, if that works we stop
-// myQanaryMessage = this.processForFirstNameAndLastName(myQanaryMessage);
-// if( myQanaryMessage != null ) {
-// logger.info("Found firstname and lastname. Processing finished.");
-// return myQanaryMessage;
-// }
+ // second, let's try to find a firstname and lastname, if that works we stop
+ myQanaryMessage = this.processForFirstNameAndLastName(myQanaryMessage);
+ if( myQanaryMessage != null ) {
+ logger.info("Found firstname and lastname. Processing finished.");
+ return myQanaryMessage;
+ }
logger.warn("Nothing could be done here.");
return myQanaryMessage;
diff --git a/qanary-component-QB-BirthDataWikidata/src/test/java/eu/wdaqua/component/birthdatawikidata/qb/QueryTest.java b/qanary-component-QB-BirthDataWikidata/src/test/java/eu/wdaqua/component/birthdatawikidata/qb/QueryTest.java
index b1d91f8e9..209dad17d 100644
--- a/qanary-component-QB-BirthDataWikidata/src/test/java/eu/wdaqua/component/birthdatawikidata/qb/QueryTest.java
+++ b/qanary-component-QB-BirthDataWikidata/src/test/java/eu/wdaqua/component/birthdatawikidata/qb/QueryTest.java
@@ -14,6 +14,8 @@
import org.springframework.test.context.web.WebAppConfiguration;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import static org.junit.jupiter.api.Assertions.*;
@@ -27,7 +29,7 @@ class QueryTest {
void filenameAnnotationsQueryTest() throws IOException {
QuerySolutionMap bindingsForFirstname = new QuerySolutionMap();
bindingsForFirstname.add("graph", ResourceFactory.createResource("urn:graph"));
- bindingsForFirstname.add("value", ResourceFactory.createStringLiteral("FIRST_NAME"));
+ bindingsForFirstname.add("hasBody", ResourceFactory.createStringLiteral("FIRST_NAME"));
String sparqlCheckFirstname = QanaryTripleStoreConnector.readFileFromResourcesWithMap(
TestConfiguration.FILENAME_ANNOTATIONS, bindingsForFirstname
@@ -37,17 +39,18 @@ void filenameAnnotationsQueryTest() throws IOException {
assertFalse(sparqlCheckFirstname.isEmpty());
assertFalse(sparqlCheckFirstname.isBlank());
- assertEquals(TestConfiguration.getTestQuery("queries/getAnnotationTest.rq"), sparqlCheckFirstname);
+ assertEquals(TestConfiguration.getTestQuery("queries/getAnnotationTest.rq").concat("\n"),sparqlCheckFirstname);
}
@Test
void filenameAnnotationsFilteredQueryTest() throws IOException {
QuerySolutionMap bindingsForAnnotation = new QuerySolutionMap();
bindingsForAnnotation.add("graph", ResourceFactory.createResource("urn:graph"));
- bindingsForAnnotation.add("source", ResourceFactory.createResource("urn:source"));
- bindingsForAnnotation.add("filterStart", ResourceFactory.createTypedLiteral(String.valueOf(5), XSDDatatype.XSDint));
+ bindingsForAnnotation.add("hasSource", ResourceFactory.createResource("urn:source"));
+ bindingsForAnnotation.add("start", ResourceFactory.createTypedLiteral(String.valueOf(5), XSDDatatype.XSDint));
String sparqlGetAnnotation = QanaryTripleStoreConnector.readFileFromResourcesWithMap(
+
TestConfiguration.FILENAME_ANNOTATIONS_NAMED_ENTITY_FILTERED_FOR_WIKIDATA,
bindingsForAnnotation
);
@@ -56,7 +59,7 @@ void filenameAnnotationsFilteredQueryTest() throws IOException {
assertFalse(sparqlGetAnnotation.isEmpty());
assertFalse(sparqlGetAnnotation.isBlank());
- assertEquals(TestConfiguration.getTestQuery("queries/getAnnotationFilteredTest.rq"), sparqlGetAnnotation);
+ assertEquals(TestConfiguration.getTestQuery("queries/getAnnotationFilteredTest.rq").concat("\n"), sparqlGetAnnotation);
}
@Test
@@ -73,7 +76,7 @@ void questionAnswerFromWikidataByPersonTest() throws IOException {
assertFalse(sparql.isEmpty());
assertFalse(sparql.isBlank());
- assertEquals(TestConfiguration.getTestQuery("queries/getQuestionAnswerFromWikidataByPersonTest.rq"), sparql);
+ assertEquals(TestConfiguration.getTestQuery("queries/getQuestionAnswerFromWikidataByPersonTest.rq").concat("\n"), sparql);
}
@Test
@@ -90,7 +93,7 @@ void wikidataQueryFirstAndLastNameTest() throws IOException {
assertFalse(sparql.isEmpty());
assertFalse(sparql.isBlank());
- assertEquals(TestConfiguration.getTestQuery("queries/getQuestionAnswerFromWikidataByFirstnameLastnameTest.rq"), sparql);
+ assertEquals(TestConfiguration.getTestQuery("queries/getQuestionAnswerFromWikidataByFirstnameLastnameTest.rq").concat("\n"), sparql);
}
}
\ No newline at end of file
diff --git a/qanary-component-QB-BirthDataWikidata/src/test/java/eu/wdaqua/component/birthdatawikidata/qb/TestConfiguration.java b/qanary-component-QB-BirthDataWikidata/src/test/java/eu/wdaqua/component/birthdatawikidata/qb/TestConfiguration.java
index 7d5c2c456..fd99e39fc 100644
--- a/qanary-component-QB-BirthDataWikidata/src/test/java/eu/wdaqua/component/birthdatawikidata/qb/TestConfiguration.java
+++ b/qanary-component-QB-BirthDataWikidata/src/test/java/eu/wdaqua/component/birthdatawikidata/qb/TestConfiguration.java
@@ -1,13 +1,20 @@
package eu.wdaqua.component.birthdatawikidata.qb;
-import java.io.IOException;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.util.ResourceUtils;
+
+import java.io.*;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Scanner;
+import java.util.stream.Collectors;
import eu.wdaqua.component.qb.birthdata.wikidata.BirthDataQueryBuilder;
@org.springframework.boot.test.context.TestConfiguration
public class TestConfiguration {
+
protected static final String FILENAME_ANNOTATIONS = BirthDataQueryBuilder.FILENAME_ANNOTATIONS;
protected static final String FILENAME_ANNOTATIONS_NAMED_ENTITY_FILTERED_FOR_WIKIDATA = BirthDataQueryBuilder.FILENAME_ANNOTATIONS_NAMED_ENTITY_FILTERED_FOR_WIKIDATA;
protected static final String FILENAME_WIKIDATA_BIRTHDATA_QUERY_PERSON = BirthDataQueryBuilder.FILENAME_WIKIDATA_BIRTHDATA_QUERY_PERSON;
@@ -20,9 +27,17 @@ public class TestConfiguration {
* @throws IOException
*/
protected static String getTestQuery(String testQueryFilename) throws IOException {
- String path = TestConfiguration.class.getClassLoader().getResource(testQueryFilename).getPath();
+// String path = TestConfiguration.class.getClassLoader().getResource(testQueryFilename).getPath();
+// File file = ResourceUtils.getFile(ResourceUtils.CLASSPATH_URL_PREFIX + testQueryFilename);
+// return new String(Files.readAllBytes(file.toPath()));
- return new String(Files.readAllBytes(Paths.get(path)));
+ try (InputStream inputStream = TestConfiguration.class.getClassLoader().getResourceAsStream(testQueryFilename)) {
+ if (inputStream != null) {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
+ return reader.lines().collect(Collectors.joining("\n"));
+ } else {
+ throw new IOException("Resource not found: " + testQueryFilename);
+ }
+ }
}
-
}
\ No newline at end of file
diff --git a/qanary-component-QB-BirthDataWikidata/src/test/resources/queries/getAnnotationFilteredTest.rq b/qanary-component-QB-BirthDataWikidata/src/test/resources/queries/getAnnotationFilteredTest.rq
index 60e226c53..77eaa443b 100644
--- a/qanary-component-QB-BirthDataWikidata/src/test/resources/queries/getAnnotationFilteredTest.rq
+++ b/qanary-component-QB-BirthDataWikidata/src/test/resources/queries/getAnnotationFilteredTest.rq
@@ -1,6 +1,5 @@
PREFIX qa:
PREFIX oa:
-PREFIX dbr:
PREFIX rdf:
SELECT *
@@ -19,4 +18,3 @@ WHERE
FILTER ( ?start = "5"^^ )
FILTER regex(?wikidataResource, ?regexForResourceFilter, "i")
}
-ORDER BY DESC(?annotationScore)
diff --git a/qanary-component-QB-BirthDataWikidata/src/test/resources/queries/getAnnotationTest.rq b/qanary-component-QB-BirthDataWikidata/src/test/resources/queries/getAnnotationTest.rq
index 74f7235bd..4356e0cea 100644
--- a/qanary-component-QB-BirthDataWikidata/src/test/resources/queries/getAnnotationTest.rq
+++ b/qanary-component-QB-BirthDataWikidata/src/test/resources/queries/getAnnotationTest.rq
@@ -1,20 +1,25 @@
PREFIX qa:
PREFIX oa:
-PREFIX dbr:
PREFIX rdf:
SELECT *
FROM
WHERE
- { ?annotation oa:hasBody ?wikidataResource ;
- qa:score ?annotationScore ;
- oa:hasTarget ?target
- FILTER ( ?wikidataResource = "FIRST_NAME" )
- ?target oa:hasSource ?source ;
- oa:hasSelector ?textSelector .
- ?textSelector
- rdf:type oa:TextPositionSelector ;
+ { ?annotationId
+ rdf:type qa:AnnotationOfInstance ;
+ oa:hasTarget _:b0 .
+ _:b0 rdf:type oa:SpecificResource ;
+ oa:hasSource ?hasSource ;
+ oa:hasSelector _:b1 .
+ _:b1 rdf:type oa:TextPositionSelector ;
oa:start ?start ;
- oa:end ?end
+ oa:end ?end .
+ ?annotationId
+ oa:hasBody "FIRST_NAME" ;
+ oa:annotatedBy ?annotatedBy ;
+ oa:annotatedAt ?annotatedAt
+ OPTIONAL
+ { ?annotationId
+ qa:score ?score
+ }
}
-ORDER BY DESC(?annotationScore)
diff --git a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/pom.xml b/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/pom.xml
index 405befa02..e82c0d69b 100644
--- a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/pom.xml
+++ b/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/pom.xml
@@ -5,8 +5,7 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia
- 3.2.4
-
+ 3.3.0
org.springframework.boot
spring-boot-starter-parent
diff --git a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/main/java/eu/wdaqua/qanary/component/comiccharacteralteregoaimpledbpedia/qb/ComicCharacterAlterEgoSimpleDBpediaQueryBuilder.java b/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/main/java/eu/wdaqua/qanary/component/comiccharacteralteregoaimpledbpedia/qb/ComicCharacterAlterEgoSimpleDBpediaQueryBuilder.java
index 8c27b0182..c8f6d4184 100644
--- a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/main/java/eu/wdaqua/qanary/component/comiccharacteralteregoaimpledbpedia/qb/ComicCharacterAlterEgoSimpleDBpediaQueryBuilder.java
+++ b/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/main/java/eu/wdaqua/qanary/component/comiccharacteralteregoaimpledbpedia/qb/ComicCharacterAlterEgoSimpleDBpediaQueryBuilder.java
@@ -38,7 +38,7 @@ public class ComicCharacterAlterEgoSimpleDBpediaQueryBuilder extends QanaryCompo
private final String applicationName;
private String FILENAME_INSERT_ANNOTATION = "/queries/insert_one_annotation.rq";
- private String FILENAME_SELECT_ANNOTATION = "/queries/select_annotation.rq";
+ private String FILENAME_SELECT_ANNOTATION = "/queries/select_all_AnnotationOfSpotInstance.rq";
private String FILENAME_DBPEDIA_QUERY = "/queries/dbpedia_query.rq";
public ComicCharacterAlterEgoSimpleDBpediaQueryBuilder(@Value("${spring.application.name}") final String applicationName) {
@@ -75,7 +75,7 @@ public QanaryMessage process(QanaryMessage myQanaryMessage) throws Exception {
QuerySolutionMap bindingsForSelect = new QuerySolutionMap();
bindingsForSelect.add("graph", ResourceFactory.createResource(qanaryQuestion.getOutGraph().toASCIIString()));
- bindingsForSelect.add("targetQuestion", ResourceFactory.createResource(qanaryQuestion.getUri().toASCIIString()));
+ bindingsForSelect.add("hasSource", ResourceFactory.createResource(qanaryQuestion.getUri().toASCIIString()));
// get the template of the INSERT query
String sparql = this.loadQueryFromFile(FILENAME_SELECT_ANNOTATION, bindingsForSelect);
@@ -89,8 +89,8 @@ public QanaryMessage process(QanaryMessage myQanaryMessage) throws Exception {
while (resultSet.hasNext()) {
QuerySolution result = resultSet.next();
logger.info("result: \n{}", result);
- int start = result.get("startOfSpecificResource").asLiteral().getInt();
- int end = result.get("endOfSpecificResource").asLiteral().getInt();
+ int start = result.get("start").asLiteral().getInt();
+ int end = result.get("end").asLiteral().getInt();
String name = question.substring(start, end);
logger.warn("annotation found for name '{}' (at {},{})", name, start, end);
diff --git a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/main/resources/queries/select_annotation.rq b/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/main/resources/queries/select_annotation.rq
deleted file mode 100644
index 7952dbcd5..000000000
--- a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/main/resources/queries/select_annotation.rq
+++ /dev/null
@@ -1,24 +0,0 @@
-PREFIX qa:
-PREFIX oa:
-
-SELECT ?a ?dbpediaResource ?startOfSpecificResource ?endOfSpecificResource ?annotatorComponent ?time
-FROM ?graph
-WHERE {
- VALUES ?dbpediaResource {
- ?targetQuestion
- }
- ?a a qa:AnnotationOfSpotInstance .
- ?a oa:hasTarget [
- a oa:SpecificResource ;
- oa:hasSource ?dbpediaResource ;
- oa:hasSelector [
- a oa:TextPositionSelector ;
- oa:start ?startOfSpecificResource ;
- oa:end ?endOfSpecificResource
- ]
- ] .
- ?a oa:annotatedAt ?time .
-# The component was originally built to look specifically for
-# annotations of ComicCharacterNameSimpleNamedEntityRecognizer:
-# ?a oa:annotatedBy .
-}
\ No newline at end of file
diff --git a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/java/eu/wdaqua/qanary/component/comiccharacteralteregoaimpledbpedia/qb/QueryTest.java b/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/java/eu/wdaqua/qanary/component/comiccharacteralteregoaimpledbpedia/qb/QueryTest.java
index c627ccbe1..a0afda90d 100644
--- a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/java/eu/wdaqua/qanary/component/comiccharacteralteregoaimpledbpedia/qb/QueryTest.java
+++ b/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/java/eu/wdaqua/qanary/component/comiccharacteralteregoaimpledbpedia/qb/QueryTest.java
@@ -36,7 +36,7 @@ void selectAnnotationQueryTest() throws IOException {
assertFalse(sparql.isEmpty());
assertFalse(sparql.isBlank());
- assertEquals(TestConfiguration.getTestQuery("queries/select_annotation_test.rq"), sparql);
+ assertEquals(TestConfiguration.getTestQuery("queries/select_annotation_test.rq").concat("\n"), sparql);
}
@Test
diff --git a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/java/eu/wdaqua/qanary/component/comiccharacteralteregoaimpledbpedia/qb/TestConfiguration.java b/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/java/eu/wdaqua/qanary/component/comiccharacteralteregoaimpledbpedia/qb/TestConfiguration.java
index 074abda9e..edd801ec1 100644
--- a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/java/eu/wdaqua/qanary/component/comiccharacteralteregoaimpledbpedia/qb/TestConfiguration.java
+++ b/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/java/eu/wdaqua/qanary/component/comiccharacteralteregoaimpledbpedia/qb/TestConfiguration.java
@@ -7,7 +7,7 @@
@org.springframework.boot.test.context.TestConfiguration
public class TestConfiguration {
protected static final String FILENAME_INSERT_ANNOTATION = "/queries/insert_one_annotation.rq";
- protected static final String FILENAME_SELECT_ANNOTATION = "/queries/select_annotation.rq";
+ protected static final String FILENAME_SELECT_ANNOTATION = "/queries/select_all_AnnotationOfSpotInstance.rq";
protected static final String FILENAME_DBPEDIA_QUERY = "/queries/dbpedia_query.rq";
/**
diff --git a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/resources/queries/select_annotation_test.rq b/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/resources/queries/select_annotation_test.rq
index e49a698a0..f5d090de3 100644
--- a/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/resources/queries/select_annotation_test.rq
+++ b/qanary-component-QB-ComicCharacterAlterEgoSimpleDBpedia/src/test/resources/queries/select_annotation_test.rq
@@ -1,17 +1,20 @@
PREFIX qa:
PREFIX oa:
+PREFIX rdf:
-SELECT ?a ?dbpediaResource ?startOfSpecificResource ?endOfSpecificResource ?annotatorComponent ?time
+SELECT *
FROM
WHERE
- { VALUES ?dbpediaResource { }
- ?a a qa:AnnotationOfSpotInstance ;
- oa:hasTarget _:b0 .
- _:b0 a oa:SpecificResource ;
- oa:hasSource ?dbpediaResource ;
- oa:hasSelector _:b1 .
- _:b1 a oa:TextPositionSelector ;
- oa:start ?startOfSpecificResource ;
- oa:end ?endOfSpecificResource .
- ?a oa:annotatedAt ?time
- }
+ { ?annotationId
+ rdf:type qa:AnnotationOfSpotInstance ;
+ oa:hasTarget _:b0 .
+ _:b0 rdf:type oa:SpecificResource ;
+ oa:hasSource ?hasSource ;
+ oa:hasSelector _:b1 .
+ _:b1 rdf:type oa:TextPositionSelector ;
+ oa:start ?start ;
+ oa:end ?end .
+ ?annotationId
+ oa:annotatedAt ?annotatedAt ;
+ oa:annotatedBy ?annotatedBy
+ }
\ No newline at end of file
diff --git a/qanary-component-QB-DateOfDeathDBpedia/pom.xml b/qanary-component-QB-DateOfDeathDBpedia/pom.xml
index 1bd708abc..972e99718 100644
--- a/qanary-component-QB-DateOfDeathDBpedia/pom.xml
+++ b/qanary-component-QB-DateOfDeathDBpedia/pom.xml
@@ -5,7 +5,7 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QB-DateOfDeathDBpedia
- 0.1.3
+ 0.2.0
org.springframework.boot
spring-boot-starter-parent
diff --git a/qanary-component-QB-DateOfDeathDBpedia/src/main/java/eu/wdaqua/qanary/component/dateofdeathrealpersons/qb/QueryBuilderDateOfDeathDBpedia.java b/qanary-component-QB-DateOfDeathDBpedia/src/main/java/eu/wdaqua/qanary/component/dateofdeathrealpersons/qb/QueryBuilderDateOfDeathDBpedia.java
index 6a329a603..f5917e42b 100644
--- a/qanary-component-QB-DateOfDeathDBpedia/src/main/java/eu/wdaqua/qanary/component/dateofdeathrealpersons/qb/QueryBuilderDateOfDeathDBpedia.java
+++ b/qanary-component-QB-DateOfDeathDBpedia/src/main/java/eu/wdaqua/qanary/component/dateofdeathrealpersons/qb/QueryBuilderDateOfDeathDBpedia.java
@@ -43,7 +43,7 @@ public class QueryBuilderDateOfDeathDBpedia extends QanaryComponent {
the final insert query */
// query used to fetch required information from the graphURI
- private static final String QUERY_FILE_FETCH_REQUIRED_ANNOTATIONS = "/queries/fetch_required_annotations.rq";
+ private static final String QUERY_FILE_FETCH_REQUIRED_ANNOTATIONS = "/queries/select_all_AnnotationOfInstance.rq";
// That's the later inserted query / new computed query
private static final String QUERY_FILE_DBPEDIA_QUERY = "/queries/dbpedia_query.rq";
@@ -168,9 +168,9 @@ public List createQueries(QanaryQuestion qanaryQuestion, List qu
public QuerySolutionMap getBindingsForSparqlQuery(QanaryQuestion myQanaryQuestion) throws Exception {
QuerySolutionMap querySolutionMap = new QuerySolutionMap();
querySolutionMap.add("graph", ResourceFactory.createResource(myQanaryQuestion.getOutGraph().toASCIIString()));// Set the GraphID
- querySolutionMap.add("targetQuestion", ResourceFactory.createResource(myQanaryQuestion.getUri().toASCIIString()));
- querySolutionMap.add("startValue", ResourceFactory.createTypedLiteral(String.valueOf(SUPPORTED_PREFIX.length()), XSDDatatype.XSDnonNegativeInteger));
- querySolutionMap.add("confidence", ResourceFactory.createTypedLiteral("1.0", XSDDatatype.XSDfloat));
+ querySolutionMap.add("hasSource", ResourceFactory.createResource(myQanaryQuestion.getUri().toASCIIString()));
+ querySolutionMap.add("start", ResourceFactory.createTypedLiteral(String.valueOf(SUPPORTED_PREFIX.length()), XSDDatatype.XSDnonNegativeInteger));
+ querySolutionMap.add("score", ResourceFactory.createTypedLiteral("1.0", XSDDatatype.XSDfloat));
return querySolutionMap;
}
diff --git a/qanary-component-QB-DateOfDeathDBpedia/src/main/resources/queries/fetch_required_annotations.rq b/qanary-component-QB-DateOfDeathDBpedia/src/main/resources/queries/fetch_required_annotations.rq
deleted file mode 100644
index fbe6a3146..000000000
--- a/qanary-component-QB-DateOfDeathDBpedia/src/main/resources/queries/fetch_required_annotations.rq
+++ /dev/null
@@ -1,22 +0,0 @@
-PREFIX dbr:
-PREFIX oa:
-PREFIX qa:
-PREFIX rdf:
-
-SELECT *
-FROM ?graph
-WHERE {
- ?annotation oa:hasBody ?dbpediaResource .
- ?annotation qa:score ?annotationScore .
- ?annotation oa:hasTarget ?target .
- {
- ?target oa:hasSource ?targetQuestion .
- } UNION {
- ?target oa:hasSource .
- }
- ?target oa:hasSelector ?textSelector .
- ?textSelector rdf:type oa:TextPositionSelector .
- ?textSelector oa:start ?start .
- ?textSelector oa:end ?end .
- FILTER(?start = ?startValue) .
-}
\ No newline at end of file
diff --git a/qanary-component-QB-DateOfDeathDBpedia/src/test/java/eu/wdaqua/qanary/component/mypackage/QanaryServiceQueryBuilderDateOfDeathDBpediaControllerTest.java b/qanary-component-QB-DateOfDeathDBpedia/src/test/java/eu/wdaqua/qanary/component/mypackage/QanaryServiceQueryBuilderDateOfDeathDBpediaControllerTest.java
index c755412a2..3d746d2b6 100644
--- a/qanary-component-QB-DateOfDeathDBpedia/src/test/java/eu/wdaqua/qanary/component/mypackage/QanaryServiceQueryBuilderDateOfDeathDBpediaControllerTest.java
+++ b/qanary-component-QB-DateOfDeathDBpedia/src/test/java/eu/wdaqua/qanary/component/mypackage/QanaryServiceQueryBuilderDateOfDeathDBpediaControllerTest.java
@@ -295,8 +295,8 @@ void getBindingForSparqlQueryWithGivenQanaryQuestion() throws Exception {
Map solutionsAsMap = querySolutionMap.asMap();
assertAll("Check correct Map",
() -> assertEquals(solutionsAsMap.get("graph").toString(), qanaryMessage.getOutGraph().toString()),
- () -> assertEquals(solutionsAsMap.get("targetQuestion").toString(), EXAMPLE_QUESTION),
- () -> assertEquals(solutionsAsMap.get("startValue").asLiteral(),
+ () -> assertEquals(solutionsAsMap.get("hasSource").toString(), EXAMPLE_QUESTION),
+ () -> assertEquals(solutionsAsMap.get("start").asLiteral(),
ResourceFactory.createTypedLiteral(String.valueOf(SUPPORTED_PREFIX.length()), XSDDatatype.XSDnonNegativeInteger))
);
}
diff --git a/qanary-component-QB-GAnswerWrapper/pom.xml b/qanary-component-QB-GAnswerWrapper/pom.xml
index d622665fc..51996dc05 100644
--- a/qanary-component-QB-GAnswerWrapper/pom.xml
+++ b/qanary-component-QB-GAnswerWrapper/pom.xml
@@ -10,7 +10,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.6.7
+ 2.7.0
@@ -49,6 +49,7 @@
+
org.springframework.boot
spring-boot-starter-web
diff --git a/qanary-component-QB-QAnswer/pom.xml b/qanary-component-QB-QAnswer/pom.xml
index 215452b48..e4bb94462 100644
--- a/qanary-component-QB-QAnswer/pom.xml
+++ b/qanary-component-QB-QAnswer/pom.xml
@@ -4,7 +4,7 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QB-QAnswer
- 4.0.1
+ 4.1.0
org.springframework.boot
@@ -19,6 +19,7 @@
qanary-component-qb-qanswer
1.4.13
1.7.0
+ [3.8.0,4.0.0)
@@ -27,6 +28,11 @@
qa.component
${qanary.version}
+
+ eu.wdaqua.qanary
+ qa.commons
+ ${qanary.commons.version}
+
org.springframework.boot
spring-boot-starter-web
@@ -130,4 +136,4 @@
-
+
\ No newline at end of file
diff --git a/qanary-component-QB-QAnswer/src/main/java/eu/wdaqua/qanary/component/qanswer/qb/QAnswerQueryBuilderAndSparqlResultFetcher.java b/qanary-component-QB-QAnswer/src/main/java/eu/wdaqua/qanary/component/qanswer/qb/QAnswerQueryBuilderAndSparqlResultFetcher.java
index 9bac1f425..585ecd8f8 100644
--- a/qanary-component-QB-QAnswer/src/main/java/eu/wdaqua/qanary/component/qanswer/qb/QAnswerQueryBuilderAndSparqlResultFetcher.java
+++ b/qanary-component-QB-QAnswer/src/main/java/eu/wdaqua/qanary/component/qanswer/qb/QAnswerQueryBuilderAndSparqlResultFetcher.java
@@ -56,7 +56,7 @@ public class QAnswerQueryBuilderAndSparqlResultFetcher extends QanaryComponent {
private String langDefault;
private String knowledgeBaseDefault;
private String userDefault;
- private final String FILENAME_GET_ANNOTATED_ENTITIES = "/queries/get_annotated_entities.rq";
+ private final String FILENAME_GET_ANNOTATED_ENTITIES = "/queries/select_all_annotationsWithSelectorAndPosition.rq";
public QAnswerQueryBuilderAndSparqlResultFetcher( //
float threshold, //
@@ -205,8 +205,8 @@ protected List getNamedEntitiesOfQuestion(QanaryQuestion my
LinkedList namedEntities = new LinkedList<>();
QuerySolutionMap bindingsForSelectAnnotations = new QuerySolutionMap();
- bindingsForSelectAnnotations.add("GRAPH", ResourceFactory.createResource(myQanaryQuestion.getOutGraph().toASCIIString()));
- bindingsForSelectAnnotations.add("QUESTION_URI", ResourceFactory.createResource(myQanaryQuestion.getUri().toASCIIString()));
+ bindingsForSelectAnnotations.add("graph", ResourceFactory.createResource(myQanaryQuestion.getOutGraph().toASCIIString()));
+ bindingsForSelectAnnotations.add("hasSource", ResourceFactory.createResource(myQanaryQuestion.getUri().toASCIIString()));
// get the template of the SELECT query
String sparqlGetAnnotations = this.loadQueryFromFile(FILENAME_GET_ANNOTATED_ENTITIES, bindingsForSelectAnnotations);
@@ -226,10 +226,10 @@ protected List getNamedEntitiesOfQuestion(QanaryQuestion my
end = tupel.get("end").asLiteral().getInt();
score = null;
- if (tupel.contains("annotationScore")) {
- score = tupel.get("annotationScore").asLiteral().getFloat();
+ if (tupel.contains("score")) {
+ score = tupel.get("score").asLiteral().getFloat();
}
- URI entityResource = new URI(tupel.get("entityResource").asResource().getURI());
+ URI entityResource = new URI(tupel.get("hasBody").asResource().getURI());
if (score == null || score >= threshold) {
namedEntities.add(new NamedEntity(entityResource, start, end, score));
diff --git a/qanary-component-QB-QAnswer/src/main/resources/queries/get_annotated_entities.rq b/qanary-component-QB-QAnswer/src/main/resources/queries/get_annotated_entities.rq
deleted file mode 100644
index b00a27a95..000000000
--- a/qanary-component-QB-QAnswer/src/main/resources/queries/get_annotated_entities.rq
+++ /dev/null
@@ -1,18 +0,0 @@
-PREFIX dbr:
-PREFIX oa:
-PREFIX qa:
-PREFIX rdf:
-SELECT ?entityResource ?annotationScore ?start ?end
-FROM ?GRAPH
-WHERE {
- ?annotation oa:hasBody ?entityResource .
- ?annotation oa:hasTarget ?target .
- ?target oa:hasSource ?QUESTION_URI .
- ?target oa:hasSelector ?textSelector .
- ?textSelector rdf:type oa:TextPositionSelector .
- ?textSelector oa:start ?start .
- ?textSelector oa:end ?end .
- OPTIONAL {
- ?annotation qa:score ?annotationScore . # we cannot be sure that a score is provided
- }
-}
\ No newline at end of file
diff --git a/qanary-component-QB-SimpleRealNameOfSuperHero/pom.xml b/qanary-component-QB-SimpleRealNameOfSuperHero/pom.xml
index bf5d5b32a..1e4b2af0f 100644
--- a/qanary-component-QB-SimpleRealNameOfSuperHero/pom.xml
+++ b/qanary-component-QB-SimpleRealNameOfSuperHero/pom.xml
@@ -5,8 +5,7 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QB-SimpleRealNameOfSuperHero
- 3.1.8
-
+ 3.2.0
org.springframework.boot
spring-boot-starter-parent
@@ -34,6 +33,11 @@
+
+ eu.wdaqua.qanary
+ qa.commons
+ [3.5.4,4.0.0]
+
org.apache.logging.log4j
log4j-to-slf4j
diff --git a/qanary-component-QB-SimpleRealNameOfSuperHero/src/main/java/eu/wdaqua/qanary/component/simplerealnameofsuperhero/qb/QueryBuilderSimpleRealNameOfSuperHero.java b/qanary-component-QB-SimpleRealNameOfSuperHero/src/main/java/eu/wdaqua/qanary/component/simplerealnameofsuperhero/qb/QueryBuilderSimpleRealNameOfSuperHero.java
index 6c62c9123..0c0341001 100644
--- a/qanary-component-QB-SimpleRealNameOfSuperHero/src/main/java/eu/wdaqua/qanary/component/simplerealnameofsuperhero/qb/QueryBuilderSimpleRealNameOfSuperHero.java
+++ b/qanary-component-QB-SimpleRealNameOfSuperHero/src/main/java/eu/wdaqua/qanary/component/simplerealnameofsuperhero/qb/QueryBuilderSimpleRealNameOfSuperHero.java
@@ -43,7 +43,7 @@ public class QueryBuilderSimpleRealNameOfSuperHero extends QanaryComponent {
private String supportedQuestionPrefix = "What is the real name of ";
- private String FILENAME_GET_ANNOTATION_OF_NAMED_ENTITIES = "/queries/get_annotation_of_named_entities.rq";
+ private String FILENAME_GET_ANNOTATION_OF_NAMED_ENTITIES = "/queries/select_all_AnnotationOfInstance.rq";
private String FILENAME_DBPEDIA_QUERY = "/queries/dbpedia_query.rq";
private String FILENAME_INSERT_ANNOTATION = "/queries/insert_one_annotation.rq";
@@ -93,8 +93,8 @@ public QanaryMessage process(QanaryMessage myQanaryMessage) throws Exception {
QuerySolutionMap bindingsForGetAnnotationOfNamedEntities = new QuerySolutionMap();
bindingsForGetAnnotationOfNamedEntities.add("graph", ResourceFactory.createResource(myQanaryQuestion.getOutGraph().toASCIIString()));
- bindingsForGetAnnotationOfNamedEntities.add("targetQuestion", ResourceFactory.createResource(myQanaryQuestion.getUri().toASCIIString()));
- bindingsForGetAnnotationOfNamedEntities.add("startValue", ResourceFactory.createTypedLiteral(String.valueOf(supportedQuestionPrefix.length()), XSDDatatype.XSDnonNegativeInteger));
+ bindingsForGetAnnotationOfNamedEntities.add("hasSource", ResourceFactory.createResource(myQanaryQuestion.getUri().toASCIIString()));
+ bindingsForGetAnnotationOfNamedEntities.add("start", ResourceFactory.createTypedLiteral(String.valueOf(supportedQuestionPrefix.length()), XSDDatatype.XSDnonNegativeInteger));
// get the template of the INSERT query
String sparqlGetAnnotation = this.loadQueryFromFile(FILENAME_GET_ANNOTATION_OF_NAMED_ENTITIES, bindingsForGetAnnotationOfNamedEntities);
@@ -105,7 +105,7 @@ public QanaryMessage process(QanaryMessage myQanaryMessage) throws Exception {
QuerySolution tupel = resultset.next();
int start = tupel.get("start").asLiteral().getInt();
int end = tupel.get("end").asLiteral().getInt();
- String dbpediaResource = tupel.get("dbpediaResource").toString();
+ String dbpediaResource = tupel.get("hasBody").toString();
logger.warn("found matching resource <{}> at ({},{})", dbpediaResource, start, end);
// create the DBpedia SPARQL select query to compute the answer
diff --git a/qanary-component-QB-SimpleRealNameOfSuperHero/src/main/resources/queries/get_annotation_of_named_entities.rq b/qanary-component-QB-SimpleRealNameOfSuperHero/src/main/resources/queries/get_annotation_of_named_entities.rq
deleted file mode 100644
index fbe6a3146..000000000
--- a/qanary-component-QB-SimpleRealNameOfSuperHero/src/main/resources/queries/get_annotation_of_named_entities.rq
+++ /dev/null
@@ -1,22 +0,0 @@
-PREFIX dbr:
-PREFIX oa:
-PREFIX qa:
-PREFIX rdf:
-
-SELECT *
-FROM ?graph
-WHERE {
- ?annotation oa:hasBody ?dbpediaResource .
- ?annotation qa:score ?annotationScore .
- ?annotation oa:hasTarget ?target .
- {
- ?target oa:hasSource ?targetQuestion .
- } UNION {
- ?target oa:hasSource .
- }
- ?target oa:hasSelector ?textSelector .
- ?textSelector rdf:type oa:TextPositionSelector .
- ?textSelector oa:start ?start .
- ?textSelector oa:end ?end .
- FILTER(?start = ?startValue) .
-}
\ No newline at end of file
diff --git a/qanary-component-QB-Sina/pom.xml b/qanary-component-QB-Sina/pom.xml
index 250a81f24..99916bb2f 100644
--- a/qanary-component-QB-Sina/pom.xml
+++ b/qanary-component-QB-Sina/pom.xml
@@ -5,8 +5,7 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QB-Sina
- 3.2.5
-
+ 3.3.1
org.springframework.boot
spring-boot-starter-parent
@@ -33,6 +32,11 @@
+
+ eu.wdaqua.qanary
+ qa.commons
+ [3.5.4,4.0.0]
+
org.apache.logging.log4j
log4j-to-slf4j
diff --git a/qanary-component-QB-Sina/src/main/java/eu/wdaqua/qanary/component/sina/qb/SINA.java b/qanary-component-QB-Sina/src/main/java/eu/wdaqua/qanary/component/sina/qb/SINA.java
index 336f9c558..1ba5c2c8d 100644
--- a/qanary-component-QB-Sina/src/main/java/eu/wdaqua/qanary/component/sina/qb/SINA.java
+++ b/qanary-component-QB-Sina/src/main/java/eu/wdaqua/qanary/component/sina/qb/SINA.java
@@ -44,9 +44,9 @@ public class SINA extends QanaryComponent {
@Value("${spring.application.name}")
private String applicationName;
- private String FILENAME_GET_ENTITIES = "/queries/get_entities.rq";
- private String FILENAME_GET_RELATIONS = "/queries/get_relations.rq";
- private String FILENAME_GET_CLASSES = "/queries/get_classes.rq";
+ private String FILENAME_GET_ENTITIES = "/queries/select_all_AnnotationOfInstance.rq";
+ private String FILENAME_GET_RELATIONS = "/queries/select_all_AnnotationOfRelation.rq";
+ private String FILENAME_GET_CLASSES = "/queries/select_all_AnnotationOfClass.rq";
private String FILENAME_INSERT_ANNOTATION = "/queries/insert_one_annotation.rq";
public SINA(@Value("${sina.jarfilelocation}") String sinaJarFileLocation) throws IOException, InterruptedException {
@@ -121,7 +121,7 @@ private StringBuilder fetchEntities(final QanaryQuestion qanaryQuestion,
while (entitiesResultSet.hasNext()) {
QuerySolution s = entitiesResultSet.next();
- final Entity entity = new Entity(s.getResource("uri").getURI(), s.getLiteral("start").getInt(), s.getLiteral("end").getInt());
+ final Entity entity = new Entity(s.getResource("hasBody").getURI(), s.getLiteral("start").getInt(), s.getLiteral("end").getInt());
argument.append(entity.uri + ", ");
logger.info("uri:{} start:{} end:{}", entity.uri, entity.begin, entity.end);
@@ -132,7 +132,7 @@ private StringBuilder fetchEntities(final QanaryQuestion qanaryQuestion,
private StringBuilder fetchRelations(final QanaryQuestion qanaryQuestion, final QanaryUtils qanaryUtils) throws SparqlQueryFailed, QanaryExceptionNoOrMultipleQuestions, URISyntaxException, IOException {
QuerySolutionMap bindingsForGetRelations = new QuerySolutionMap();
bindingsForGetRelations.add("graph", ResourceFactory.createResource(qanaryQuestion.getInGraph().toASCIIString()));
- bindingsForGetRelations.add("targetQuestion", ResourceFactory.createResource(qanaryQuestion.getUri().toASCIIString()));
+ bindingsForGetRelations.add("hasSource", ResourceFactory.createResource(qanaryQuestion.getUri().toASCIIString()));
String sparqlGetRelations = this.loadQueryFromFile(FILENAME_GET_RELATIONS, bindingsForGetRelations);
logger.info("fetchRelations for given question with query {}", sparqlGetRelations);
@@ -142,7 +142,7 @@ private StringBuilder fetchRelations(final QanaryQuestion qanaryQuestion
while (relationResultSet.hasNext()) {
QuerySolution s = relationResultSet.next();
- final Entity entity = new Entity(s.getResource("relationurl").getURI());
+ final Entity entity = new Entity(s.getResource("hasBody").getURI());
// entityTemp2.begin = s.getLiteral("start").getInt();
// entityTemp2.end = s.getLiteral("end").getInt();
@@ -156,7 +156,7 @@ private StringBuilder fetchRelations(final QanaryQuestion qanaryQuestion
private StringBuilder fetchClasses(final QanaryQuestion qanaryQuestion, final QanaryUtils qanaryUtils) throws SparqlQueryFailed, QanaryExceptionNoOrMultipleQuestions, URISyntaxException, IOException {
QuerySolutionMap bindingsForGetClasses = new QuerySolutionMap();
bindingsForGetClasses.add("graph", ResourceFactory.createResource(qanaryQuestion.getInGraph().toASCIIString()));
- bindingsForGetClasses.add("targetQuestion", ResourceFactory.createResource(qanaryQuestion.getUri().toASCIIString()));
+ bindingsForGetClasses.add("hasSource", ResourceFactory.createResource(qanaryQuestion.getUri().toASCIIString()));
String sparqlGetClasses = this.loadQueryFromFile(FILENAME_GET_CLASSES, bindingsForGetClasses);
logger.info("fetchClasses for given question with query {}", sparqlGetClasses);
@@ -164,9 +164,9 @@ private StringBuilder fetchClasses(final QanaryQuestion qanaryQuestion,
final StringBuilder argument = new StringBuilder();
while (classResultSet.hasNext()) {
QuerySolution s = classResultSet.next();
- Entity entityTemp3 = new Entity(s.getResource("uri").getURI());
+ Entity entityTemp3 = new Entity(s.getResource("hasBody").getURI());
argument.append(entityTemp3.uri + ", ");
- logger.info("uri info {}", s.getResource("uri").getURI());
+ logger.info("uri info {}", s.getResource("hasBody").getURI());
}
return argument;
}
diff --git a/qanary-component-QB-Sina/src/main/resources/queries/get_classes.rq b/qanary-component-QB-Sina/src/main/resources/queries/get_classes.rq
deleted file mode 100644
index adcf854d9..000000000
--- a/qanary-component-QB-Sina/src/main/resources/queries/get_classes.rq
+++ /dev/null
@@ -1,16 +0,0 @@
-PREFIX qa:
-PREFIX oa:
-PREFIX xsd:
-
-SELECT ?uri
-FROM ?graph
-WHERE {
- ?a a qa:AnnotationOfClass .
- ?a oa:hasTarget [
- a oa:SpecificResource;
- oa:hasSource ?targetQuestion;
- ] ;
- oa:hasBody ?uri ;
- oa:annotatedAt ?time
-}
-ORDER BY ?start
\ No newline at end of file
diff --git a/qanary-component-QB-Sina/src/main/resources/queries/get_entities.rq b/qanary-component-QB-Sina/src/main/resources/queries/get_entities.rq
deleted file mode 100644
index a0b073e00..000000000
--- a/qanary-component-QB-Sina/src/main/resources/queries/get_entities.rq
+++ /dev/null
@@ -1,19 +0,0 @@
-PREFIX qa:
-PREFIX oa:
-PREFIX xsd:
-
-SELECT ?start ?end ?uri
-FROM ?graph
-WHERE {
- ?a a qa:AnnotationOfInstance .
- ?a oa:hasTarget [
- a oa:SpecificResource;
- oa:hasSource ?q;
- oa:hasSelector [
- a oa:TextPositionSelector ;
- oa:start ?start ;
- oa:end ?end
- ]
- ] .
- ?a oa:hasBody ?uri ;
-}
\ No newline at end of file
diff --git a/qanary-component-QB-Sina/src/main/resources/queries/get_relations.rq b/qanary-component-QB-Sina/src/main/resources/queries/get_relations.rq
deleted file mode 100644
index 996a1f49e..000000000
--- a/qanary-component-QB-Sina/src/main/resources/queries/get_relations.rq
+++ /dev/null
@@ -1,16 +0,0 @@
-PREFIX qa:
-PREFIX oa:
-PREFIX xsd:
-
-SELECT ?relationurl
-FROM ?graph
-WHERE {
- ?a a qa:AnnotationOfRelation .
- ?a oa:hasTarget [
- a oa:SpecificResource;
- oa:hasSource ?targetQuestion;
- ] ;
- oa:hasBody ?relationurl ;
- oa:annotatedAt ?time
-}
-ORDER BY ?start
\ No newline at end of file
diff --git a/qanary-component-QBE-QAnswer/pom.xml b/qanary-component-QBE-QAnswer/pom.xml
index ba4f4398a..2da3224e9 100644
--- a/qanary-component-QBE-QAnswer/pom.xml
+++ b/qanary-component-QBE-QAnswer/pom.xml
@@ -5,8 +5,7 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QBE-QAnswer
- 3.3.3
-
+ 3.4.0
org.springframework.boot
spring-boot-starter-parent
diff --git a/qanary-component-QBE-QAnswer/src/main/java/eu/wdaqua/qanary/component/qanswer/qbe/QAnswerQueryBuilderAndExecutor.java b/qanary-component-QBE-QAnswer/src/main/java/eu/wdaqua/qanary/component/qanswer/qbe/QAnswerQueryBuilderAndExecutor.java
index 5b7655ed0..568fa8fca 100644
--- a/qanary-component-QBE-QAnswer/src/main/java/eu/wdaqua/qanary/component/qanswer/qbe/QAnswerQueryBuilderAndExecutor.java
+++ b/qanary-component-QBE-QAnswer/src/main/java/eu/wdaqua/qanary/component/qanswer/qbe/QAnswerQueryBuilderAndExecutor.java
@@ -12,8 +12,14 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import eu.wdaqua.qanary.commons.triplestoreconnectors.QanaryTripleStoreConnector;
+import org.apache.jena.datatypes.RDFDatatype;
+import org.apache.jena.datatypes.xsd.XSDDatatype;
import org.apache.jena.query.QuerySolution;
+import org.apache.jena.query.QuerySolutionMap;
import org.apache.jena.query.ResultSet;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.vocabulary.RDF;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -61,6 +67,9 @@ public class QAnswerQueryBuilderAndExecutor extends QanaryComponent {
private String knowledgeBaseDefault;
private String userDefault;
+ private final String SELECT_ALL_ANNOTATION_OF_INSTANCE = "/queries/select_all_AnnotationOfInstance.rq";
+ private final String INSERT_ONE_ANNOTATION_OF_ANSWER_SPARQL = "/queries/insert_one_AnnotationOfAnswerSPARQL.rq";
+
public QAnswerQueryBuilderAndExecutor( //
float threshold, //
@Qualifier("langDefault") String langDefault, //
@@ -84,6 +93,9 @@ public QAnswerQueryBuilderAndExecutor( //
assert !(userDefault == null || userDefault.trim().isEmpty()) : //
"userDefault cannot be null or empty: " + userDefault;
+ QanaryTripleStoreConnector.guardNonEmptyFileFromResources(SELECT_ALL_ANNOTATION_OF_INSTANCE);
+ QanaryTripleStoreConnector.guardNonEmptyFileFromResources(INSERT_ONE_ANNOTATION_OF_ANSWER_SPARQL);
+
this.threshold = threshold;
this.qanswerEndpoint = qanswerEndpoint;
this.langDefault = langDefault;
@@ -213,26 +225,9 @@ protected List getNamedEntitiesOfQuestion(QanaryQuestion my
throws Exception {
LinkedList namedEntities = new LinkedList<>();
- // TODO: Move to qanary.commons and use template queries
- String sparqlGetAnnotation = "" //
- + "PREFIX dbr: \n" //
- + "PREFIX oa: \n" //
- + "PREFIX qa: \n" //
- + "PREFIX rdf: \n" //
- + "SELECT ?entityResource ?annotationScore ?start ?end " //
- + "FROM <" + inGraph.toString() + "> \n" //
- + "WHERE { \n" //
- + " ?annotation oa:hasBody ?entityResource .\n" //
- + " ?annotation oa:hasTarget ?target .\n" //
- + " ?target oa:hasSource <" + myQanaryQuestion.getUri().toString() + "> .\n" //
- + " ?target oa:hasSelector ?textSelector .\n" //
- + " ?textSelector rdf:type oa:TextPositionSelector .\n" //
- + " ?textSelector oa:start ?start .\n" //
- + " ?textSelector oa:end ?end .\n" //
- + " OPTIONAL { \n" //
- + " ?annotation qa:score ?annotationScore . \n" // we cannot be sure that a score is provided
- + " }\n" //
- + "}\n";
+ QuerySolutionMap bindingsForGetAnnotationOfNamedEntities = new QuerySolutionMap();
+ bindingsForGetAnnotationOfNamedEntities.add("graph", ResourceFactory.createResource(inGraph.toASCIIString()));
+ String sparqlGetAnnotation = QanaryTripleStoreConnector.readFileFromResourcesWithMap(SELECT_ALL_ANNOTATION_OF_INSTANCE, bindingsForGetAnnotationOfNamedEntities);
boolean ignored = false;
Float score;
@@ -247,10 +242,10 @@ protected List getNamedEntitiesOfQuestion(QanaryQuestion my
end = tupel.get("end").asLiteral().getInt();
score = null;
- if (tupel.contains("annotationScore")) {
- score = tupel.get("annotationScore").asLiteral().getFloat();
+ if (tupel.contains("score")) {
+ score = tupel.get("score").asLiteral().getFloat();
}
- URI entityResource = new URI(tupel.get("entityResource").asResource().getURI());
+ URI entityResource = new URI(tupel.get("hasBody").asResource().getURI());
if (score == null || score >= threshold) {
namedEntities.add(new NamedEntity(entityResource, start, end, score));
@@ -370,6 +365,19 @@ private String getSparqlInsertQuery(QanaryQuestion myQanaryQuestion, QAn
counter++;
}
+ QuerySolutionMap bindingsForInsert = new QuerySolutionMap();
+ bindingsForInsert.add("service", ResourceFactory.createResource(this.applicationName));
+ bindingsForInsert.add("question", ResourceFactory.createStringLiteral(myQanaryQuestion.getUri().toASCIIString()));
+ bindingsForInsert.add("score", ResourceFactory.createTypedLiteral(String.valueOf(result.getConfidence()), XSDDatatype.XSDdouble));
+ bindingsForInsert.add("improvedQuestionText", ResourceFactory.createStringLiteral(improvedQuestion));
+ bindingsForInsert.add("sparqlQueryString", ResourceFactory.createStringLiteral(createdAnswerSparqlQuery.replace("\"", "\\\"") + "\"") );
+ bindingsForInsert.add("answerDataType", ResourceFactory.createResource(String.valueOf(result.getDatatype())));
+ bindingsForInsert.add("knowledgeGraph", ResourceFactory.createResource(String.valueOf(knowledgeGraphEndpoints.get(usedKnowledgeGraph))));
+ bindingsForInsert.add("json", ResourceFactory.createStringLiteral(
+ result.getJsonString().replace("\"", "\\\"").replace("\\\\", "\\\\\\").replace("\\n", "").replace("\\t", "").replace("\\/", "/")
+ ));
+
+
// TODO: Move to qanary.commons and use template queries
String sparql = "" //
+ "PREFIX qa: \n" //
diff --git a/qanary-component-QBE-SimpleQueryBuilderAndExecutor/pom.xml b/qanary-component-QBE-SimpleQueryBuilderAndExecutor/pom.xml
index 66182d096..570df477a 100644
--- a/qanary-component-QBE-SimpleQueryBuilderAndExecutor/pom.xml
+++ b/qanary-component-QBE-SimpleQueryBuilderAndExecutor/pom.xml
@@ -5,8 +5,7 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-QBE-SimpleQueryBuilderAndExecutor
- 3.2.4
-
+ 3.3.0
org.springframework.boot
spring-boot-starter-parent
@@ -27,6 +26,11 @@
qa.component
${qanary.version}
+
+ eu.wdaqua.qanary
+ qa.commons
+ [3.5.4,4.0.0]
+
org.springframework.boot
spring-boot-starter-web
diff --git a/qanary-component-QBE-SimpleQueryBuilderAndExecutor/src/main/java/eu/wdaqua/qanary/component/simplequerybuilderandexecutor/qbe/QueryBuilder.java b/qanary-component-QBE-SimpleQueryBuilderAndExecutor/src/main/java/eu/wdaqua/qanary/component/simplequerybuilderandexecutor/qbe/QueryBuilder.java
index fa83a6200..0ad125475 100644
--- a/qanary-component-QBE-SimpleQueryBuilderAndExecutor/src/main/java/eu/wdaqua/qanary/component/simplequerybuilderandexecutor/qbe/QueryBuilder.java
+++ b/qanary-component-QBE-SimpleQueryBuilderAndExecutor/src/main/java/eu/wdaqua/qanary/component/simplequerybuilderandexecutor/qbe/QueryBuilder.java
@@ -34,9 +34,9 @@ public class QueryBuilder extends QanaryComponent {
@Value("${dbpedia.sparql.endpoint:http://dbpedia.org/sparql}")
String dbpediaSparqlEndpoint;
- private String FILENAME_SELECT_CLASSES = "/queries/select_classes.rq";
- private String FILENAME_SELECT_PROPERTIES = "/queries/select_properties.rq";
- private String FILENAME_SELECT_ENTITIES = "/queries/select_entities.rq";
+ private String FILENAME_SELECT_CLASSES = "/queries/select_all_AnnotationOfClass.rq";
+ private String FILENAME_SELECT_PROPERTIES = "/queries/select_all_AnnotationOfRelation.rq";
+ private String FILENAME_SELECT_ENTITIES = "/queries/select_all_AnnotationOfInstance.rq";
private String FILENAME_INSERT_SPARQL = "/queries/insert_sparql.rq";
private String FILENAME_INSERT_JSON = "/queries/insert_json.rq";
@@ -293,8 +293,8 @@ private List getClassesFromQanaryKB(QanaryUtils myQanaryUtils, QanaryQue
while (r.hasNext()) {
QuerySolution s = r.next();
- classes.add(s.getResource("uri").getURI());
- logger.info("class: {}", s.getResource("uri").getURI());
+ classes.add(s.getResource("hasBody").getURI());
+ logger.info("class: {}", s.getResource("hasBody").getURI());
}
return classes;
@@ -321,8 +321,8 @@ private List getPropertiesFromQanaryKB(QanaryUtils myQanaryUtils, Qanary
while (r.hasNext()) {
QuerySolution s = r.next();
- properties.add(s.getResource("uri").getURI());
- logger.info("property: {}", s.getResource("uri").getURI());
+ properties.add(s.getResource("hasBody").getURI());
+ logger.info("property: {}", s.getResource("hasBody").getURI());
}
return properties;
}
@@ -348,8 +348,8 @@ private List getEntitiesFromQanaryKB(QanaryUtils myQanaryUtils, QanaryQu
while (r.hasNext()) {
QuerySolution s = r.next();
- entities.add(s.getResource("uri").getURI());
- logger.info("entity: {}", s.getResource("uri").getURI());
+ entities.add(s.getResource("hasBody").getURI());
+ logger.info("entity: {}", s.getResource("hasBody").getURI());
}
return entities;
}
diff --git a/qanary-component-QE-Wikidata/pom.xml b/qanary-component-QE-Wikidata/pom.xml
index f9ea28f79..3ce557726 100644
--- a/qanary-component-QE-Wikidata/pom.xml
+++ b/qanary-component-QE-Wikidata/pom.xml
@@ -6,7 +6,6 @@
eu.wdaqua.qanary.component
qanary-component-QE-Wikidata
3.1.9
-
org.springframework.boot
spring-boot-starter-parent
@@ -34,6 +33,11 @@
+
+ eu.wdaqua.qanary
+ qa.commons
+ [3.5.4,4.0.0]
+
org.apache.logging.log4j
log4j-to-slf4j
diff --git a/qanary-component-QE-Wikidata/src/main/java/eu/wdaqua/component/wikidata/qe/QueryExecuter.java b/qanary-component-QE-Wikidata/src/main/java/eu/wdaqua/component/wikidata/qe/QueryExecuter.java
index 77afc934d..bc1aec9f5 100644
--- a/qanary-component-QE-Wikidata/src/main/java/eu/wdaqua/component/wikidata/qe/QueryExecuter.java
+++ b/qanary-component-QE-Wikidata/src/main/java/eu/wdaqua/component/wikidata/qe/QueryExecuter.java
@@ -83,7 +83,6 @@ public String getAnswersFromWikidata(String queryString) {
/**
* Create a query to store the computed information in the Qanary triplestore
*
- * @param myQanaryQuestion the QanaryQuestion currently being processed
* @param answerJson the JSON returned by Wikidata
* @return sparql
* @throws QanaryExceptionNoOrMultipleQuestions
diff --git a/qanary-component-RD-DiambiguationProperty-OKBQA/pom.xml b/qanary-component-RD-DiambiguationProperty-OKBQA/pom.xml
index 241fbc111..048c096bb 100644
--- a/qanary-component-RD-DiambiguationProperty-OKBQA/pom.xml
+++ b/qanary-component-RD-DiambiguationProperty-OKBQA/pom.xml
@@ -5,8 +5,7 @@
4.0.0
eu.wdaqua.qanary.component
qanary-component-RD-DiambiguationProperty-OKBQA
- 3.1.2
-
+ 3.2.0
org.springframework.boot
spring-boot-starter-parent
diff --git a/qanary-component-RD-DiambiguationProperty-OKBQA/src/main/java/eu/wdaqua/qanary/component/diambiguationproperty/rd/DiambiguationProperty.java b/qanary-component-RD-DiambiguationProperty-OKBQA/src/main/java/eu/wdaqua/qanary/component/diambiguationproperty/rd/DiambiguationProperty.java
index 05fdf3ac8..fbecaee65 100644
--- a/qanary-component-RD-DiambiguationProperty-OKBQA/src/main/java/eu/wdaqua/qanary/component/diambiguationproperty/rd/DiambiguationProperty.java
+++ b/qanary-component-RD-DiambiguationProperty-OKBQA/src/main/java/eu/wdaqua/qanary/component/diambiguationproperty/rd/DiambiguationProperty.java
@@ -2,10 +2,13 @@
import eu.wdaqua.qanary.commons.QanaryMessage;
import eu.wdaqua.qanary.commons.QanaryUtils;
+import eu.wdaqua.qanary.commons.triplestoreconnectors.QanaryTripleStoreConnector;
import eu.wdaqua.qanary.component.QanaryComponent;
import eu.wdaqua.qanary.exceptions.SparqlQueryFailed;
import org.apache.http.client.ClientProtocolException;
+import org.apache.jena.query.QuerySolutionMap;
import org.apache.jena.query.ResultSet;
+import org.apache.jena.rdf.model.ResourceFactory;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
@@ -39,9 +42,11 @@ public class DiambiguationProperty extends QanaryComponent {
private static final Logger logger = LoggerFactory.getLogger(DiambiguationProperty.class);
private final String applicationName;
+ private final String QUERY_SELECT_ALL_QUESTION_LANGUAGE = "/queries/select_all_AnnotationOfQuestionLanguage.rq";
public DiambiguationProperty(@Value("${spring.application.name}") final String applicationName) {
this.applicationName = applicationName;
+ QanaryTripleStoreConnector.guardNonEmptyFileFromResources(QUERY_SELECT_ALL_QUESTION_LANGUAGE);
}
public static String runCurlGetWithParam(String weburl, String data, String contentType)
@@ -125,7 +130,7 @@ public static String runCurlPOSTWithParam(String weburl, String data, String con
* component
*/
@Override
- public QanaryMessage process(QanaryMessage myQanaryMessage) throws SparqlQueryFailed {
+ public QanaryMessage process(QanaryMessage myQanaryMessage) throws SparqlQueryFailed, IOException {
long startTime = System.currentTimeMillis();
//org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.OFF);
logger.info("process: {}", myQanaryMessage);
@@ -159,14 +164,10 @@ public QanaryMessage process(QanaryMessage myQanaryMessage) throws SparqlQueryFa
// the below mentioned SPARQL query to fetch annotation of language from
// triplestore
- String questionlang = "PREFIX qa: " //
- + "SELECT ?lang " + "FROM <" + namedGraph + "> " //
- + "WHERE {?q a qa:Question ." //
- + " ?anno ?q ." //
- + " ?anno ?lang ." //
- + " ?anno a qa:AnnotationOfQuestionLanguage }";
- // Now fetch the language, in our case it is "en".
- ResultSet result1 = myQanaryUtils.selectFromTripleStore(questionlang, endpoint);
+ QuerySolutionMap bindingsForQuery = new QuerySolutionMap();
+ bindingsForQuery.add("graph", ResourceFactory.createResource(namedGraph));
+ String query = QanaryTripleStoreConnector.readFileFromResourcesWithMap(QUERY_SELECT_ALL_QUESTION_LANGUAGE, bindingsForQuery);
+ ResultSet result1 = myQanaryUtils.getQanaryTripleStoreConnector().select(query); // ResultSet currently not used
String language1 = "en";
logger.info("Language of the Question: {}", language1);
@@ -238,7 +239,7 @@ public QanaryMessage process(QanaryMessage myQanaryMessage) throws SparqlQueryFa
Map urlsAndScore = new HashMap();
JSONObject tempObject = (JSONObject) iTypes.next();
String urls = (String) tempObject.get("value");
- double score = (double) tempObject.get("score");
+ double score = tempObject.getNumber("score").doubleValue();
var = (String) tempObject.get("var");
if (allProperties.size() > 0 && allProperties.containsKey(var)) {
diff --git a/qanary-component-REL-Python-Falcon/component/rel_falcon.py b/qanary-component-REL-Python-Falcon/component/rel_falcon.py
index 7048b295d..7431716b5 100644
--- a/qanary-component-REL-Python-Falcon/component/rel_falcon.py
+++ b/qanary-component-REL-Python-Falcon/component/rel_falcon.py
@@ -70,7 +70,7 @@ async def qanary_service(request: Request):
""".format(
uuid=triplestore_ingraph_uuid,
question_uri=question_uri,
- component="qanary:" + SERVICE_NAME_COMPONENT.replace(" ", "-"),
+ component="urn:qanary:" + SERVICE_NAME_COMPONENT.replace(" ", "-"),
relation=relation["URI"])
insert_into_triplestore(triplestore_endpoint_url,
diff --git a/service_config/build_images.sh b/service_config/build_images.sh
index f1729e74e..4b85746b2 100755
--- a/service_config/build_images.sh
+++ b/service_config/build_images.sh
@@ -89,7 +89,7 @@ then
exit 4 # stop if maven build fails
fi
-docker image ls | grep -oP "^qanary/qanary-component.*\.[0-9] " > images.temp
+docker image ls | grep -oP "^qanary/qanary-component.*\.[0-9]+ " > images.temp
# read image list
images=$(cat images.temp)
diff --git a/service_config/service_config.json b/service_config/service_config.json
index f7be000e2..b8175481f 100644
--- a/service_config/service_config.json
+++ b/service_config/service_config.json
@@ -48,7 +48,7 @@
{
"mode": "dockerfile",
"port": "40152:40152",
- "image": "qanary/qanary-component-qb-birthdatawikidata",
+ "image": "qanary/qanary-component-qb-birthdata-wikidata",
"tag": "latest",
"files": {
".env": "qb-birthdatawikidata"
@@ -152,7 +152,7 @@
"2": "qanary-qanary-component-ned-opentapioca",
"3": "qanary-qanary-component-ner-comiccharacternamesimplenamedentityrecognizer",
"4": "qanary-qanary-component-qc-answertypeclassifier",
- "5": "qanary-qanary-component-qb-birthdatawikidata",
+ "5": "qanary-qanary-component-qb-birthdata-wikidata",
"6": "qanary-qanary-component-qb-comiccharacteralteregosimpledbpedia",
"7": "qanary-qanary-component-qb-qanswer",
"8": "qanary-qanary-component-qbe-qanswer",
@@ -164,4 +164,4 @@
"14": "qanary-qanary-component-kg2kg-translateannotationsofinstance",
"15": "qanary-qanary-component-ned-openai-gpt"
}
-}
\ No newline at end of file
+}