Home > semantic > Java Semantic Web & Linked Open Data webapps – Part 2

Java Semantic Web & Linked Open Data webapps – Part 2

November 24, 2010

Selection criteria – technologies, content, delivery

For both applications different different technologies are required – they have different needs and outputs, as described in the first part of this series. One is aimed at the Linked Open Data web, the other at exploring the possibilities of using Semantic Web technologies in a J2EE stack, in particular within a Location Based Service. Neither of these applications are RDFa publishing mechanisms or concept extractors like OpenCalais.

So what kind of content will the tools I need have to work with, what are the criteria, and how does the final package look ?

Linked Open Data webapp Semantic backed J2EE webapp
Content A PDF of a 19th century gazeteer of Ireland’s Civil Parishes [1]. This takes us into the world of digital humanities, history and archive data. But this is about the rich content of the gazeteer, not about describing the gazeteer itself, so its not a bibliographic application. It takes the form of entries for each of 3600 odd civil parishes in Ireland. Each entry may consist of information regarding 

  • placename and aliases
  • location,
  • relation to other locations – distance, bearing,
    other placenames
  • population – core, borough and rural
  • antiquity and history – thru the eyes of the author and the tendency to ignore social and individual aspects of “historians” at this time
  • natural resources present in the location
  • days or markets and fairs
  • landscape, features and architecture
  • goverment and official presence – brideswell, police station, post office
  • agriculture and industry
  • politics – the great houses of the gentry and aristocracy, the members of parliament
  • ecclesiastical matters – Tithes, Glebes and church buildings for the Church of Ireland/England to the Roman Catholic “chapels”
  • educational facilties for the population

Entries for cities and larger towns are long and wavering in their descriptions, while smaller parishes or those known by common names may simply be entries that say “SEE OtherPlaceName”. Each entry starts with a capitalised placename, which is then followed by freetext sentences, using 19th vocabulary and phraseology. There are no subject headings or breaks within entries. Pages are 2 column layout with page numbers at the bottom and 3 letter index headings on each page – eg “301 BRI” or “199 ATH” – or at least this is how it looks when the text is extracted from the PDF. So, in summary, the content is freetext, but does have some structure, although its not possible to tell until the content is read. There are variations used throughout, capitalisation can be different from entry to entry, and there are myriad OCR errors.

The idea here is that a user might be able to continually and over time record their latitude and longitude, and tag their profile and their locations with a structured vocabulary. To make
it useful, allow others to see that info if I invite them to, and allow commerical applications access to my data if I sign up to it. Obviously there are issues to do with privacy, access control and data protection here, not just at an end-user level but also at a commercial level. And if we’re going to do it with semantic technology then it needs to justify itself. Oh, and almost (didnt) forget, it needs to be highly performant too. So – its simple really, right ? A user database, login, authorization, post some coordinates, create groups and “friends”, report on them. maintain privacy, show some real benefit from choosing Semantic technologies. What could be easier ! 

So, what kind of content do we have to look at :

  • User profile information – but we want to minimise and identification details, preferably retain none, not even an email address
  • Roles – User, Administrator, Partner, Root. An admin is a user who owns an Application and can see Location data for all users in the application. A Partner is a repository wide user who can
    see locations in all applications, but cannot identify users or applications by name.
  • Blur – a representation of the degree of fuzziness applied to an identifying entity, to be used with Roles, ACLs or permissions to diminish the accuracy of the information reported to a
    user or machine using the system
  • Location information – lat and long, but also related to Application or Group, User
  • Application profile – we want 3rd parties to be able to create an “application” with some valuable proprietary content that builds on an anonymous individuals location history,
  • Groups – like applications but not commercially orientated. These are for individuals who know each other – friends – or who share an interest – eg a Football Club. They may have an off
    domain web application of their own.
  • Date and time – more than one user might post the same location at the same time, and we want to have a history trail of
    locations for users
  • Devices – individuals may use applications that reside on a mobile device or a web page perhaps, to post location information. They may have multiple devices. Multiple users might share
    the same device.
  • Interests/Tags – what people are interested in, how they categorise themselves, what they think of when theyre at a location
  • Permissions – read,write,identify,all and so on – the degree to which a role or user can perform some operation
  • Platforms – the operating system or software that a device runs on
  • Status – Active, Deleted, Archived etc – flags to signify the state of an entity in the system and around which access rules may be tied
  • UserAgent – as well as the Platform and Device, we may want to record the agent that posted a location or a tag
  • Query – commercial applications need to be able to “can” a query that interests them so they can run it again and again, or even schedule it
  • Schedule – a cron-like entity that assumes an owners identity when run to query available and accessible data, then perform a Task
  • Task – an coarse entity that encapsulates a query and some action that happens when the query is run and either “succeeds” or “fails”
