Sunday, March 13, 2011

Bug Fixes

I spent most of both days this weekend in Concord watching my daughter and her fellow dancers do a great job at a competition. It was a fun time being proud of my daughter, but I didn't make a lot of progress on this project.

I did manage to fix a few bugs with the interaction of the combo boxes to narrow down the accounts by categories. The major one was that when you double click on an item in the table or chart the corresponding combo box is selected. But, the list of available categories to group by was losing too many items. It was just supposed to lose the item that was just selected. It turns out that the first update to the list was causing a nested update that removed the wrong item. During the initial update I set a flag that I already had to prevent redundant updates and that made it work much better.

I also fixed a performance bug when the model RDF files were opened. I had added a cache for the Jena models, but it turned out I wasn't putting the models in the cache. That was an easy fix once I realized the cause. I found it when I added better logging using SLF4J. I've used log4j almost exclusively in prior projects, but Jena uses SLF4J so I looked into it. It allows the logging to be switched at deploy time, which is cool, and I am still using log4j underneath.

I fixed the sorting of the table column of budget amounts. I had rendered floats from Jena using NumberFormat into Strings that were added to the table. But, as I've seen countless times before, sorting numbers as Strings sorts the first digit, not by place value. I fixed this by using BigDecimal consistently so I can get numeric sorting, control over the decimal places so they always show cents, and I added a simple renderer to the table to add commas to separate the thousands.

Lastly, I started adding unit tests based on UISpec4J. I haven't used this before, but I've done a lot of unit testing of non-GUI code before and from what I read on the web, UISpec4J seems like a great framework for Swing applications like this. I have very basic tests working, but my first substantive test that opens an RDF file is stuck trying to capture the heavyweight FileDialog that is recommended for Mac OS X. Or, maybe I just don't have the window interceptors initialized properly. I added a menu item to open an RDF model from a file for faster and more targeted testing, but I still don't have this test working. Still a few bugs to work out....

Sunday, March 6, 2011

Untethered

This week I have continued to work on the Budget Viewer application. I have focused on 2 main areas: 1) make it run anywhere, 2) make it start up faster. Making it run anywhere - untethering it - is a bigger step than you might think. At the start of this week, it would only run from a single directory on my computer. That directory had to have the SPARQL query files and RDF files. Both of these had to be changed so you could run the application, too. I also explored the next step of packaging the application to make it easier for you to install.

My first step actually fell out of some exploring into making the application work under either Windows or Mac OS X. Even though Java is billed as a cross platform environment, it is really more Windows-centric than neutral. So, there are several articles on how to make Java applications fit better under Mac OS X. One of those articles included an adapter for Mac OS X that included a build.xml file for Ant. I replaced my BASH script to build with a heavily-edited copy of this build.xml. The real advantage of this build.xml file is it has tasks to build the Java program as a double-clickable Mac OS X application. (Here's another extended article.) Beyond the Mac OS X application packaging I think I'll just create a DMG disk image and copy the application onto it for distribution. In other words, I don't think a Mac OS X installer is needed.

For Windows, I think an installer is needed since I need to create start menu shortcuts and registry entries. I found the Nullsoft Scriptable Install System (NSIS) which is an open-source full-featured tool to create Windows installers. I found a bunch of examples on the web that I was able to mash together for a simple installer.

The Java runtime is another big question for installers. For Mac OS X, at least for now, Java is already installed with the base system. I can't rely on that for Windows, but I don't really want to include the full Java runtime since that will more than double the size of my application. So, for now I just check that the compatible version of Java is installed and if not report an error and quit. I don't like it, but for now I hope it is good enough.

Returning to the SPARQL query files, I handled them through the build.xml file. I put all my Java files in reasonable Java package directories and embedded a query subdirectory where I moved all the SPARQL files. I then use a Classloader to read in the files. This allows me to package them in the Jar file that the build.xml file builds so now that part no longer ties the application to my environment.

The RDF files will come from the ORCSD data web site. I've been focusing on this application to verify that the RDF files are OK, but I really need them there so I can test the application in different environments. So, I've copied the first few files "as is" to the web site. If you'd like to take a peek, here they are with the caveat they are very likely to change:

With these RDF files minimally available on the web, the Budget Viewer application can now run from anywhere.

A noticable downside of moving the RDF files to the web is the time it takes for the application to start up. It was slow before, but now it is very slow. I had sped up the normal operation after start up by caching the models. During start up, though, it is still bogged down by reading the models.

The application was reading the models as part of constructing the GUI components. So, it wouldn't display anything until it was all ready. This clearly wasn't going to work. I first tried starting with a dialog to ask for the URL for the budget RDF file. This was clunky and I struggled a bit to figure out how to go from the budget RDF file to the account lines and accounting categories RDF files. While I eventually figured out how to extract the resource prefixes and convert them to URLs using Jena, I also switched to constructing the basic GUI without the parts that depend on the models and added an Open menu item. This GUI starts up in a few seconds, which will work fine. It lets the user know it is working and gives a palette to display a busy cursor and "Loading..." status message. I still think it is a bit rough, but it is progress.

Here's the initial window:



When you select the Open menu item, this dialog comes up with the ORCSD budget URL already filled in:



While the budget is loading, the cursor changes to a spinning ball and the window displays a simple status:



And, then when it is done, you get the full Budget Viewer that you've seen before, but with a few additional properties for more categories in the bottom right:



That's it for this week. I hope very soon to be at a point where it is good enough for you to try out.

Monday, February 28, 2011

Jena Models

I made a little more progress tonight on the Budget Viewer application. No new pictures since it looks the same as yesterday. The interaction is a bit less buggy, though still not quite correct.

The biggest change is in how I use the Jena API. I now read the RDF and query files only once and then query them repeatedly. This makes the application much faster. It was painfully slow before, and now it is quite reasonable. I was previously concerned whether I could use SPARQL repeatedly or just once to get the original data and then troll the results as needed. With this speed I think I can stick with SPARQL. That makes the application much easier to write.

Another advantage of this change in the API calls is that the queries now have no references to the specific RDF files or prefixes. Only the budget vocabulary, SKOS, RDFS and RDF which are all quite generic. This means it will be easy to use any set of budget data, whether from ORCSD or anywhere else. That's great!

This also brings back the issue of finding budget data. I need to add a way for the application to ask for the budget data to view, probably using a form. But, that's for another night....

Sunday, February 27, 2011

Budget Viewer Selection

This weekend I have made more progress on the Budget Viewer application. I am using this application to validate the RDF files, and I am still finding problems. For example, the ORCSD account categories RDF file includes an intermediate category called Object Categories like Supplies and Salaries. I had them defined so they were related to Object using the skos:broader property just like the individual items like Object 51010 for Administrator Salaries. The effect of this was that when the Budget Viewer application grouped by Object, the total was doubled. I fixed this by defining an Object Category directly under Account Classification and then each individual item is related by skos:broader to both Object and a specific Object Category. A bit confusing, I know, but this is the kind of things I am finding.

This week I added a feature to Budget Viewer so you can double click on a line in the table or a wedge of the pie chart and that item is used to narrow down the accounts to those that match the category. I also added combo box controls for each category. They take up a lot of room and still don't interact quite correctly, but it is still a work in progress. Here's a recent snapshot:



In this snapshot, the Salaries Object Category and Teacher Salaries Object is selected to limit the accounts. They are then grouped by Location. I'm sure you also see what I mean about the selection taking up too much space.

Friday, February 18, 2011

It's Alive!

Thanks to Sonja Gonzalez, the IT Director at ORCSD, we have a live web site to serve the RDF data for this project. She emailed late last night that it was available and we worked through some issues today to make sure I could use it, and tonight I replaced the "Hello, World" page she used to try it out with a slightly better welcome page. Try it out!

I have to warn you that I don't have any real RDF data published yet. As I have been exploring it over the last few weeks, I realized that my simplistic versioning scheme wasn't going to work well. Originally, I proposed just appending the date to the end of each file name. Each new version of a file would get the date replaced. But, since the file name is part of the URL, and the URL is part of the identifier for the RDF resources, if I changed the file name each time I tweaked a file, I would have to edit and rename a lot of files that used the URLs to keep them current.

Further, I don't think this level of versioning is really necessary. A lot of changes can be done without requiring the file to be versioned. If new data is added without "breaking" any old data, then it doesn't need a new version. For example, if new properties are added to old resource descriptions, or new resource descriptions are added, then it doesn't need a new version. Removing data, or worse, redefining the vocabulary of the data, would need a new version. Changes that didn't warrant a new version could simply be indicated by updating the last modified property of the file.

Before I publish any RDF data on the new web site, I want to make sure I get this versioning correct and also make sure my queries work when using data from the web site instead of files on my computer. My goal is to have the first RDF files ready later this weekend. Stay tuned!

Wednesday, February 16, 2011

Exploded Pie

I played a bit more with jFreeChart and my budget viewer application today. I interconnected the spreadsheet, pie chart and properties panels. When the mouse is clicked over the table, then the corresponding pie section is exploded (increased in size and shifted out from the center). The properties are also updated to match the selection. Similarly, when the mouse is clicked over a pie section, that section is exploded, the table row is selected, and the properties are updated. Here's a picture with all 3 panels showing the corresponding selection and properties:

Tuesday, February 15, 2011

More Small Steps

I haven't updated in over a week, mostly because I've been very busy with other things, but there are a few little things that have happened on this project. The biggest is this last weekend I made some progress on a Java application to view budget data. I decided the application should be a window with 4 panels: 1) a top "toolbar" of controls, 2) a main "spreadsheet" table in the bottom left, 3) a smaller graph panel in the middle right and 4) a smaller "properties" panel in the bottom right. The table and graph give 2 perspectives on the same data. When you select a line in the table, details on that line are shown in the properties panel. The toolbar lets you select what level of detail or groupings are shown in the table and graph as well as filter that data. Here's a picture of the prototype:



