• Aucun résultat trouvé

Jassa - A JavaScript suite for SPARQL-based faceted search

N/A
N/A
Protected

Academic year: 2022

Partager "Jassa - A JavaScript suite for SPARQL-based faceted search"

Copied!
6
0
0

Texte intégral

(1)

Jassa - A JavaScript Suite for SPARQL-based Faceted Search

Claus Stadler, Patrick Westphal, Jens Lehmann Universit¨at Leipzig, Institut f¨ur Informatik, AKSW, {cstadler|pwestphal|lehmann}@informatik.uni-leipzig.de

http://aksw.org

Abstract. The availability of SPARQL endpoints on the Web provides interesting opportunities for rapid Web application development. How- ever, sophisticated applications need components that can adopt to the data, yet, the efficient generic exploration and visualization of data con- tained in those endpoints is still challenging. In this paper, we present the

“JAvascript Suite for Sparql Access” (Jassa) framework, which features various abstractions and utilities for the creation and transformation of SPARQL queries, as well as the processing of corresponding result sets.

The current highlights comprise modules for RDF, SPARQL, data ac- cess, conversion of result sets to objects and faceted browsing, together with corresponding user interface components based on AngularJS.

1 Introduction

The Linked Data initiative led to a paradigm shift, in which large amounts of structured data were made publicly available. With RDF, a data model was introduced, which enables global identification and integration of resources as well as cross-dataset interlinking. On top of RDF, SPARQL1became a standard language for accessing Web databases. Yet, the development of Web applica- tions for the exploration and visualization of SPARQL-accessible data still poses several challenges related to performance and design. In this paper, we present the Open Source JavaScript framework calledJAvaScript Suite for Sparql Access (Jassa). Jassa is motivated by the goal of creating the generic widgets for faceted browsing of RDF data depicted in Figure 2. The library is designed to tackle many of the challenges encountered during the development process.

The remainder of this paper is structured as follows. In Section 2 we outline the high-level structure of Jassa as well as its highlights. In Section 3 we briefly summarize related work. Finally, in Section 4 we conclude this paper.

2 The Jassa Architecture

Jassa is an umbrella term for a set of three related projects. A depiction of the architecture is shown in Figure 1. These projects are summarized as follows:

1 http://www.w3.org/TR/sparql11-query/

(2)

Fig. 1:The Jassa Architecture

– Jassa Core2 is a project that provides a layered set of modules for: the representation of RDF and SPARQL, the execution of queries, SPARQL-to- JSON mapping, and most prominently, faceted search.

– Jassa UI3 is a project for user interface components based on Jassa Core and the AngularJS4 framework.

– Complementary Services for Jassa5 is a Java project that offers server side APIs that enhance Jassa, such as a SPARQL cache proxy. Another service is capable of finding property paths connecting two sets of resources.

In the following, we explain selected components of Jassa in a bottom-up fashion, starting from the RDF API and ending in the faceted browsing widgets.

2.1 The RDF, VOCAB and SPARQL modules

Therdf module features the basic components for working with RDF data. The most important class is rdf.NodeFactory, from which rdf.Node objects can be created that represent RDF terms. Thevocab module provides predefined node objects for the commonly used xsd, rdf, rdfs and owl vocabularies. The sparql module features classes for representing the syntactic constructs of SPARQL queries.

1 var s = rdf . N o d e F a c t o r y . c r e a t e V a r (’ s ’) ;

