4.2.2. System-Wide Components

System-wide components in the QALL-ME Framework are WS components which are neither language nor location dependent and which can thus be implemented only once and then be used system-widely. The core framework brings implementations for all system-wide components. These implementations can either be used directly or they can be modified to suit specific needs; the Java source code of all component implementations is freely available (cf. 4.1).

The getLanguage web method tries to determine the language of a given natural language text string. The identified language is represented as a two-letter, lower-case ISO 639-1 alpha-2 language code. Implementations may return “UND” (cf. RFC 3066) as the language code if they absolutely cannot identify the language of the given text, e.g., for an empty input text string. However, this should only be done if really in doubt, not if just unsure. In reverse, the caller of this web method should know this policy and must be aware that 100 % correct results are not always possible in language identification.

Sample request (SOAP body):

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
              xmlns:qal="http://qallme.sf.net/wsdl/qallmeshared.wsdl">
	<qal:string>¿Qué películas puedo ver en el cine Schmelzer Lichtspiele?</qal:string>
</soapenv:Body>

Sample response (SOAP body):

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<languageCode xmlns="http://qallme.sf.net/wsdl/qallmeshared.wsdl">es</languageCode>
</soapenv:Body>

The answerQuestion web method is the main operation of the QAPlanner. It returns an RDF answer graph for a given inquiry consisting of a natural language question string and the spatiotemporal context of the question. If the question cannot be answered for some reason, then an empty RDF graph is returned.

Sample request (SOAP body):

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<qap:inquiry xmlns:qap="http://qallme.sf.net/xsd/qaplanner.xsd"
	             xmlns:qal="http://qallme.sf.net/xsd/qallmeshared.xsd">
		<qap:question>Was für eine Art von Film ist Dreamgirls?</qap:question>
		<qal:spatiotemporalContext>
			<qal:location lat="49.256409" lon="7.042437">DE</qal:location>
			<qal:time>2007-03-18T12:58:21</qal:time>
		</qal:spatiotemporalContext>
	</qap:inquiry>
</soapenv:Body>
As can be seen from the example, the natural language question is given as a simple string. The question context consists of a spatial part and a temporal part. The spatial part is the geocoordinate (latitude and longitude) of the location at which the question was posed. Additionally there may be some string describing the location. It is recommended, however, that this string is the
ISO 3166-1 alpha-2 code of the country where the question was posed; if such a code is present, it will be used if for some reason the given geocoordinate could not be used for determining the country through reverse geocoding. The temporal context part is simply the point in time at which the question was posed.

Sample response (SOAP body):

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<RDFGraph xmlns="http://qallme.dfki.de/xsd/qallmeshared.xsd">
		<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
		         xmlns:qma="http://qallme.fbk.eu/ontology/qallme-answers.owl#"
		         xmlns:qmo="http://qallme.itc.it/ontology/qallme-tourism.owl#">
			<qma:AnswersObject rdf:about="http://qallme.fbk.eu/ontology/qallme-answers.owl#AnswerInstance">
				<qma:hasAnswerValue>
					<rdf:Description rdf:about="http://qallme.itc.it/ontology/qallme-tourism.owl#Genre_musical">
						<qmo:name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">musical</qmo:name>
					</rdf:Description>
				</qma:hasAnswerValue>
				<qma:hasAnswerValue>
					<rdf:Description rdf:about="http://qallme.itc.it/ontology/qallme-tourism.owl#Genre_drama">
						<qmo:name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">drama</qmo:name>
					</rdf:Description>
				</qma:hasAnswerValue>
			</qma:AnswersObject>
			<qmo:Movie rdf:about="http://qallme.itc.it/ontology/qallme-tourism.owl#Movie_DFKI_5934">
				<qmo:hasGenre rdf:resource="http://qallme.itc.it/ontology/qallme-tourism.owl#Genre_musical"/>
				<qmo:name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Dreamgirls</qmo:name>
				<qmo:hasGenre rdf:resource="http://qallme.itc.it/ontology/qallme-tourism.owl#Genre_drama"/>
			</qmo:Movie>
		</rdf:RDF>
	</RDFGraph>
</soapenv:Body>
The structure of the returned answer RDF graph in this example is explained in the description of the demo component implementations section in 4.4.