I also explored jFreeChart a bit more. Here's a bar chart of the same locations data:



On a related note, a colleague at work emailed me a link to a PBS article on budget visualizations.

My son sent me a note that the New Hampshire state government is also starting a move toward open data. While it is not quite RDF, it is good to see some compatriots near to home.

Lastly, I got a note last week from Sonja Gonzales saying she is still working on getting a URL on the ORCSD web site for the RDF data.

Sunday, February 6, 2011

Budget Cubed

After reading the Data Cube vocabulary guide a couple more times and studying the UK payment vocabulary example some more I finally wrapped my head around it and integrated it into my budget vocabulary. I had to understand the distinction between dimensions, measures and attributes and apply those concepts to budgets.

The only measure is the amount of money for each budget component. Most of the other properties are dimensions. I added an attribute using the SDMX unit measure property to define the amounts in terms of US dollars. This solved how to specify the currency of the amounts, but the only reference I could find for US dollars was from DBpedia. This works, but there may be a better choice out there I haven't found yet. There are other SDMX properties that I should add later to give more details about the data set.

I also had to figure out what constituted a budget data set. Since the predominant use case is to compare budget data between years, I decided that a data set is the set of all budgets for the school district. I added a BudgetSet class to the budget vocabulary to represent this data set.

I defined 2 slices of the data set. The first slice is by fiscal year, that is the Budget class is a slice. Then a subslice is a version of a budget, that is the BudgetVersion class. The Budget slice has the fiscal year property fixed, and the BudgetVersion slice has the fiscal year and version date properties fixed.

Adding the BudgetSet and other Data Cube properties solved another problem I wrote about before, namely how to find budget versions. The BudgetSet has properties to list the Budget slices. These are listed in a new RDF file just to describe the budget set as a whole. Each Budget has properties to list its BudgetVersion subslices. Each BudgetComponent also has a property to link back to the Budget. While I still think an index and sitemap are needed down the road, the Data Cube links solve the problem for now.

Integrating the Data Cube vocabulary affected more than just the budget vocabulary. I had to modify the RDF files for each fiscal year and the XSLT stylesheets to generate the budget version slices. In the process I factored out some common templates into a library stylesheet with parameters. This eliminated a lot of the redundant code, though again there is still some room for improvement.

Sunday, January 30, 2011

Two are Better than One

Yesterday I wrote that I would work on the map from ORCSD account categories to the NH account categories, but the thought of that tedium caused me to reevaluate my priorities. While I still think that a better set of categories is worthwhile, I realized that it would be more useful for less work to figure out how to compare different versions of budgets.

I copied and edited the XSLT stylesheet for extracting the proposed budget from Jay Hilyard's CSV. I made 2 new copies that extract the current year budget and last year's actual expenditures. This gives me 3 different RDF files, 1 for each fiscal year.

Editing copies of the XSLT files isn't a long term approach. Adding parameters would be much better. XSLT can't search for tag names using parameters. The Csv2Xml program uses the CSV column header as the tag name. And, the tag names are ExpendedBudget20092010, CurrentBudget20102011, and ProposedBudget20112012. I know I can generate an XSLT stylesheet from a template, but that seems like overkill.

Once I had multiple years of data, I realized I needed a way for my application to figure out for which years there is data. I also realized that I needed to write SPARQL queries to compare the data from 2 years.

I spent some time today researching how to describe a catalog of RDF data. Since my data is all RDF, it seems the Vocabulary of Interlinked Datasets (VOID) was the best choice, in spite of its seemingly useless acronym. This guide referred me to the sitemap protocol and the semantic sitemap extensions that I will also need to worry about at some point.

While I am still wrestling with whether all of the budget files combine to form a single data set or a bunch of data sets, I realized that VOID really needs full URLs to work, so I shelved that until I have the RDF files on the web site.

I wrote a SPARQL query to correlate the budget accounts from 2 years and calculate the difference. But, it swapped the order so I had to define the fiscal years. From the budget model, the fiscal year is a property of the whole budget, not of each version of the budget. The XSLT-generated RDF files are just a version. I hand coded a small RDF file for each fiscal year that defined the whole budget and added properties to each version to relate the version to the budget. I then extended the SPARQL query to find the fiscal years and use them to order the amounts. This did the job! Here's the query:
PREFIX rdf:          <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX orAcctCats: <http://www.orcsd.org/data/2011/orAcctCats.rdf#>
PREFIX orAcctLines: <http://www.orcsd.org/data/2011/orAcctLines.rdf#>
PREFIX budget: <http://www.orcsd.org/data/2011/budget-20110122.rdf#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT ?accountLabel ?amount1 ?amount2 (?amount2 - ?amount1 AS ?difference)
FROM <orAcctLines.rdf>
FROM NAMED <orBudgetFy2011-20110130.rdf>
FROM NAMED <orBudgetFy2012-20110130.rdf>
FROM NAMED <orFy2011.rdf>
FROM NAMED <orFy2012.rdf>
WHERE
{
?account rdfs:label ?accountLabel .
GRAPH ?g1
{
?item1 budget:accountLine ?account ;
rdf:type ?type ;
budget:componentAmount ?amount1 .
?version1 budget:budgetVersion ?budget1 .
}
GRAPH ?g2
{
?item2 budget:accountLine ?account ;
rdf:type ?type ;
budget:componentAmount ?amount2 .
?version2 budget:budgetVersion ?budget2 .
}
GRAPH ?g3
{
?budget1 budget:fiscalYear ?fy1 .
}
GRAPH ?g4
{
?budget2 budget:fiscalYear ?fy2 .
}
FILTER(?fy2 > ?fy1 && ?type = <budget:BudgetAccount> )
}
ORDER BY ?difference
And here's part of the output:
-------------------------------------------------------------------------
| accountLabel | amount1 | amount2 | difference |
=========================================================================
| "10-109-5110-59100-00-00-00000" | "1465000" | 1185000.00 | -280000.00 |
| "10-110-2721-52110-00-00-00000" | 673607.16 | 447971.24 | -225635.92 |
| "10-112-2620-53300-50-13-00000" | "205000" | 0.00 | -205000.00 |
...
| "10-110-2721-56260-00-00-00000" | "122293" | 185351.00 | 63058.00 |
| "10-209-2150-51020-35-30-00000" | "-9602" | 74174.14 | 83776.14 |
| "10-109-1100-52600-00-00-00000" | "4770" | 106145.00 | 101375.00 |
| "10-209-2150-51020-35-13-00000" | "0" | 143134.00 | 143134.00 |
-------------------------------------------------------------------------
The quoted numbers under amount1 were really like this:

