Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
LabVIEW Zone LabVIEW Tools Network Resources LabVIEW Champions Student Corner User Groups Discussion Forum Code Sharing Learning Center

Coding Challenge - The Meta Keyword Generator - Results

 Challenge Description:

In this Coding Challenge, all contestants were to develop a VI which reads an HTML text file and then generates a meta keyword phrase by combining the four most commonly used words in that file.

The judging was performed by the following:
  1. The VIs were run using two text files: the first contained 37 words and was used to test the functionality of the entries. The second file contained 9,386 words and was used to test the efficiency of the submissions.
  2. VI performance was judged upon two criteria. First, they had to generate the correct meta keyword phrase. If they passed this test, then they were judged on the speed at which they generated this phrase. The time was running the VI 50 times and taking the average time required. The tests were run on a Windows XP PC with a Pentium III 866MHz processor.
  3. The coding style was judged according to the LabVIEW Style Guide.

 Coding Challenge Winner

 
Christian Altenbach : Winner of LabVIEW Zone Meta Keyword Generator Coding Challenge
Christian Altenbach is the Meta Keyword Generator Coding Challenge Champion! Christian has been developing with LabVIEW for eight years and currently works at UCLA in Los Angeles.
 

 Performance

Christian's VI correctly created the Meta Keyword phrase for both text files. For the first file, it completed in 1 millisecond. For the large file, Christian's VI correctly created the Meta Keyword phrase in 38 milliseconds!

To execute this efficiently, Christian's VI compresses all words in the file into a single DBL value for sorting and comparison. He describes his algorithm here:

The algorithm works in the following manner: assign a-z to the numbers 1-26 (by subtracting 96 from the U8 representation). These are then considered digits in a base27 number and represented as a DBL value as follows:

Number = (first letter + second letter * 27 + third letter * 27^2 ...)

It will overflow at 12 digits, so only the first 11 digits are OK. The mantissa of a DBL is 52 bits; this gives about 4.7 bits/character. Unfortunately, not all 64 bits are utilized, giving an effective ratio of 5.8 bits/character. (It is possible to put 13 characters in a DBL using type casting, but these solutions turned out to be 3x slower.) If the calculation is done using EXT precision, 13 characters are possible on windows (64 bit mantissa) with a slight speed penalty. (On a SUN, EXT has a 112 bit mantissa and words could be much longer!)

Speed is very critical here, because it is called once for each word. It might be a bit faster to flatten it out to the main diagram, eliminating all the subroutine call, but the current solution is nicer.

Decompression just reverses the process. Since this is called only 4x, speed is quite irrelevant.

After sorting the DBL array of compressed words, a single loop handles all the scoring with a series of nested case structures:

  1. Test if word is the same as previous iteration
    T: increment the word counter and go to next word
    F: Do test (2)
  2. Does the word count qualify for a current top 4 rank?
    T: Do test (3)
    F: go to the next word.
  3. Does the word match any word in the drop list?
    T: go to next word.
    F: Replace current 4th place with new word, sort the top 4, and place the score of the 4th place as new threshold for test (2).

Coding Style

Front Panel: Christian's submission also exhibited great coding style. All of his Front Panels were very clean and well-structured. All objects were aligned and easy for a user to understand.

Block Diagram: All of Christian's Block Diagrams demonstrate excellent coding style. In fact, his top-level VI Block Diagram only required one screen width. They are clean and organized and he uses comments to describe how his application runs. Additionally, his use of subVIs keeps his applications organized and easier to follow.

Icon/Connector Pane: Christian develops some very impressive icons. In this submission, he created compression and decompression VIs. His icons are posted here:

Compression VI: 
Decompression VI: 
These advanced icon designs make it much easier to follow his application on the Block Diagram.

Honorable Mentions

Kevin Price, Shane O'Neill, and Julien Lamaire also submitted very impressive solutions. Their VIs generated the Meta Keyword phrase from the large file (9,386 words) in the following times:

Developer Time for Phrase Generation
Kevin Price 47 ms
Shane O'Neill 56 ms
Julien Lamaire 106 ms

Congratulations to everyone who competed in the LabVIEW Zone Meta Keyword Generator Coding Challenge. Be sure to enter the newest Coding Challenge!