|
||||||||||
Building Semantic Web Applications |
|
This exercise utilizes information from a government spending website, USASpending.gov along with some resources from OEGov to produce a simple application that displays government spending, organized by line of business for that spending and government agency. The instructor will walk you through the steps; this is a group activity. If you are an experienced user of TopBraid Composer you might be able to follow the instuctions on your own, but these are not intended to be complete without additional guidance from the instructor. You will need web connectivity to carry out the full exercise. The process exploits many of the concepts outlined in this tutorial:
Before the exercise begins, install TopBraid Composer Maestro Edition on your computer. The instructor will supply the software for PC or Mac platforms. For this course, we will not support linux installations. Step 1. Create a project in TopBraid Composer, call it iswc.topquadrant.com. Create a file in that project called Budget1.n3. Import the following URLs into the Budget1 model:
Step 2. Visit USASpending.gov. You will find a tool for creating your own data feed from government financial data. Create a feed that includes Agency name, Bureau name, Line of business, Service Group, and some fiscal data you are interested in. At the bottom, click the RSS icon to get a feed of your data. Copy the URL of this feed. Step 2.5. View the BRM vocabulary structure. Select the "Properties" tab, and find skos:broader ("has braoder") Right-click and select "associations view". Step 3. Import this feed into TopBraid Composer using the RSS import wizard. Add that data set to Budget1.n3 The instructor will guide you through an exploration of this data, noting certain correllations in the different data sources. Step 4. Use the following query to determine all of the items in the RSS feed, and find the FEA references for their lines of business. SELECT DISTINCT ?i ?c
WHERE {
?c a skos:Concept .
?c skos:prefLabel ?lob .
?i Atom:lobName ?lob .
?i a rss:item .
}
Step 5. Review these matches to determine if they make sense. Now use a CONSTRUCT query to record these matches in the model. We will use the dc:subject property to record the match. CONSTRUCT {?i dc:subject ?c .}
WHERE {
?c a skos:Concept .
?c skos:prefLabel ?lob .
?i ?p ?lob .
?i a rss:item .
}
Assert these triples back into the model.
Step 6. The following query will find all business lines that have been used in the feed. Run this query. Copy the results to the basket - we'll want to reference them later on. SELECT DISTINCT ?x
WHERE {?i dc:subject ?x }
Step 7. We can find all the items related to a particular topic using SPARQL. We can also report the things about that item that we are interested in. Use and modify this query as needed to match the data you included in your feed selections. SELECT ?category ?dmepy ?ss ?tot
WHERE {
?c dc:subject ?this .
?c rdfs:label ?category .
?c Atom:DMEPY ?dmepy .
?c Atom:SteadyStatePY ?ss .
?c Atom:totalInvestmentsPY ?tot .
}
Now you can double-click on the various lines of business in the basket. You will see the business
line in its context in the associations view, as well as information about all items that match it.
Step 7.5. Poor-man's inferencing. Let's do some inferences about rdfs:label, to make displays look cleaner. Run the following query, and assert the results: CONSTRUCT {?term rdfs:label ?l}
WHERE {?term a skos:Concept .
?term skos:prefLabel ?l .}
Step 8. Ensemble. Open TopBraid Ensemble from the url http://localhost:8083/tbl/. Open a New Application, and create a tree component and a grid component. Customize the tree as follows: Root = BRM count = Subject transitive=has broader (event) single click=SelectTermCustomize the grid as follows: (event) Bind and Execute = SelectTerm Query Template = [the same query from Composer]You now have the same behavior in Ensemble that you had in composer; each click on a business line shows all the projects associated with it, and their fiscal details. Step 9. Back in Composer, let's make a connection from these items back to the agencies. This query is much like the one in an earlier step to link to the FEA, but this one isn't picky about how the agency is referred to. Often cavalier approaches like this work just fine. CONSTRUCT {?i dc:subject ?a .}
WHERE {
?a a gov:Agency .
?a rdfs:label ?an .
?i a rss:item .
?i ?p ?an .
}
Explore the model to see how agencies have been connected to the RSS items.
Step 10. Now that we have our items linked both by agency and by FEA business line, we can cross-reference the two organizing methods. The following query will require some explanation - it includes several of our topics:
SELECT ?agency
(SUM (?dmepyfl) as ?newSpending)
(SUM (?ssfl) as ?steady)
(SUM (?totfl) as ?totalSpending)
WHERE {
?c dc:subject ?this .
?this a skos:Concept .
?this rdfs:label ?category .
?c dc:subject ?a .
?a a ?cl. ?cl rdfs:subClassOf* gov:Agency .
?a rdfs:label ?agency .
?c Atom:DMEPY ?dmepy .
LET (?dmepyfl := xsd:float (?dmepy))
?c Atom:SteadyStatePY ?ss .
LET (?ssfl := xsd:float (?ss))
?c Atom:totalInvestmentsPY ?tot .
LET (?totfl := xsd:float (?tot))
}
GROUP BY (?agency)
Using this query in the SPARQL tab, select various lines of business ("Health" is a good one ...).
Step 11. Copy this query into Ensemble as the "Query Template". See the same behavior in Ensemble. |