"0"^^<http://www.w3.org/2001/XMLSchema#decimal>

But, the explicit types made the text too wide. I think this is just because the decimal numbers don't have a fractional part. I'm not worried about this right now.

Saturday, January 29, 2011

Data Table

I explored a bit more with my Java application today. I first made a copy that filled in a spreadsheet table with the result of the SPARDL query. As I was showing my son both the first application with the pie chart and the new application with the data table, he said I needed to put them together. Of course, I already knew that, and that is what I did.

I had to refactor both programs a bit and merge the data models. I used a Java Swing JTable with a TableModel interface for the data table and the jFreeChart PieDataset interface for the pie chart. I created a new class that implemented both interfaces and populated that class with the results of the SPARQL query. Then I put the chart panel and table panel into a root panel and used the common model. It is a bit slow, but otherwise it works great.

Up to this point, I had a hard-coded SPARQL query. Unlike SQL that can take parameters, the current version of SPARQL doesn't have parameters, so I added an Apache Commons Lang StrSubstitutor to edit the query template. First I passed the account category on the command line, and finally I made it into a JComboBox pull-down menu so you can change the category while the application is running. Again, other than being a bit slow, it works great. Here's a screenshot:



There are a lot more features that this application can do. It is still just something to explore what is possible. One obvious thing is to format the numbers in the table with 2 fixed decimal places and commas.

As I was comparing the various ways the ORCSD budget is categorized, I was reminded how hard it is to get a good picture of the budget breakdown. The categories are not used consistently. That is what lead me to find the NH handbook account categories. I need another RDF file to map the ORCSD accounts to the NH categories. This needs to be hand coded, or at least hand tweaked, so it may take a while to get all 1,000 plus accounts categorized properly.

Unfortunately, I still don't have a place to publish my RDF files. Since a Java program is a bit more than I asked for, I think a good place for it would be on SourceForge. I'll create a new open source project for it and put it there. This will allow others to use it and add to it as well. And, it won't burden the district website any more than I've asked for already.

Friday, January 28, 2011

Pretty Picture

After getting my first SPARQL query to work yesterday, I was on a roll and got even more to work. I ran a simple query that summed up all the budget accounts.
---------------
| total |
===============
| 35963503.94 |
---------------
I ran a more sophisticated query that grouped the budget accounts by location and then summed each group. This query joined 3 separate RDF files, and it worked. It was lots of fun!
---------------------------------------------------------------------
| label | comment | total |
=====================================================================
| "Location 201" | "Special Education (Mast Way)" | 0.00 |
| "Location 203" | "Special Education (Moharimet)" | 0.00 |
| "Location 205" | "Special Education (Middle School)" | 0.00 |
| "Location 206" | "Special Education (High School)" | 0.00 |
| "Location 111" | "Technology" | 960708.92 |
| "Location 110" | "Transportation" | 2012691.67 |
| "Location 112" | "Maintenance" | 2764318.64 |
| "Location 103" | "Moharimet" | 2898503.63 |
| "Location 101" | "Mast Way" | 2902710.83 |
| "Location 109" | "Districtwide (including SAU)" | 3516174.09 |
| "Location 105" | "Middle School" | 6126682.72 |
| "Location 106" | "High School" | 6561831.79 |
| "Location 209" | "Special Education (District)" | 8219881.65 |
---------------------------------------------------------------------

So, today I explored another step. Both when I met with Sonja last week and at the last ABC meeting the question of how people would use this data came up. My approach has been to collect the data first, and worry about an application later. Since some of these data sets will take years to accumulate, I see it as crucial to start collecting. But, I realize most people don't have as much fun playing with SPARQL queries, so being able to show them what it can do is important.

Besides reformatting the Excel spreadsheet, Jay made some charts from the data grouped by various categories. I thought a quick application would be to take my location group SPARQL query and graph the results as a pie chart. I found jFreeChart as an open source Java library to generate charts. The jena tool I use to run the SPARQL queries also has an application programming interface (API) for applications to run queries. It wasn't hard to find examples of both parts and then write a program to do both. I wrote a rough application tonight, and here is what it looks like:

Thursday, January 27, 2011

And the Answer is...

Yesterday, I wrote that I couldn't figure out how to join 2 RDF files together in a SPARQL query. The SPARQL syntax uses named graphs, but they just didn't seem to work for me.

Well, I am delighted to say I just got it to work. It turned out that my original intent proved correct. I wanted to try some SPARQL queries to see if my RDF files were correct. They were not.

The first problem was that I used the rdf:ID attribute where I needed to use rdf:about. I don't fully understand the difference yet, but I now know in some cases they aren't equivalent. I noticed that where I was using rdf:ID, the SPARQL result was not enclosed in angle brackets, but the brackets were around the rdf:about resources. I also noticed that the subjects that I hoped to link to the rdf:ID items also used angle brackets, so I changed rdf:ID to rdf:about and added the prefix and I started getting angle brackets consistently. And, my simple queries started giving me some results.

The query I was trying to get to work summed all the budget accounts with object ID 51020. That's professional salaries. But, jena complained that my budget amounts couldn't be summed. For that problem I figured out how to add an explicit decimal type to the amounts. I added rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal" to the XML elements. I tried defining the root URL as the xsd: prefix, but jena still complained so I spelled it out everywhere and I got a total. Here is the working query to sum up all the professional salaries:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX orAcctCats: <http://www.orcsd.org/data/2011/orAcctCats.rdf#>
PREFIX orAcctLines: <http://www.orcsd.org/data/2011/orAcctLines.rdf#>
PREFIX budget: <http://www.orcsd.org/data/2011/budget-vocabulary-20110122.rdf#>

SELECT (sum(?amount) AS ?total)
FROM <orAcctLines.rdf>
FROM NAMED <orBudgetFy2012-20110126.rdf>
WHERE
{
?account rdfs:label ?label ;
rdfs:comment ?comment ;
budget:category ?category .
GRAPH ?g
{
?item budget:accountLine ?account ;
rdf:type ?type ;
budget:componentAmount ?amount .
}
FILTER(?category = <orAcctCats:Object51020> && ?type = <budget:BudgetAccount> )
}

The result from jena is much simpler:

