Wednesday, July 2, 2014

Lloyd's Video Analysis Tool, Part 7: Generating Reports

I added the feature of generating some simple reports to the project. I am deliberating not including a video in this posting because I will reporting in my next post on my first public demonstration of the project prototype to my college held earlier today. That posting will include a short video introducing the current prototype from start to finish. I'll include a good overview of the the reporting features.

Two Report Options


As I've written elsewhere in this blog, I'm a big fan of using Excel whenever possible to help organize and analyze data from projects. So, I created an "Excel Ready" report option that creates and saves a comma-separated value (.csv) file to the user's hard drive. Here is an example of this "table style" report already opened in Excel:




From here, one can use Excel to sort, organize, or search the data.

I also created a second report option that produces a simple text document using a "label style" format. Here's an example already opened in the Mac's TextEdit application:



This could obviously be opened instead with Microsoft Word and then edited anyway the user wishes.

Other Report Options to Consider


There is obviously much more that can be done here. For example, I plan on providing the option to produce reports that only focus on certain tags or combinations of tags. Likewise, I plan on giving users the option to include or exclude categories of information. For example, the user may just want the comments, but not the tags or the time code.

Tag Summary Report


At the bottom of both reports, you can see I added a short "Tag Summary Report." This seemed like a very obvious and useful summary of some key information. The list processing strengths of LiveCode make these sorts of summaries easy to produce. I again use the strategy of having two "shadow fields" (fields the user can't see) in combination with two scripts:



The first script scans the entire video analysis data and builds a running log of all tags in the field "tags found." After this field is generated, a second script scans it to produce the field "unique tags" on the right. The contents of this second field is then copied to the bottom of the report using yet another field not shown here titled "report bin."

Here's the code for producing the Excel-ready version (the text only version only differs in the way it outputs the data):

//Create list of unique tags
   repeat with i = 1 to the number of lines in field "tags found"
      put false into varTagFound
      repeat with i2 = 1 to the number of lines in field "unique tags"
         if line i of field "tags found" = line i2 of field "unique tags" then 
            put true into varTagFound
            exit repeat
         end if
      end repeat
      if varTagFound = false then put line i of field "tags found" into line (the number of lines in field "unique tags"+1) of field "unique tags"
   end repeat
   
   //Count the use of each unique tag
   repeat with i = 1 to the number of lines in field "unique tags"
      put 0 into varCountTags
      repeat with j = 1 to the number of lines in field "tags found"
         if line i of field "unique tags" = line j of field "tags found" then add 1 to varCountTags
      end repeat
      put varCountTags into item 2 of line i of field "unique tags"
   end repeat
   
   put the number of lines in field "report bin" into l
   put "Tags used in this analysis:"&comma&"Frequency"&return into line l+2 of field "report bin"
   put field "unique tags" after field "report bin"
   
Yes, there is a lot of nested repeating going on here! But LiveCode somehow makes it easy to conceptualize these repeat structures in ways that other programming languages don't, at least for me.

Final Thoughts


These simple reports were the last major piece of the puzzle to creating a tool that would actually do something useful. Even if I stopped working on the project right now, I have a tool (albeit crude) that does some useful work. This is a very important milestone. Heck, I might almost be ready to declare that the project has moved from beta version 2 to beta version 3!


No comments:

Post a Comment