I continued to work on the SCOSYA project this week, picking out a couple of big items from my ‘to do’ list and working through them. The first was adding in facilities to the Atlas attribute search to display only those ratings made in questionnaires where the interviewer was a fieldworker or a participant. I’ve also added this option to the ‘consistency’ page as well. I used a drop-down list instead of the checkboxes that Gary initially suggested for this. This is because if there is a ‘participant’ and a ‘fieldworker’ checkbox it would be confusing as to what happens when both are deselected – ‘neither’ is not a valid option but it would appear to be one. In the atlas limit options the ‘interviewed by’ limit is available for each selected attribute. Implementing this meant I had to update the API to incorporate the new search options. There are now 7 possible arguments that can be passed in an ‘attribute’ search, including attribute IDs, Boolean join types, age limits, number of people, rating levels and whether spurious data is included or not. I updated the API documentation to take this into consideration too.
The second item I looked at was to update the Atlas display when multiple attributes are joined by ‘or’ in order to display a different marker shape / colour to represent each possible combination. Working out an algorithm that can generate every single ‘present / absent’ permutation for any number of selected attributes proved to be rather difficult and I spent rather a long time attempting to get something working.
Given the number of variables I wanted to get back all possible permutations of them being true or false. For two or three variables this is really simple to just work out manually, but figuring out an algorithm that can do it automatically really stumped me. So, say you have two variables A and B that can either be true or false there would be four possible outcomes:
It feels like it should be simple to write a script that can output that but I just couldn’t seem to get there and for once I was struggling to find anything on Stackoverflow that helped either. I found some information about calculating different permutations of an array, such as here: http://docstore.mik.ua/orelly/webprog/pcook/ch04_26.htm and here: http://stackoverflow.com/questions/18935813/efficiently-calculating-unique-permutations-in-a-set but this isn’t quite the same issue as they are about switching the order of the elements rather than keeping the order the same but stating whether the elements are present or absent. I.e. the output of these scripts for an array containing A and B would be:
Now when you perform a search joined with ‘or’ the script works out every possible combination and assigns a randomly selected colour and shape to each. For example, if you have two attributes D3 and A9 selected then there are 4 possible combinations:
Y, N = beige five pointed star
Y, Y = purple 5 sided polygon
N, Y = yellow 7 sided polygon
N, N = grey square (not present is always a grey square and ‘present but not meeting your criteria’ is always a grey circle)
When the script places the markers on the map it checks which attributes are present at that location, matches it to one of the above and displays the appropriately shaped and coloured marker. This means you can tell at a glance where different combinations of attributes are located. Note that this doesn’t take into consideration the rating level – i.e. you can’t tell from looking at the map where high or low scores are. Here’s a screenshot of a new ‘or’ search in action:
As the colours and shapes are randomly assigned whenever you perform a search if you don’t like the ones currently displayed you can just press the ‘show’ button again and different ones will load in. Note also that this search works best when you supply some limit options. Without them an ‘or’ search tends to just bring back everywhere having both for a lot of attributes.
I’ve still not fully completed work on this as I still need to update the map legend. When I’ve done so the different colours and shapes and what they represent will be displayed in the legend and you’ll be able to show / hide one or more marker types using it (it might take some time to implement this, though). I also need to look into an issue with different colours / shapes not appearing when the same attribute with different limits is selected multiple times joined by ‘OR’.
Other than SCOSYA work I spent some time on AHRC review duties and also gave some feedback to Graeme about an AHRC Technical Plan he’s working on. I also responded to a researcher who was looking into ways of extracting text from eBook files, had a chat with Carole about some REELS related issues and responded to a query from Marc about new OED works in the Historical Thesaurus. I also had an email conversation with Hannah Tweed about a proposal she’s putting together (we’re going to meet to discuss it next week) and looked through some materials Johanna Green sent me relating to an exhibition website the we’re going to work on together (this was all arranged before she moved from English Language to HATII). I’ll be meeting with her next week too. I also updated all of my WordPress sites to version 4.7.2 and created a new ‘Song of the Week’ feature for the Burns website. For the next 10 weeks we’re going to be publishing a new song every Wednesday. You can find more information here: http://burnsc21.glasgow.ac.uk/