The setComponent web method tells the QAPlanner to use a given component implementation for QA. The method must be used for initializing the QAPlanner with all component implementations it shall manage. The method may be used again later to replace a certain component implementation with another one. If any part of the request is not valid or if the given WS implementation cannot be invoked, then an IllegalArgumentFault is thrown.

Each component implementation is specified by the URL of its WSDL description (cf. <wsdlURL> in the request). Additionally the caller has to specify which type of component shall be set with the given implementation (cf. <componentID>). This component type is determined by the namespace of the respective component’s WSDL definition. There are three possible ways for writing a request to the setComponent web method; the caller has to choose one of these three based on whether a system-wide component shall be set or a language or location specific component shall be set.

Sample request (SOAP body) for setting a language specific component implementation:

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<qap:ComponentSetupRequest xmlns:qap="http://qallme.sf.net/wsdl/qaplanner.wsdl">
		<componentID>http://qallme.sf.net/wsdl/querygeneration.wsdl</componentID>
		<componentLang>de</componentLang>
		<wsdlURL>http://localhost:8080/qmfdemo/de-querygeneration/QueryGeneratorWS?wsdl</wsdlURL>
	</qap:ComponentSetupRequest>
</soapenv:Body>
The <componentLang> element has to be used for setting a language specific component implementation. Its value has to be the
ISO 639-1 alpha-2 code of the language for which the implementation shall be used.

Sample request (SOAP body) for setting a location specific component implementation:

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<qap:ComponentSetupRequest xmlns:qap="http://qallme.sf.net/wsdl/qaplanner.wsdl">
		<componentID>http://qallme.sf.net/wsdl/answerpool.wsdl</componentID>
		<componentLoc>ES</componentLoc>
		<wsdlURL>http://localhost:8080/qmfdemo/ES-answerpool/AnswerPoolWS?wsdl</wsdlURL>
	</qap:ComponentSetupRequest>
</soapenv:Body>
The <componentLoc> element has to be used for setting a location specific component implementation. Its value has to be the ISO 3166-1 alpha-2 code of the country for which the implementation shall be used.

Sample request (SOAP body) for setting a system-wide component implementation:

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<qap:ComponentSetupRequest xmlns:qap="http://qallme.sf.net/wsdl/qaplanner.wsdl">
		<componentID>http://qallme.sf.net/wsdl/languageidentification.wsdl</componentID>
		<systemWideComponent/>
		<wsdlURL>http://localhost:8080/qmfdemo/languageidentification/LanguageIdentifierWS?wsdl</wsdlURL>
	</qap:ComponentSetupRequest>
</soapenv:Body>
When setting system-wide component implementations in the QAPlanner, then an empty <systemWideComponent> element has to flag this.

Sample response (SOAP body):

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<ns4:dummy xsi:type="xs:string"
	           xmlns:ns4="http://qallme.sf.net/xsd/qallmeshared.xsd"
	           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	           xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
</soapenv:Body>
If no error has occured during the setting of any component implementation, then a dummy value will be returned.

The getSubsystemComponents web method returns all component WS implementations which are currently used in the QAPlanner for a given language/location subsystem or as system-wide components. A flag in the return result (cf. complete attribute) additionally shows whether all components for the given subsystem are already set or not. The identifier for the subsystem in a request to the method has the same form as the parameter of the setComponent web method.

If only a single WS implementation of a certain component type that is currently used in the QAPlanner shall be returned, then the getComponent web method can be used instead.

Sample request (SOAP body) for getting all component implementations of a certain language subsystem:

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<qap:ComponentSetupRequest xmlns:qap="http://qallme.sf.net/wsdl/qaplanner.wsdl">
		<componentLang>de</componentLang>
	</qap:ComponentSetupRequest>
</soapenv:Body>
The two other possible request forms look analog to the possible requests of the setComponent web method.

Sample response (SOAP body):

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<ns2:SubsystemComponentSetup complete="false" xmlns:ns2="http://qallme.sf.net/wsdl/qaplanner.wsdl">
		<component id="http://qallme.sf.net/wsdl/termannotation.wsdl">http://localhost:8080/qmfdemo/de-termannotation/TermAnnotatorWS?wsdl</component>
		<component id="http://qallme.sf.net/wsdl/timeannotation.wsdl">http://localhost:8080/qmfdemo/de-timeannotation/TimeAnnotatorWS?wsdl</component>
	</ns2:SubsystemComponentSetup>