---------------
| total |
===============
| 13081890.74 |
---------------

Yep, that's a bit over $13 million. While this specific query is interesting, the key thing at this point is it shows that my RDF files work together, now. That makes me very happy!

Wednesday, January 26, 2011

Say What?

Tonight I am exploring another piece of the puzzle: asking questions. I am trying to ask questions of my RDF files to see whether they work as I want. I wrote another XSLT stylesheet to transform the ABC spreadsheet into the first slice of budget data as RDF. I am using the rough budget vocabulary without worrying about using the Data Cube vocabulary. I copied the budget slice RDF into the W3C RDF validator to make sure the syntax was OK and fixed a few errors. By asking questions, I can now validate it at a deeper level.

Asking questions with RDF uses another W3C standard called the SPARQL Query Language for RDF. It is similar to the standard query language for relational database call SQL. Many of the keywords are the same between SPARQL and SQL. SPARQL works with RDF triples instead of relational tables, though.

Up to this point, I've just been working with a text editor (BBEdit), a shell terminal, and the Xalan for Java program for running my XSLT transforms. SPARQL needs another program to execute the queries. I found the open source jena project, also written in Java. It executes SPARQL queries by giving it the RDF files and a file with the query itself.

This works pretty well, and as I had hoped this testing found a few things I did wrong. So, I've corrected my XSLT stylesheets and regenerated the RDF files. I've read a few tutorials about SPARQL (jena and Cambridge Semantics) and made some progress. Here's an example SPARQL query I got to work:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX orAcctCats: <http://www.orcsd.org/data/2011/orAcctCats.rdf#>
PREFIX orAcctLines: <http://www.orcsd.org/data/2011/orAcctLines.rdf#>
PREFIX budget: <http://www.orcsd.org/data/2011/budget-vocabulary-20110122.rdf#>

SELECT ?label ?comment ?type ?category
FROM <orAcctLines.rdf>
WHERE
{
?a rdfs:label ?label ;
rdfs:comment ?comment ;
rdf:type ?type ;
budget:category ?category .
FILTER(?category = <orAcctCats:Object51020> )
}

Now, I am struggling with named graphs that let me join 2 RDF files together. These named graphs are used instead of SQL joins, but different enough to confuse me so far. My tests have not worked, yet, but I am sure I'll get there.

Tuesday, January 25, 2011

Statistical Choices

As I continue learning about SDMX, I realize that the UK government payment vocabulary isn't really based on SDMX, but a subset called the Data Cube vocabulary. There is another vocabulary to choose from as well called SCOVO. SCOVO is the oldest RDF model for statistics, but it is quite simple with only 3 classes. SDMX is a well-established standard adopted by many organizations, but it has only recently been modeled in RDF. SDMX is a very general international standard for statistics.

The Data Cube vocabulary was started last year (2010) as a simpler model than SDMX, but with the same conceptual core. It is so new that the guide for the Data Cube vocabulary is still being written. The Data Cube vocabulary seems best for our budget vocabulary as well, though I'll have to track it as it solidifies.

Fortunately, I also realized that the choice of statistical model really doesn't slow down this project. As long as the actual budget classes, relationships and properties are well-defined, their relationships to the statistical classes, relationships and properties can change without harm. The choice of statistical model makes it easier to integrate our budget data, so it is important, but it doesn't hold up capturing the budget data as RDF in the first place.

Monday, January 24, 2011

Budget Properties

Last post I described the beginnings of a budget vocabulary. I listed 9 classes and as many relationships between those classes. As I started coding this vocabulary into RDF, I realized that 1 of those classes is already defined elsewhere. Namely, the Account Category class is already defined in the NH Financial Accounting Handbook for LEAs vocabulary I converted to SKOS. Basically, the handbook vocabulary just defines account categories. The ORCSD account category RDF that I transform from the ABC spreadsheet is defined in terms of the NH handbook, so it doesn't need to define a new class, either.

The budget vocabulary so far doesn't include any properties. Here, I mean details about the classes, not properties in the sense of predicates or relationships. It sure would be nice if there was a consistent vocabulary for talking about vocabularies! As an example, the Budget class has an instance for each fiscal year. So, it needs a property that defines the fiscal year. Besides defining the fiscal year, the Budget class is like a container for the Budget Versions for the same fiscal year.

Each Budget Version has an "as of date" property. This is the date when the snapshot of budget figures was taken. This isn't necessarily the same as the date when the Budget Version is published. A Planned Version adds a property to indicate if it is the final approved budget. Likewise, the Actual Version adds a property to indicate if it is the final audited budget. These Boolean properties are used to find the official versions, as opposed to intermediate versions.

Each Budget Change is basically a container for Budget Components that serve the same purpose. A Budget Change just has a description property. A Budget Component also has a comment property based on the real budget spreadsheets that have comments. I can see in the future, the budget vocabulary being extended to add additional semantics to these comments. For example, several budget components correspond to specific employees, and a count of those employees is useful. For now, we'll leave that to the next version of the vocabulary.

The key property for a Budget Component is an amount. The currency of the amounts should be a property on the Budget class. The Budget Account class doesn't add any properties. It is just related to Account Lines and is the primary Budget Component. The sum of the amounts for all Budget Accounts for a Budget give the total for the fiscal year.

For an RDF vocabulary, each of these properties is defined as a predicate with a class as the subject and usually a literal value for the subject. With these properties, I now have a very rough draft of the budget vocabulary in RDF. It at least passed the W3C RDF validator after a few tries. I need to study the SDMX vocabulary used by the payment vocabulary to make sure I get it all correct.

Sunday, January 23, 2011

Budget Picture

I made good progress yesterday on the RDF files of the ORCSD categories and the ORCSD account lines. I have 2 XSLT stylesheets that transform the Excel-to-CSV-to-XML files into these 2 RDF files. I used the W3C RDF validator to verify that the RDF files are at least well formed. The validator also found 6 accounts that were duplicated in the budget spreadsheet that Jay converted from his database, adding $36,000 to the bottom line. This wasn't in the official spreadsheet, just the ABC spreadsheet. That has since been corrected by Jay. I realized that I need the elusive budget vocabulary before I can generate the RDF file for the proposed budget, so this morning I returned to that.

I found a few things on the people (non-data) web to help with the budget vocabulary. First, there is the UK government payment vocabulary that is similar to a budget vocabulary. Second, is a best practices document by the W3C that answers my question about whether to use an intermediate object or a special property for each proposed budget account. Third, is a blog by Jeni Tennison. In 5 parts starting here, she details how she coded traffic counting data into RDF. Jeni Tennison is listed as a contributor to the payment vocabulary and is a well-known expert in the field.

I have decided to use the payment vocabulary as an example to create a new budget vocabulary. As Jeni Tennison points out in her blog post, designing a vocabulary is much like designing a database or XML schema. Since I work best with pictures, I usually do this kind of work with an entity-relationship or class diagram. Here's one I put together with Inkscape:



This diagram models budgets using 9 classes represented by rectangles in the diagram: Budget, Budget Version, Planned Version, Actual Version, Budget Component, Budget Account, Budget Change, Account Line, and Account Category. There are 3 "is a" relationships represented by lines with arrowheads: Planned Version is a Budget Version, Actual Version is a Budget Version, and Budget Account is a Budget Component. There are also 6 other relationships represented by named lines in the diagram. These relationships are named by the type of object in the relationship. The 1's and *'s indicate how many of each class can be related to the other class. For example, a single Budget can have any number of Budget Versions. Any number of Account Lines can have any number of Account Categories.