2 var o = rdf . N o d e F a c t o r y . c r e a t e U r i (’ h t t p :// d b p e d i a . org / o n t o l o g y / A i r p o r t ’) ;

3 var t = new rdf . T r i p l e ( s , v o c a b . rdf . type , o ) ;

4

5 var q u e r y = new s p a r q l . Q u e r y () ;

6 q u e r y . s e t R e s u l t S t a r (t r u e) ;

7 q u e r y . s e t Q u e r y P a t t e r n (new s p a r q l . E l e m e n t T r i p l e s B l o c k ([ t ]) ) ;

8 q u e r y . s e t L i m i t ( 1 0 )

9 c o n s o l e . log (’ As s t r i n g : ’ + q u e r y ) ;

10 // O u t p u t : S e l e c t * { ? s a < h t t p :// d b p e d i a . org / o n t o l o g y / Airport > } L i m i t 10

Listing 1:Example for forming a query

Note, that all mentioned namespaces reside in the globaljassaobject. As can be seen from Listing 1, we decided to follow designs of the well-known Apache Jena

2 https://github.com/GeoKnow/Jassa-Core

3 https://github.com/GeoKnow/Jassa-UI-Angular

4 https://angularjs.org/

5 https://github.com/AKSW/jena-sparql-api

(3)

project6, with the intention of providing a consistent development experience when combining these frameworks in a project.

2.2 The Sparql Service API

Web applications could run SPARQL queries against HTTP SPARQL endpoints by directly using an AJAX API. However, this simple approach has several drawbacks: The server may limit the sizes of result sets. Triple stores may have limited or even erroneous SPARQL implementations, forcing clients to phrase queries differently. In many cases, caching query responses is desired. On some occasions it can happen that an application launches a new query although the same query is already running. Jassa provides a decorator-based approach to transparently deal with these issues. The main interface isservice.SparqlService, which defines methods for creatingservice.QueryExecutionobjects from a query string7 or query object. Usually, decorators that apply query transformations will first parse the string before passing the transformation result as an object to the delegate. Thesparql.QueryExecutionclass offers methods for retrieving the response: execSelect(), execConstruct(), exectDescribe() and exectAsk(), which yield promises of appropriate type, i.e.sparql.ResultSet,rdf.Graph and boolean.

Listing 2 demonstrates the creation of a SPARQL service that performs pag- ination8, query transformations for some issues with Virtuoso9 and caching of the individual pages.

1 var s p a r q l S e r v i c e = new s e r v i c e . S p a r q l S e r v i c e H t t p (

2 ’ h t t p :// d b p e d i a . org / s p a r q l ’, [’ h t t p :// d p b e d i a . org ’]) ;

3 s p a r q l S e r v i c e = new s e r v i c e . S p a r q l S e r v i c e V i r t F i x ( s p a r q l S e r v i c e ) ;

4 s p a r q l S e r v i c e = new s e r v i c e . S p a r q l S e r v i c e C a c h e ( s p a r q l S e r v i c e ) ;

5 s p a r q l S e r v i c e = new s e r v i c e . S p a r q l S e r v i c e P a g i n a t e ( s p a r q l S e r v i c e , 1 0 0 0 )

6

7 // N o t e : T h i s a c c o m p a n y i n g f l u e n t API is o f f e r e d for c o n v e n i e n c e :

8 s p a r q l S e r v i c e = s e r v i c e . S p a r q l S e r v i c e B u i l d e r

9 . h t t p (’ h t t p :// d b p e d i a . org / s p a r q l ’, [’ h t t p :// d p b e d i a . org ’])

10 . v i r t F i x () . c a c h e () . p a g i n a t e ( 1 0 0 0 ) .c r e a t e() ;

11

12 var qe = s p a r q l S e r v i c e

13 . c r e a t e Q u e r y E x e c u t i o n (’ S e l e c t * { ? s ? p ? o } L i m i t 1 0 0 0 0 ’) ;

14 qe . e x e c S e l e c t () . t h e n (f u n c t i o n( rs ) {

15 w h i l e( rs . h a s N e x t () ) {

16 var b i n d i n g = rs . n e x t B i n d i n g () ;

17 b i n d i n g . get ( rdf . N o d e F a c t o r y . c r e a t e V a r (’ s ’) ) ;

18 }

19 }) ;

Listing 2:Usage example of the SparqlService API

6 http://jena.apache.org/

7 We are currently experimenting with the integration of the SPARQL.js parser:

https://github.com/RubenVerborgh/SPARQL.js

8 The default implementation assumes that limit and offset do not influence the result set order.

9 For example, some versions of Virtuoso do not support queries having an outer-most OFFSET greater than 20000 in conjunction with an ORDER BY clause. Please refer to the Jassa github page for implementation details.

(4)

2.3 The SPARQL-to-JSON mapper

Between SPARQL and JSON (or JavaScript objects in general) there is an impedance mismatch similar to that encountered in the object/relational world:

SPARQL result sets are relations, however these are of little direct use in JavaScript applications without a transformation into objects. In general, object creation requires aggregation of data from multiple result set rows. Sponate uses maps to express the SPARQL-to-JSON mappings, and it supports initial query capa- bilities over the mapped objects using an interface similar to that of the JSON database MongoDB10. A usage example of Sponate is shown in Listing 3.

1 var s t o r e = new s p o n a t e . S t o r e F a c a d e ( s p a r q l S e r v i c e , p r e f i x M a p ) ;

2 s t o r e . a d d M a p ({

3 t e m p l a t e : [{

4 id : ’ ? s ’, n a m e : ’ ? l ’,

5 p a r t n e r s : [{

6 id : ’ ? f ’, n a m e : ’ ? pl ’, a m o u n t : ’ ? a ’,

7 }]

8 }] ,

9 f r o m: ’ ? s a o : P r o j e c t ; r d f s : l a b e l ? l ; o : f u n d i n g ? f . ? f o : p a r t n e r [ r d f s : l a b e l ? pl ] . ? f o : a m o u n t ? a ’ }) ;

10 }) ;

11 var c r i t e r i a = { p a r t n e r s : {$e l e m M a t c h : { n a m e : {$r e g e x : ’ u n i v e r s i t y ’} } } } ;

12 s t o r e . p r o j e c t s . f i n d ( c r i t e r i a ) . l i m i t ( 1 0 ) . a s L i s t () . d o n e (f u n c t i o n( arr ) {

13 // arr is an a r r a y of J a v a S c r i p t o b j e c t s a c c o r d i n g to the J S O N t e m p l a t e

14 })

Listing 3: Example of a Sponate mapping

2.4 The LookupService API

Given a set of URIs, Jassa makes retrieval of related information easy using the LookupService interface and its corresponding implementations. The only method on this interface isPromise<Map>lookup(keys). The API is similar to that of the sparql service: Functionality is enhanced using decorators, as shown in Listing 4, where the basic lookup service is based on a Sponate store.

1 var ls = new s e r v i c e . L o o k u p S e r v i c e S p o n a t e ( s t o r e . p r o j e c t s ) ;

2 ls = new s e r v i c e . L o o k u p S e r v i c e C a c h e ( ls ) ;

3 // E x e c u t e the o r i g i n a l l o o k u p r e q u e s t by p e r f o r m i n g l o o k u p s w i t h

4 // p a r t i t i o n s of at m o s t 20 k e y s - a v o i d s l a r g e S P A R Q L q u e r i e s

5 ls = new s e r v i c e . L o o k u p S e r v i c e P a r t i t i o n ( ls , 20) ;

6 // V a l i d a t e e a c h key by a f i l t e r p r e d i c a t e b e f o r e d o i n g the a c t u a l r e q u e s t

7 ls = new s e r v i c e . L o o k u p S e r v i c e K e y F i l t e r ( ls , p r e d i c a t e F o r V a l i d a t i n g U r i s ) ;

8 // M e r g e all l o o k u p r e q u e s t s w i t h i n a 50 ms t i m e w i n d o w i n t o a s i n g l e r e q u e s t

9 ls = new s e r v i c e . L o o k u p S e r v i c e T i m e o u t ( ls , 50) ;

10 ls . l o o k u p ([ /* rdf . N o d e o b j e c t s for the l o o k u p */ ]) . t h e n (f u n c t i o n( map ) {

11 /* Use map . get ( key ) to r e t r i e v e the key ’ s v a l u e */

12 }) ;

Listing 4: Decoration of a LookupService

2.5 The Faceted Browsing Widgets

Jassa comes with a powerful SPARQL-based faceted search module in thefacete namespace, which supports the definition of custom constraint types as well as

10http://docs.mongodb.org/manual/reference/operator/nav-query/

(5)

constraining sets of resources by indirectly (possibly inversely) related proper- ties. Due to space limitations, we only demonstrate the usage of the faceted browsing widgets, shown in Figure 2. These widgets are implemented as Angu- larJS directives and can thus be embedded into AngularJS applications using the corresponding HTML snippets. The HTML attribute values refer to JavaScript objects, of which a basic setup is shown in Listing 5. Note that the widgets are synchronized by AngularJS on the state of thefctTreeConfigobject; any change will automatically trigger an update of the widgets.

1 $s c o p e . f c t T r e e C o n f i g = new f a c e t e . F a c e t T r e e C o n f i g () ;

2 $s c o p e . s e l e c t e d P a t h = n u l l; // S t a r t w i t h no s e l e c t i o n

3 $s c o p e . s e l e c t F a c e t = f u n c t i o n( p a t h ) { $s c o p e . s e l e c t e d P a t h = p a t h ; }

Listing 5:Basic setup to make the facet-value-list show the values for a selected facet

1 < facet - t r e e

2 sparql - s e r v i c e =" s p a r q l S e r v i c e "

3 facet - tree - c o n f i g =" f c t T r e e C o n f i g "

4 s e l e c t =" s e l e c t F a c e t ( p a t h ) "

5 > </ facet - tree >

(a) Facet Tree

1 < facet - value - l i s t

2 sparql - s e r v i c e =" s p a r q l S e r v i c e "

3 facet - tree - c o n f i g =" f c t T r e e C o n f i g "

4 p a t h =" s e l e c t e d P a t h "

5 > </ facet - value - list >

(b)Facet Value List

Fig. 2:Widgets for Faceted Browsing & the HTML (AngularJS-based) to create them

3 Related Work

A generic JavaScript-based RDF data browser called Tabulator [3] was developed under the umbrella of the World Wide Web Consortium. Besides the tree based traversing the tool also provides a map and a calendar view. Another library providing RDF access in JavaScript is RDFQuery11, which provides an API for manipulation and querying of RDF data within JavaScript as well as the extraction of RDF data from Web content. However, neither of these projects

11http://code.google.com/p/rdfquery/

(6)

seem to offer the powerful abstractions and implementations provided by Jassa.

As for RDF JavaScript APIs, there are recent efforts in re-continuing work on a specification on RDF interfaces in JavaScript12. In regard to faceted browsing of RDF datasets, there are for instance the Sparklis browser13 and the Pelorus faceted navigation tool14. Jassa however features support for nested and inverse properties and offers reusable components. Very recent development efforts which provide similar features are [2] and [1].

4 Conclusions and Future Work

In this software description, we explained the components of the JAvascript Suite for Sparql Access (Jassa). Its foundation is built on a core library, which includes an RDF, SPARQL API, advanced service abstractions (e.g. transparent caching, query transformation, pagination and page expansion) and a faceted search module. The jassa-ui modules introduce user interface components for faceted browsing and map display. Thanks to AngularJS, these widgets can be embedded as ordinary HTML elements in websites. Overall, Jassa simplifies Se- mantic Web application development via light-weight but powerful and efficient APIs. In the future, Sponate’s feature set will be extended, such as with sup- port for references between maps. We are also working on new facet retrieval strategies with the aim of improving overall performance. Examples of applica- tions built using Jassa include the generic SPARQL browserFacete215 and the Linked Data Presentation Framework [4].

Acknowledgment

This work was supported by grants from the EU’s 7th Framework Programme provided for the projects LOD2 (GA no. 257943) and GeoKnow (GA no. 318159).

References

1. M. Arenas, B. Cuenca Grau, E. Kharlamov, ˇS. Marciuˇska, D. Zheleznyakov, and E. Jimenez-Ruiz. Semfacet: Semantic faceted search over yago. In23rd International World Wide Web Conference, WWW ’14, Seoul, Republic of Korea, April 7-11, 2014, Companion Volume, pages 123–126, New York, NY, USA, 2014. ACM Press.

2. H. Bast, F. B¨aurle, B. Buchhold, and E. Haußmann. Easy access to the freebase dataset. In23rd WWW ’14, Seoul, Republic of Korea, April 7-11, 2014, Companion Volume, pages 95–98, New York, NY, USA, 2014. ACM Press.

3. T. Berners-Lee, Y. Chen, L. Chilton, D. Connolly, R. Dhanaraj, J. Hollenbach, A. Lerer, and D. Sheets. Tabulator: Exploring and analyzing linked data on the semantic web. InThe 3rd Intl. Semantic Web User Interaction Workshop, 2006.

4. D. Lukovnikov, C. Stadler, and J. Lehmann. Ld viewer - linked data presenta- tion framework. In Proceedings of the 10th International Conference on Semantic Systems, SEM ’14, pages 124–131, New York, NY, USA, 2014. ACM.

12http://www.w3.org/TR/rdf-interfaces/

13http://www.irisa.fr/LIS/ferre/sparklis/osparklis.html

14http://clarkparsia.com/pelorus/

15http://facete.aksw.org

Références

Documents relatifs

This analysis shown in Figure 6 shows that participants found data source and triple pattern(s) related information helpful for understanding the query result derivation, but have

Using GF, we are able to present a cross-language SPARQL grammar covering 15 languages and a cross-language retrieval interface that uses this grammar for interacting with the

Based on the applications discussed, faceted search and browsing can be combined in a useful way with various means and tools for visualization: facet selections are a very flexible

For example, if a user types in the partial label hum, GraFa will suggest human (3595226 results) as the first result; if selected, GraFa will search for entities of type wd:Q5; on

Which combinations of object and datatype properties should be added as columns to the search engine table, depending on the type of ?x, is controlled by the index configuration..

Design Requirements The requirements for our tool, SPARQL Faceter, are based on our earlier experience on tediously implementing server side faceted search over and over again

Abstract. We propose a facet-based RDF data exploration mechanism that lets the user visualize large RDF datasets by successively refining a query. The novel aspects of

Figure 1 shows a typical situation: a user searched for a keyword (here an author name) and the faceted search generated links for search refinements (the facets) on the