</soapenv:Body>
In the above sample response two URLs of the WSDL documents of component implementations which are currently set for the requested subsystem (here the German language subsystem) are returned. Additionally the complete attribute flags that not all required component implementations for the requested subsytem have been set, yet. In particular the QueryGenerator component implementation has not been set, yet.

The Timex2SparqlConverter is a WS which has a single web method that converts the temporal information from a piece of text which is annotated in the extended TIMEX2 format (cf. 4.2.1: “General Remarks”) to parts of a SPARQL query. Standard TIMEX2 annotations will result in a time point disjunction SPARQL query and two annotations with extended TIMEX2 annotations are considered to be start and end points of an interval. The Timex2SparqlConverter’s WSDL description can be found under src/main/net/sf/qallme/res/wsdl/timex2sparqlconversion.wsdl. The system-wide framework implementation in Java is the class net.sf.qallme.Timex2SparqlConverterWSProvider.

The Timex2SparqlConverter has the following web methods:

The convert web method converts the temporal information from a piece of text which is annotated in the extended TIMEX2 format to a SPARQL “FILTER” expression. Standard TIMEX2 annotations will result in a time point disjunction SPARQL filter and two annotations with extended TIMEX2 annotations are considered to be start and end points of a time interval.

Sample request (SOAP body) for a simple standard TIMEX2 annotation:

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<tim:ConversionRequest xmlns:tim="http://qallme.sf.net/wsdl/timex2sparqlconversion.wsdl"
	                       xmlns:tim1="http://qallme.sf.net/xsd/timex2.xsd">
		<tim:TIMEX2AnnotatedText>
			<tim1:TIMEX2 VAL="2008-02-12T10:15">heute um 10:15 Uhr</tim1:TIMEX2>
		</tim:TIMEX2AnnotatedText>
		<tim:temporalContext>2008-02-12T12:56:23</tim:temporalContext>
	</tim:ConversionRequest>
</soapenv:Body>

Sample request (SOAP body) for an extended TIMEX2 annotation:

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<tim:ConversionRequest xmlns:tim="http://qallme.sf.net/wsdl/timex2sparqlconversion.wsdl">
		<tim:TIMEX2AnnotatedText>
			<tim:TIMEX2 VAL="2008-02-12T14:00" function="FROM">heute von 14</tim:TIMEX2>
			<tim:TIMEX2 VAL="2008-02-12T18:30" function="TO">bis 18:30 Uhr</tim:TIMEX2>
		</tim:TIMEX2AnnotatedText>
		<tim:temporalContext>2008-02-12T12:56:23</tim:temporalContext>
	</tim:ConversionRequest>
</soapenv:Body>

Sample response (SOAP body):

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<string xmlns="http://qallme.sf.net/wsdl/qallmeshared.wsdl"
		>FILTER (((xsd:dateTime("2008-02-12T13:45:00") &lt;= xsd:dateTime(fn:string-join(fn:string-join(xsd:string(?date),"T"),xsd:string(?time)))) &amp;&amp; (xsd:dateTime("2008-02-12T19:15:00") >= xsd:dateTime(fn:string-join(fn:string-join(xsd:string(?date),"T"),xsd:string(?time)))))).</string>
</soapenv:Body>
The resulting SPARQL filter always operates on the two variables ?date and ?time. These variables are therefore assumed to be existent in the SPARQL query in which the filter will be used. Both ?date and ?time are restricted by the generated filter to temporal expressions which are constrained by the input TIMEX2 annotation. Additionally, the namespace prefix “fn” must be defined in the SPARQL query in which the filter is used: it has to be defined as http://www.w3.org/2005/xpath-functions#.

In the system-wide implementation of the Timex2SparqlConverter for the QALL-ME Framework the created SPARQL filter is usually a bit less strict than the temporal expressions that it was created for, i.e., the times that the created filters will match are the times given by the temporal expressions plus a bit more. As the filters are intended for a QA system it is usually a good idea to do this. For example, if someone asks “Which movies can I see in Schmelz today at 8 p.m.?”, then he is probably also interested in the movies at 20:25 or 19:50.