I designed this vocabulary to handle how I've seen people use budgets. Each fiscal year, a Budget goes through several versions, starting with Planned Versions that are proposed throughout the budget process. Eventually, one of those Planned Versions is adopted by the voters (as a bottom line number in our jurisdiction). Then the expenses of the school district are accounted to the budget lines during the fiscal year. At the end, the actual total expenses are reported. Eventually, one of the Actual Versions is audited to reflect the official expenses.

A Budget Version is reported as various component lines. Some of these Budget Components are summaries of large sections. The detailed Budget Version is reported as Budget Accounts. Sometimes, a single Budget Account may have smaller components that relate to specific Budget Changes. A Budget Change is a grouping of components for a specific purpose. For example, a new program or initiative or maybe even a significant cut would be a Budget Change. Budget Changes help people understand the intent of the Planned Budget. Budget Components can be broken down into smaller Budget Components. Budget Accounts correspond to Account Lines and Account Lines are categorized using Account Categories.

Using the UK payment vocabulary as an example, my next step is to code this budget vocabulary into RDF. I noticed that the payment vocabulary also used the Statistical Data and Metadata eXchange (SDMX) vocabulary in a way that allows the data to be used as statistics and also give it meaning, so I will try to do that as well.

Saturday, January 22, 2011

Workflow

As promised last post, I've cleaned up my transformation of the NH Financial Accounting Handbook for LEAs this weekend. I think it is all ready to publish this week! Keep your fingers crossed!

Today, Jay Hilyard of the Advisory Budget Committee (ABC) emailed to the committee an Excel spreadsheet of the final budget approved by the school board last week. Rob McEwan of the ABC had the great idea of publishing Jay's documents as Google Docs:
This is great since now you can easily see the data this project is working with. Besides getting the financial handbook ready to publish, I am also working on getting the first part of this budget spreadsheet ready to publish, though I don't think it will be ready this week.

I don't want this project to turn into a full-time job for me, or anyone else for that matter. Besides making it easier to use the data, I want it to be easier to publish the data. To do that, we need to look at workflow: how does the data get processed.

Jay's spreadsheet started in ADS, the accounting system used by ORCSD. The Business Administrator developed a report from ADS and converted it into an Excel spreadsheet. Based on her comments at the last board meeting, this conversion is not easy. She emailed that spreadsheet to Jay. Jay converted that data into a relational database he developed for the ABC. He merged the new data with some comments from earlier versions of the spreadsheet. Jay then converted the database into a new Excel spreadsheet and graphs that he emailed to the ABC members. Rob took those documents and copied them to Google Docs.

I now take Jay's spreadsheet and start to convert it into RDF. I take the first sheet of Jay's spreadsheet and save it in comma-separated value (CSV) format. I then convert that CSV into XML.

Converting from CSV to XML took a little bit of effort. I found a simple open source Java program on //javareference submitted by Darshan Singh. Unfortunately, this didn't handle quoted values well, so I replaced the Java StringTokenizer with my own. For this spreadsheet, this simple program did the trick.

The XML that comes from the CSV is pretty generic. It uses the column headers as the element tag names. This is quite handy, since it means my XSLT stylesheets to process this XML don't have to change when the columns move around or new columns are added, which happened this time.

Jay's spreadsheet is the only real source data I have to work with, so I want to get the most out of it. I think I need to make 3 different RDF files: 1) a list of account categories specific to ORCSD, but similar to the NH Financial Accounting Handbook for LEAs; 2) a list of accounts; and 3) the slice of proposed budget amounts for those accounts. I am writing separate XSLT stylesheets for each of these files.

The budget notebook handed to the ABC has a list of account categories. Jay's spreadsheet has sheets based on that handout, but it doesn't really cover the actual categories used in the budget. So, I will extract the actually used categories to generate the RDF. This is the stylesheet I am working on now.

Thursday, January 20, 2011

Baby Steps

It's been a snowy week up here in New Hampshire, with 2 snow days so far and another likely tomorrow. In spite of that, I've made some baby steps in my project.

Early Wednesday, I met with Sonja Gonzales who runs the IT department at ORCSD. We had a good conversation about what I am trying to do and how she can help. I am hoping that as early as next week we may have our first RDF file published!

That first file is likely to be the SKOS-ified NH Financial Accounting Handbook for LEAs I discussed earlier. Sonja also helped by giving me a contact at the NH Department of Education who published the handbook so I could let them know of my plans and make sure it was OK. They said yes!

I did find that I made a few errors in my transform of the handbook, so I need to clean it up a bit before I can publish it, but I should be able to do that easily this weekend.

The Advisory Budget Committee (ABC) got a new Excel spreadsheet from the ORCSD Business Administrator with the proposed budget as of the official hearing last Thursday. Since then a few more edits have been made and the school board approved at their meeting on Wednesday a final budget to be posted for the first deliberative session of the annual district meeting. I am expecting yet another copy of the spreadsheet with the final numbers soon. Once I get that I can save it as a comma-separated value (CSV) file, convert it to XML using a simple program I found on the web, and then transform it into RDF. That's when I'll need to really implement the RDF ideas from earlier and try them out.

I heard from 3 of my readers that my blog was quickly becoming too obscure. I am sensitive to this, and I'll try to explain the technology more clearly. I know I do get carried away!

In spite of a snow day delay, the ABC held a brief meeting to just catch up on each others' thoughts before yesterday's school board meeting. Nothing really new to report from that.

The Long Range Planning Committee (LRPC) also met on Monday to discuss our enrollment projection model I worked on last weekend. While most of the committee shared my concerns about the new formulas, we didn't really make any decisions.

Sunday, January 16, 2011

Student Enrollment

Today I took a break from budgets to work on the Long Range Planning Committee (LRPC) spreadsheet model for projecting student enrollment. This model is an Excel spreadsheet that started a couple decades ago. It uses Grade Progression Ratios (GPRs) to project most grades and linear regressions to project Kindergarten and 1st grade.

The GPRs are simple 5-year averages of the ratios of students from one grade in one year to the next grade in the next year. For example, the grade 2 to 3 GPR for this year takes 2010 grade 3 and divides it by 2009 grade 2 enrollments. It is also called cohort survival modeling which sounds a bit more dire, especially for the earlier grades.

The sticky part is the Kindergarten and 1st grade projections. Until a few years ago both were ordinary least squares (OLS) regressions based on births and housing. For the projected years 1 to 5 a regression based on the average of births 5 and 6 years back was used. It was sort of a GPR from birth to Kindergarten and then to 1st grade. Given kids are about 5 when they enter Kindergarten, and the school year is off by about half, that formula made sense.

For projections beyond 5 years (we go out 10 years), the future students are not yet born. Again, until a few years ago we used a regression of housing. We tracked local housing starts and added it to the decennial census of houses to estimate the total number each year. We then took the estimate for the last about 40 years and used that as a projected number going forward for the next decade. We then did a regression between housing and Kindergarten and 1st grade students. This regression was basically telling us about how many kids were born per house each year in our community.

These projections for Kindergarten and 1st grade have been OK for a while when the data was largely flat, but over the last few years it started to curve more sharply and the projections were off. So we've been trying to find alternatives that are closer. My job today was to take a new formulas based on births and prior year Kindergarten and 1st grade enrollments (no housing) and code them into the Excel spreadsheet.

While I think I coded the formulas faithfully, the results don't seem very good. The birth projects based only on prior year births rise slightly, but the Kindergarten and 1st grade projections both drop off quickly and steadily, much faster than other models we've explored, and more quickly than the recent historical data. The committee meets tomorrow to see what our next step will be.