Technology questions The webapp will consist of a SPARQL endpoint and some HTML with Javascript Ajax calls. This is 2-tier rather then 3-tier architecture, because the SPARQL endpoint is simply a means to pass queries to the repository using http. For an application where developers are focused on UI and dynamic linkage across the web, where the data is effectively read-only and doesnt have much in the way of
surrounding business logic – a typical Mashup – then this kind of architecture gets you there fast. Following guidelines for building Linked Open Data applications [2,3,4] this is broken down into a number of technology problems. 

  • Getting a quality corpus of text to use. This also includes making sure that any licensing and privacy issues are considered.
  • Exracting entities from the text – but this is in itself a series of tasks 
    • what entities am i interested in ?
    • how do i define the entity ?
    • is the entity actually a compound of more than one thing – eg a distance of “11 miles” may be an entity that is a string or a compound that is a number (what kind of number) and a unit or
      measurement “miles”. Are the miles in this 1842 corpus the same as the ones used today ?
    • do I need to bundle each entries entities into a single blob or RDF ? this is as much a question of what RDF is as to how you go about developing, debugging and staging the content
    • how are entites related to other content in an entry in the corpus, and to other entries in the corpus
    • is the quality and structure of the content sufficiently consistent to support automated techniques, available technology and time constraints ?
    • can i treat the corpus as a series of text fields, or do I need to consider it as set of concepts ?
    • for either approach, what technologies are available and what are their limitations ? are they current, documented and actively supported ? do they do what they say they do ? how much
      effort is needed to learn them ? Will I need to write my own code even if do use them ? Are there examples of code elsewhere ? Do they have dependencies that arent compatible with other technologies I use ? Are there licensing issues and costs if my application becomes commercial ? Once I start using them, how long will it take to get useable output ?
  • Once an entity is identified, transforming that into an RDF representation – what URI and tags to use (this relates to the ontology design), what serialisation format (if any) is best to work with – xml/ttl/n3/direct-load. How do I design my URIs (“hash or slash” ?) [5] ? Do I need to use or be aware of other URI schemes for compatability and reuse ? [6]. Should I try and clean the source text first (OCR errors) or rectify this by using RDF “tricks” or “aliases” ?
  • Storing or staging the RDF and loading into a repository – one file, many files (how many?), a database, a filesystem, a semantic repository
  • Building a query front end for the data once it its in the repository – check its in there, check its correct, make it available – do I need a 303 redirect ? Do I serve the ontology (T) alongside the instances (A) ? Do I need inference ? Can I use Tomcat/Jetty/OpenVirtuoso ? What hardware do I need ?
  • How do I make the content searchable ? What is search in this context – is it google-esque keyword lookup (TF/IDF) or is it a query console, or a browse capability – how can I do any of these things ? Do I need a separate search instance/technology or do any of the SemWeb technologies do this as well as store and retrieve RDF ? What am I going to index – text, uris (subjects/properties/objects)
  • Once I have a SPARQL endpoint, how do I build a webapp to talk to it  – can I get JSON ? can I get JSONP ? What XML formats are output ? Do I need to make server side calls or can I use Ajax client side calls ? Are there security features required – or do any of the SPARQL endpoint technologies have any security or access control facilties ?
  • What libraries of code are available to make calls to a SPARQL endpoint – are there specialist libraries or do I just treat it as an XML web service ?
  • If I am to link with other SPARQL endpoints – eg dbPedia [7]- how do I do that ? Is it a server side or client side problem ? How do I match URIs or more importantly concepts ?
  • Can I build other datasets from related information later, independently, and then link those to my dataset ?
  • How can I build a UI around RDF – are there conventional ways to render forms or graphs ? Do I need to write code myself or are there “black boxes” that I can make use of to render RDF or forms to capture user input as RDF ?
  • How will machine rather than human access be handled ? – Do I  need to build an API other than the SPARQL endpoint – is this for other applications, for spiders or robots. Do I need a
    client side API ? Do I want to service cross domain calls  eg (JSPONP/CORS) ?
  • Are there any concurrency issues to be aware of – will the data extracted ever be updated once we get it out of the text ?
  • Phasing – Will the extraction be phased, does it take place over time and need different staging and migration strategies ?
  • Will I need to deal with versions of my information ?
  • Do we need backup and resilience at the service and/or data levels ?
  • Can we cluster, can we deploy round-robin, can we separate the display logic hosting from query, and this from the data hosting ?
  • Is performance of this application comparable with a traditionally built application that might make thinly proxied JDBC service calls from Javascript ?
  • Can you really treat a semantic repository like an RDBMS ?
  • Is Sign-in really required – why not just drop a cookie and let people post using some random GUID ?
  • How can I represent my entities if i use RDF ? Can I control the IDs in the system ?
  • Are there any libraries of code the bridge the gap from Object to RDF ? What criteria do I need in selecting one ? 
    • Licensing, cost
    • Support, documentation, recency
    • Tie-in to particular technology
    • Standards compliance
    • Performance
    • Configuration ease
    • API design – built to interface, modular, separation of concerns ?
    • Object oriented or RDF leaning ?
  • Can I build my app using common patterns – DAO, service layer, MVC ?
  • What if it all turns out to be wrong and semantic repository technology just doesnt do it ?
  • How do I control anonymity ? I dont want or care to know who people are really, and I want users to be secure knowing that they cannot be found by other users if they dont already know who they are. Likewise, how do I hide or cloak sensitive information even when a user allows another access to their details ?
  • Is the system performant in read and write ?
  • Does (how does) the system scale with concurrency ?
  • How can I allow cross-domain usage of the information, so that users, affinity groups and commercial 3rd parties create useful or novel applications from the location-content and then
    add-on value with proprietary information and perhaps Linked Open Data ? How do I allow the end user to control that access ?
  • Can a message queue be modelled using RDF ?
  • Can messages be “sent” from one user to another or a user to an application ?
  • Can I ensure that identities cannot be inadvertently explored or discovered ?
  • Are there ontologies available that allow me to model my entities ?
  • What tools can use to create an ontology, and reuse others ?
  • Do I need inferrence ? What advantages does it give me, or the users of the system ?
  • Can I combine those advantages with the application data to deliver a new kind of service ? Does Semantic Web technology deliver on its promise ?
  • How can I allow a user to use a structured vocabulary ?
  • Will I need to partition all this data by user, by application, by date ?
  • Can I host this reliably, efficiently and with performance ? What deployment configuration do I need during development and then when I come to host it ?
  • Do I need a purpose-designed semantic repository or can I use my favourite RDBMS as a storage medium ?
