|
SPARQLMotion Example NewsfeedCalaisMap
This example SPARQLMotion script reads business news from a New York Times news feed, extracts all countries mentioned in the news and displays them on a map, helped by the OpenCalais and GeoNames web services.
Download in N3 format (2008-03-24)

This example demonstrates how unstructured data (here, a collection of news articles) can be mined to create a mash-up. The starting point is an RSS news feed from the New York Times business section.
- The module Import NYT news feed (type: Import news feed) loads this news feed and sends it as RDF to the next steps.
- The Collect all news items (type: Concatenate text) module concatenates the bodies of all current articles into a single large text string and binds it with the variable text.
- The variable text is also the input of the Extract countries module (type: Call Calais). This is using the OpenCalais web service from Reuters to identify entities such as countries, people, companies and events from arbitrary text sources. In this case, we are interested in the instances of the Calais country class. The module adds the triples delivered by Calais to the RDF graph.
- The module Iterate over all countries (type: Iterate over select) repeats the body script for each country in our current RDF graph. The iteration is controlled by a SPARQL SELECT query that binds the names of each country into the variable countryLabel.
- The countryLabel is used by the Get country from geonames module (type: Import RDF from URL). Geonames is a web service that can take location names as input and return their geographical latitude and longitude. The body script of the iteration calls geonames for each country mentioned in the news and accumulates the geo:lat/long values in our RDF graph.
- Finally, after all countries and their locations have been collected, the script invokes Display countries on map (type: Create map) which runs a SPARQL query that specifies which countries shall appear on the map.
|