Saturday, January 15, 2011

Budget Triples

A couple days ago, I discussed how all RDF data is limited to triples. The question that remains is how to represent the spreadsheet of budget data as triples. In particular, we want to start with just the proposed budget amount for a single account line.

We assume we have an RDF file that defines the account numbers and gives each of them a description. This data has an "accounts:" prefix with an example account number of accounts:10-101-1100-51020-00-11-00000. To move the discussion forward, let's assume we have a vocabulary for budgets that defines a predicate like "budget:proposed" that assigns a proposed amount to an account item. Then an RDF triple for this might be like this:

Subject: accounts:10-101-1100-51020-00-11-00000
Predicate: budget:proposed
Object: "1343151.98"

A budget goes through multiple versions and then is adopted and then implemented. The next year, the new budget goes through several versions. Over the years, a lot of amounts will be assigned to each account number. When the various RDF files from multiple versions are used by an application, all the triples are effectively merged. They can't all have the same subject and predicate with different amounts. How would we know which amount was for which version? To fix this, we need to use either a different subject or a different predicate for each version.

We still want the amount to be related to the particular accounts:10-101-1100-51020-00-11-00000 URI, but we can relate it through an intermediate piece of data. We can think of the intermediate data as the instance of the account line in the version of the data. For example, suppose we have a separate RDF file for each version and include the date in the name like this:

http://www.orcsd.org/data/2011/proposed-budget-20110117.rdf

Let's use "p20110117:" as the prefix for this URL. Then we can use the same tag names with this URL for the proposed account item like p20110117:10-101-1100-51020-00-11-00000. We use this instead of the accounts: prefixed item in the triple:

Subject: p20110117:10-101-1100-51020-00-11-00000
Predicate: budget:proposed
Object: "1343151.98"

This triple says this proposed budget account line item has $1,343,151.98. (Actually the dollars needs to be explicit somewhere.) This triple captures the time-sensitive aspect of the proposed amount, but while we know that the identical tag names in "accounts:" and "p20110117:" mean the same account, it has to be explicit in RDF. So, with this approach we need to add another triple per account item like this:

Subject: p20110117:10-101-1100-51020-00-11-00000
Predicate: budget:forAccount
Object: accounts:10-101-1100-51020-00-11-00000

This triple says this proposed line item is for the pre-defined account with the same name in another RDF file. Again, we assume we have some budget vocabulary that defines the budget:forAccount predicate for this purpose. This seems to work OK.

Another alternative is to change the predicate for each version. Instead of using a generic budget:proposed predicate, we could define a new predicate specific to each proposed version. It would probably make sense to define the version-specific predicate in the same RDF file as the amounts. Maybe something like this:

Subject: p20110117:proposed20110117
Predicate: rdfs:subPropertyOf
Object: budget:proposed

The "rdfs:" prefix is for the RDF Schema specification. This triple just says the new predicate is a specialization of the generic budget:proposed predicate. With this 1 RDF triple per version, we can now have just 1 triple per account line:

Subject: accounts:10-101-1100-51020-00-11-00000
Predicate: p20110117:proposed20110117
Object: "1343151.98"

Frankly, I don't know which of these alternatives is better. The next step is to make up some sample RDF files for a couple versions and try to use it. That should help answer which is better.

Three's the Limit

Resource Description Framework (RDF) aims to capture all the data in the world. That's a big goal. It is a very complicated goal, too. So, RDF needs to be very flexible. To be flexible it uses the most basic building blocks: simple statements with only 3 parts. They are like simple sentences with a subject, verb and object. The subject is a piece of data so it is named with a Uniform Resource Identifier (URI). The verb is called a predicate in Artificial Intelligence-speak. It is also called a property in Object-Oriented-speak. The object of the statement is either another piece of data, another URI, or a literal name, number, date, etc. That's it. They are called triples, and the semantic web has billions of them.

Last time we looked at budget data. In particular, we focused on the spreadsheet of budget line items that had 5 or 6 columns: account number and description, last year expended budget, current year budget, next year proposed budget, difference and comments. So, for each line, there are at least 6 parts. But, 6 is greater than 3, so we need to be creative.

To start, we can ignore the difference column. Any application can easily calculate the difference between the current budget and proposed budget. Even more, applications will probably want to find other kinds of differences: proposed budget to 5-year trend of actual expenditures; proposed budget to other districts' proposed budgets; between sums of accounts. So, we can ignore the difference column.

The account number and description are actually 2 different items concatenated together. The "and" in the name tells you that. The account number is the real key to each line item. Given any account number, you can look up the description. For almost all accounts the description for a given account number stays the same. So, for a yearly proposed budget, the description can be ignored, too.

Applications will need an RDF file that labels each account number with the description so thay can stitch them back together. Let's take a slight detour to describe that file. Each account is identified by the URL for the RDF file and a hash tag for the account number. Say, something like this:

http://www.orcsd.org/data/2011/accounts-20110115.rdf#10-101-1100-51020-00-11-00000

where all the stuff between "http://" and "#" is the URL for the file and the rest between "10-" and "-00000" is the account number as a long tag name. Each account will share the URL part, so we'll use a handy prefix as a shorthand for it. Read "accounts:" to be a simple substitution for "http://www.orcsd.org/data/2011/accounts-20110115.rdf#". Then, the above hash URI can be written as accounts:10-101-1100-51020-00-11-00000, which is a little bit better. With any luck, from year to year, most of the accounts will stay the same, so these account numbers can be easily compared, and the URIs can be stable. This RDF file is where we would have the descriptions of the accounts as triples like this:

Subject: accounts:10-101-1100-51020-00-11-00000
Predicate: skos:prefLabel
Object: "PROF TEACH-MW"

The 3 columns of budget numbers are parallel. We want to be able to combine them and compare them. So, if we can figure out how to express 1 column of numbers in RDF, we can extend that to handle the others. For example, the current year budget is just the proposed budget from last year. Since it is the most important column, let's focus on the proposed budget column.

In the proposed budget, each account number is assigned an amount of money. This is a triple: account number, "proposed", and amount. We can use the hash URI for the account number. We can use a literal number for the amount. But, what do we use for the verb, that is the predicate. This is what I was looking for in Choose Your Words Carefully. I didn't really find it.

Applying the anti-procrastination principle that it is better to publish something that can later be changed than wait until it is all worked out to even start, I ask what is an easy first step? Next time I'll start to try to answer this question.

Friday, January 14, 2011

Budget Artifacts

The last few posts have been largely focused on technical aspects of open data. Here, I'd like to think a bit more about budgets. A useful tool in Contextual Design is to analyze the artifacts of a task. For budgets, we have several documents that fit the bill. The Advisory Budget Committee started just before the annual introductory budget workshop. At this workshop we all got a copy of a divided binder. Some of the items in the binder are published here on the ORCSD web site.

The first binder section included general documents like the Fiscal Year 2012 Overview and District-Wide Priorities for Increasing Student Achievement. (Sorry, they are only published on the web site in Microsoft Word format.)

The next section of the binder was the proposed budget line-by-line for the whole district as of the date of the workshop. There are over 1,100 lines. I couldn't find the whole budget on the web site, but there is the section of the budget on technology.

After the binder section with the whole budget, there were binder sections for each of the schools and other major areas: special education, technology, professional development, district office, facilities, transportation, and food service. Each section started with an overview presentation like this one for Mast Way. After the presentation was a copy of the relevant budget section.

After the schools, the other binder sections had a presentation, part of the budget as well as other supporting documents. The section with the most information published on the web (not surprisingly, I guess) is the technology section. For example, there is the job description for the new database integrator position and a copy of the district technology plan. (Again, I apologize for the proprietary Microsoft Word, PowerPoint and Excel format files!)

The primary artifact is the line-by-line budget. It is basically a spreadsheet with 5 columns: account number and description, expended budget 2009-2010, current budget 2010-2011, proposed budget 2011-2012 and difference. I observed throughout the workshop and subsequent meetings that people often got confused about the 3 budget columns. They represent 3 consecutive years of figures. For the first year, last year, it is how much money was actually spent for each account. For the second year, this year, it is the approved budget. That is, how much money is planned to be spent this year for each account. For the third year, next year, it is the proposed budget. The proposed budget is the real focus of this process.

A lot of the discussion and confusion over the 3 budget columns is between the first 2. Not only do they represent 2 different years (which was not always clear to everyone), but they also differ between actual expenditures and planned budget. Many thought they represented the actual expenditures compared to the budget for the same year. This was aggravated by a budget surplus of over $2 million last year that made these columns quite different in many lines.

The account numbers and descriptions relate to the account categories defined in the NH Financial Accounting Handbook for LEAs. I've already written about this before and I'm sure I will again.

The difference column subtracted the current year budget from next year's proposed budget for each item. Of course, a lot of attention is drawn to those lines with large differences. Unfortunately, many if not most of the large differences were due to accounting changes. Several accounts were redefined between the 2 years so they didn't really account for the same expenditures. In the broken out budget sections after the whole budget there was an additional column with comments that sometimes explained these changes. Way too much effort was spent discussing these changes that often had no real impact on planned spending.

There were also a lot of accounts that just seemed to be wrong in the current budget. Many accounts were zero when there were bound to be real expenses. For example, substitutes for teachers and others had a total difference of about $100,000 between both the current budget and prior actual expenses and the proposed budget. Some accounts even had negative numbers that just make no sense.