Delivery This is really a question about who my users are, what their requirements and expectations are of the application, what I want to deliver to them – is it a technology demo or a useful, perhaps even attractive application ? Will it be long lasting – what are my expectations for it ? 

For me, this is primarily a technology demonstration, a learning tool and perhaps if it turns out to actually work and delivers something over and above what a conventional application might then I can keep it going and running without it costing too much. Cost is as a large consideration –

  • Amazon EC2 will cost roughly e2/day for a micro instance,
  • an ISP might charge e70/y but wont be capable of hosting a large memory JVM and give me the level of control I need, or
  • self-host at home on an old machine – electricity isnt cheap, will the machine be powerful enough, and what do I do if and when the machine
    fails ?

The intent in this exercise is to learn as much as possible about the practical sides of building such an application, and to try and do what can be done without it becoming a research project. A long the way, there are choices of course, and in the end hindsight and experience will pay rewards.

The J2EE application is to deliver a “white-label” (customisable) service for application builders who are interested in making use of crowd sourced location data. Individuals need to be secure in trusting their location, and some aspect of their identity (or a moniker for it), to the system. They need to be sure that when they allow another user to get to it that they cannon be identified from it (or a sequences of locations or recurring location usage) unless they chose to do so. 

The tags used against locations or member profiles need to be queryable usefully – not just by equivalence or presence. Any queries run against the system must be availble to non technicians (SPARQL experts) so a useable UI.

The service will not deliver a SPARQL endpoint initially, but may deliver one against a subset of aggregate information over long periods of time. Similarly an API delivered for third party users is only open
to registered users or applications.

Users and groups get restricted volume access, and cannot schedule queries, while applications get unrestricted access to their own data, and query capabilities. Partners will get access to repository wide location data, but cannot see under which application or group the location was posted.

The information, and the intelligence within, created from users attracted to commercial applications (eg an anonymous FourSquare type application), are within the realm of the 3rd party delivering that
application. This web service only deals with the custodianship of location trails, user declared relationships between users, and the tags assigned by users to them.

Building the application must be successful in terms of raw functionality but also in terms of performance. It must not be tied to a particular semantic technology, and it must be possible to compare with a traditional RDBMS based application. Importantly, the application must demonstrate commercial advantage and a pattern of usage where information is sensitive, but also usefully relatable to the Linked Open Data web.

So – many questions, and many choices to make. Answers to most of these will follow in subsequent articles.

[1] http://www.libraryireland.com/topog/
[2] http://www4.wiwiss.fu-berlin.de/bizer/pub/LinkedDataTutorial/
[3] http://www.w3.org/DesignIssues/LinkedData.html
[4] http://virtuoso.openlinksw.com/whitepapers/VirtDeployingLinkedDataGuide.html
[5] http://www.w3.org/TR/swbp-vocab-pub/
[6] http://www.w3.org/TR/cooluris/
[7] http://wiki.dbpedia.org/Interlinking

%d bloggers like this: