Skip to content

Latest commit

 

History

History
112 lines (87 loc) · 3.55 KB

File metadata and controls

112 lines (87 loc) · 3.55 KB

QB SINA component

Intention

Receives 3 data structures: AnnotationOfClass, AnnotationOfRelation, and AnnotationOfInstance.

Behavior

Depending on the availability of them, generates a query and stores it.

As a Qanary component, it reads the question and the annotations produced by upstream components from the Qanary triplestore (the shared process memory), performs its task — build a formal (SPARQL) query from the question and its annotations — and writes the result back as standard Qanary (Web Annotation / qa:) annotations. See Input specification / Output specification below for the exact annotation contract.

Characteristics

Implementation

  • Language: Java (JDK 21).

  • Major frameworks: Spring Boot 3.5 (spring-boot-starter-parent); the Qanary component framework eu.wdaqua.qanary:qa.component 4.0.0 (transitively Spring Boot Admin client + Apache Jena 5).

  • Main component class: src/main/java/eu/wdaqua/qanary/component/sina/qb/SINA.java (extends eu.wdaqua.qanary.component.QanaryComponent).

  • Tests: 3 test class(es) under src/test/java/ (QanaryServiceControllerTest.java, SinaTest.java, SwaggerUiAvailabilityTest.java).

Build and run

Targets the current Qanary framework 4.0.0 (Spring Boot 3, Java 21). Install the framework first (mvn install in the Qanary repository), then build with JDK 21:

JAVA_HOME=/path/to/jdk21 mvn clean package
docker build --build-arg JAR_FILE=target/qanary-component-qb-sina.jar -t qanary/qanary-component-qb-sina .

Input specification

Comment: qa:AnnotationOfInstance does not have oa:annotatedAt

@prefix qa: <http://www.wdaqua.eu/qa#> .
@prefix oa: <http://www.w3.org/ns/openannotation/core/> .

<urn:qanary:input> a qa:AnnotationOfClass .
<urn:qanary:input> oa:hasTarget [
        a oa:SpecificResource ;
        oa:hasSource ?q ;
    ];
    oa:hasBody ?uri ;
    oa:annotatedAt "2001-10-26T21:32:52"^^xsd:dateTime .
@prefix qa: <http://www.wdaqua.eu/qa#> .
@prefix oa: <http://www.w3.org/ns/openannotation/core/> .

<urn:qanary:input> a qa:AnnotationOfRelation .
<urn:qanary:input> oa:hasTarget [
        a oa:SpecificResource ;
        oa:hasSource ?q ;
    ];
    oa:hasBody ?uri ;
    oa:annotatedAt "2001-10-26T21:32:52"^^xsd:dateTime .
@prefix qa: <http://www.wdaqua.eu/qa#> .
@prefix oa: <http://www.w3.org/ns/openannotation/core/> .

<urn:qanary:input> a qa:AnnotationOfInstance .
<urn:qanary:input> oa:hasTarget [
    a   oa:SpecificResource;
        oa:hasSource ?q ;
        oa:hasSelector  [
            a oa:TextPositionSelector ;
            oa:start "0"^^xsd:nonNegativeInteger ;
            oa:end  "5"^^xsd:nonNegativeInteger
        ]
    ] .
<urn:qanary:input> oa:hasBody <dbr:Resource> .

Output specification

@prefix qa: <http://www.wdaqua.eu/qa#> .
@prefix oa: <http://www.w3.org/ns/openannotation/core/> .

<urn:qanary:output> a qa:AnnotationOfAnswerSPARQL ;
    oa:hasTarget <urn:qanary:myQanaryQuestion> ;
    oa:hasBody "sparql query" ;
    qa:score "0.5"^^xsd:float ;
    oa:annotatedAt "2001-10-26T21:32:52"^^xsd:dateTime ;
    oa:annotatedBy <urn:qanary:applicationName > .