Anyway, the key thing about the budget spreadsheet is that it is a list of line accounts and 3 series of numbers at different times (and some comments related to the last year's numbers). This seems like the best place to start representing the budget.

Tuesday, January 11, 2011

What's in a Name?

Every piece of data on the semantic web has a name. And not just any old name. It has a unique web address, a unique Uniform Resource Locator (URL) or Uniform Resource Identifier (URI). These are those things you type into a web browser that start with http://....

These names become the official way to identify each piece of data. The names need to be easy to use and most importantly, unchanging. Easy to use is a relative term when you are talking about things that start http://, but you don't want to use totally arbitrary names that even techies can't figure out. If other people link to our data (which is what we want), then changing the names will break their links. As we design open data, we need to think carefully about how to name it. For more details, here is a good tutorial: How to Publish Linked Data on the Web.

While the names for each piece of published data can't change, our design needs to be able to handle likely changes related to that data. Changes can come from making mistakes, year-to-year progress, or coming up with a better design. Since we are publishing budgets, we know that every year there are new numbers. Every year there are new account lines or changes to accounts.

As recommended in How to Publish Linked Data on the Web, section 7.1, I think we should use simple static pages and hash URIs. We should have a special directory on the district web site for all RDF data and then subdirectories for each year. The W3C has used the year subdirectories. I think it will help keep the data directory from growing unmanageably. Further, I would append each file name (before the extension) with the publication date as YYYYMMDD. For example, proposed-budget-20110113.rdf, or something like that. This is a crude but effective way to handle versions.

Hash URIs means we name each piece of data by the URL for the file that describes the data and then add a hash tag, e.g., #mytag, to the end. So the full name would be something like this:

http://www.orcsd.org/data/2011/proposed-budget-20110113.rdf#mytag

As I said, easy to use is a relative term.

Choose Your Words Carefully

For open data to be useful, it needs to have meaning. Meaning comes from identifying each piece of data with a well-defined dictionary of words, or what is called a vocabulary or even ontology. But, to really make the open data useful, it needs to have shared meaning. The vocabulary needs to be shared between your data and other similar data.

In other words, you don't want to create your own vocabulary for everything. Instead, you need to find published vocabularies that fit your data. This was the source for some of my frustration. I couldn't find a vocabulary for budgets. That didn't make sense. Much of the published open data is from the US and UK governments, surely money (budgets) would be a big part of that, right? Instead, most of it is more operational or statistical. After some time I found UK government data on spending. They even have a vocabulary on payments. This is a big step forward, but still not quite budgets.

Then I found the UK Combined Online Information System (COINS) that includes budget data. This uses a hypercube or Statistical Data and Metadata eXchange (SDMX) vocabulary that seems a bit more abstract and complicated for our budget. It seems more aimed at complicated but generic statistical analysis. To me, that seems to miss the point because the assigned vocabulary gives the meaning, and generic meaning really has no meaning. Also, COINS includes spending data but doesn't use the simpler payments vocabulary. Anyway, as the best fit so far, I will have to study it further.

Coming closer to home in New Hampshire, I found the NH Department of Education (NH DOE) has a New Hampshire Financial Accounting Handbook for Local Education Agencies. This was last revised in August 2010. Most importantly to this project, it specifically defines accounting categories for local schools in New Hampshire. While this is not a vocabulary for budgets, it is a vocabulary for school accounts. What a find!

The categories defined in the handbook are very similar to those used by Oyster River. Of course, they are not quite the same. But the match is clearly close enough to be very useful.

But, the document published by the NH DOE is a PDF! It is not a semantic vocabulary. It is at least a textual PDF and not just a scanned image. Over a weekend I copied the text and edited it into HTML for the relevant sections (Appendix A). I made sure the HTML was clean XML (XHTML actually) so I could use XSLT to transform it into at least a skeleton of an RDF vocabulary, once I figured out what that meant.

After first trying to just transform the account categories into vanilla RDF resource descriptions, I stumbled onto the Simple Knowledge Organization System (SKOS). This is another offical part of the W3C semantic web. It is used to codify things like classification systems as an RDF vocabulary. It is a great fit for the NH DOE accounting categories. SKOS even has a way of relating similar vocabularies like the Oyster River categories to the NH DOE categories.

So, I changed my XSLT stylesheet to transform the XHTML page into a SKOS vocabulary. It took a bit of tweaking, but in the end I think it is a great start. I hope soon that I can get it published on the ORCSD web site as our first piece of open data!

The NH DOE PDF on accounting categories illustrates a few key points of open data. The couple days work it took me to convert the PDF into RDF was very tedious. Even with some power search and replace it took hours and hours of editing. That is a good example of how hard it is to use a document that is not published as data.

The second point is that the accounting categories are a shared vocabulary. Not only do they refine Oyster River's accounts, but they also work for other school districts throughout New Hampshire (and maybe even broader). The single published vocabulary can be linked to by other districts who follow our example. And, when they do that, suddenly Oyster River budget data can be compared to that of other districts. Shared vocabularies applied to multiple data sets makes it easy to integrate all that data.

Why RDF?

A key aspect of open data is not just that some programs can easily read your data, but lots of programs. Interoperability. This means an open standard format. There aren't a lot of choices. Comma separated values (CSV) is a frequent choice. It is easy to import into a spreadsheet like Excel. Indeed, it makes sense that the data should be in at least CSV.

In my case, eXtensible Markup Language (XML) makes sense since I know it well and more importantly I know eXtensible Stylesheet Language Transformations (XSLT) well so I can take a single XML document and make it available as XML, CSV, HTML, etc. I could even produce a PDF!

But CSV and XML both lack a key thing. They don't tell you what the data means. Or, more importantly they don't tell a program what the data means. The only standard, open way I've found to format data that tells programs what it means is Resource Description Framework (RDF). RDF supports five star data as Tim Berners-Lee calls it. Data that has the greatest potential for applications on the semantic web. Given my preference for XML, RDF/XML seems best.

But, RDF also has its drawbacks. It is quite abstract and complicated. It is verbose. It requires someone with a good domain knowledge and technical skill to find or create the vocabularies that define what the data means. But, I am hoping that its flexibility will make it more tolerant of mistakes, especially by a newbie like me. To help illustrate some of the challenges or RDF, I found a podcast on the semantic web for educators on iTunes. It's free and gives a good introduction to the semantic web, but it is a bit dry. It does talk about possible applications of the semantic web in education that you may find interesting.

As a follow up to an earlier post about a decision last week to split the capital improvement projects into separate warrant articles for separate votes, the school board last night revisited the issue (something they do a lot) and reversed their decision. It is now back to a single article as it has been since its inception.

Sunday, January 9, 2011

Why Open Data?

The general benefits of open data can be found easily using Google. Here's a good example by Tim Berners-Lee. He calls it linked data in this video.

The Advisory Budget Committee (ABC) doesn't really need open data to do its work, but open data would make its work much easier. Why? Without open data, when the ABC has a question it has to ask the district for the data to answer that question. Each set of data answers some questions, but leads to more questions. The new questions beg for new data and new requests. Since the data is not readily available, questions go unanswered while the data is gathered. This slows the work of the ABC considerably. The delay can be several weeks.

If the wealth of budget data is regularly published as open data, then as questions come up, the data can simply be queried in a new way. The committee work turns into expressing the query instead of getting the data in the first place.

Open data can also save time and money for the district. For each request, whether by the ABC or a citizen, someone has to find the data to answer the request. Often, that person is an administrator since there aren't a lot of people in a small district who know the data. An administrator's time is expensive. Publish it once in a way that is easy to find and use, and let the web server answer all the requests.

Saturday, January 8, 2011

Usefulness

My kids loved Thomas the Tank Engine when they were little. One of the things I liked most about Thomas was when Mr. Conductor would tell Thomas, "You're a really useful engine." Particularly when it comes to technology, it is too easy to get lost in the bells and whistles and lose focus on whether it is really useful. As an engineer, I admit that I enjoy technology for its own sake. When I am struggling with a more difficult part of a project, say getting people to buy into an idea, it is a refuge to turn to a technical part instead.

Professionally, I have learned the value of starting a project by asking how it will be used. I took a course in Contextual Design several years ago that really opened my eyes to view projects this way. So, for this project I ask how will it be used?

The repeated request around the table of the Advisory Budget Committee was to get enough historical data to compare trends. At a minimum we wanted 3 to 5 years of actual expenditures for each item. In other budget discussions longer term data would have been useful. For example, at the last school board meeting the item of custodians came up. School board member JoAnn Portalupi mentioned how the number of custodians has been debated and changed for several years. Wouldn't it be great if the actual data for the last decade on the number of custodians was there to inform that discussion?

At the same meeting, there was also a discussion about capital improvement projects. Should all the projects be in a single warrant article asking for a single vote, or should each project have a separate article? Each year a handful of capital improvement projects to maintain the school facilities are proposed to the voters. We have had a decade of these proposals based on two 5-year capital improvement plans (CIPs). Until now, they have been proposed as a single warrant article each year. For this year, several people supported separate warrant articles. They argued that separate articles would reduce the chance of the whole plan losing because voters opposed individual projects. I argued based on my collection of data over the last decade of elections that the single article each year has gotten the highest voter approval consistently, sometimes between 70 and 80%. Unfortunately, I was only able to refer to the data since it was not readily available. Needless to say, the decision was to vote contrary to historical fact. But, this is another example of how longer term data could inform better decisions.

Time is not the only comparison sought by the Advisory Budget Committee. We struggled quite a bit with comparisons between different parts of the budget. The way the budget data was categorized had clearly devolved over the years so the categories were not clear. Even questions like what portion of the budget is for special education were almost impossible to answer accurately. This is particularly problematic since revenues from federal and state reimbursements are based on identified special education expenditures.

Perhaps the hardest way to compare budget data is against other districts. In New Hampshire at least, each school district has considerable latitude. The state collects very high level data each year based on various forms like the MS-25. But, more detailed data is not available, let alone available as data that is easy to compare. Ideally, being able to compare detailed data between school districts would be very useful.

So, I think being able to compare budget data over time, within categories and even between school districts would be make this project "a really useful engine."

Oyster River Schools Semantic Web

I live in the small town of Durham, New Hampshire in the United States. I've lived here for many years. My children have all gone to the local Oyster River Cooperative School District (ORCSD). As most parents, my wife and I have been active volunteers in our children's schools over the years. My first official role was as Treasurer for the elementary school Parent Teachers Organization. I graduated from there to serve on the local school board for 12 years. After losing re-election last year, I volunteered for the newly formed Advisory Budget Committee. I have also served for many years on the Long Range Planning Committee whose only purpose is to project student enrollment each year.

A common theme and frustration for my involvement in the schools has been data. Financial data, enrollment data, participation data, assessment data, employment data. There is a lot of data in public education, but getting access to that data is a struggle.

My goal for this blog is to chronicle my new project: publish ORCSD data on the web. Actually, I had a similar side project many years ago before I joined the school board. I had a web site named Oyster River On-Line (OROL). The name shows the early state of technology at the time when sites were published more through on-line modem pools instead of the interconnected world wide web. Anyway, on OROL I published documents that I collected from the school district before it had its own web site.

Now, the district has its own web site, but it is still mostly just a repository for documents. The majority of those documents are textual, or even worse, image PDFs. That is, they are not in a form that can be used as data.

Why does that matter? It makes it much harder to find the data, and practically impossible to put the data embedded in the documents to good use. For example, the Advisory Budget Committee wanted to compare the recently proposed budget to a few prior years. The data just was not available in spite of repeated requests. It was hard enough to get the current budget data as an Excel spreadsheet, let alone any historical data beyond last year. That makes it very difficult to look at trends to see how a proposed budget compares to how money was actually spent. That's a very useful way to judge a budget, but without the data we couldn't do it.

I am a software engineer in real life, or at least that is what I get paid to do. Indeed, part of the technologies I work with are web technologies: HTML, CSS, JavaScript, XML, DOM, JSP, etc. I have a reasonable amount of experience working with relational databases, and more generic programming technologies like C++, C, Java and Linux.

So, I feel competent to tackle this project by combining my knowledge of the school system and my knowledge of software. Or so I thought. After a while Googling for similar projects on the web, I was surprised how little I found that was a close enough match. What seems to be the best technology fit is the World Wide Web Consortium (W3C) Semantic Web. This is an open standard for data on the web that has been adopted by the US, UK and other national governments as well as many states and even some cities in the US. As an open standard it will make any data we publish available to anyone else on the web, so they can combine it or apply it in lots of new ways. That's exciting!

But, the semantic web uses a whole bunch of new technologies. This includes the Resource Description Framework (RDF), Web Ontology Language (OWL), Simple Knowledge Organization System (SKOS) and others. Through my web work I am comfortable reading W3C standard recommendations like those covering these semantic web technologies. But, these recommendations are dealing with very abstract concepts. Either they read like a treatise in philosophy or overly simple examples. I have yet to find a basic down-to-earth example of how to apply the semantic web to a practical problem like publishing data for a school budget.

I hope that by chronicling my journey up the learning curve of the semantic web for this practical project that I can get help from others and pass help along as well. C'est parti!