Rutherford Appleton Laboratory

cancel
Showing results for 
Search instead for 
Did you mean: 

User Group Challenge - June 2014 - Character Count

This meetings challenge was:

Create a VI that counts the number of occurrences of each character in a block of text and displays the information on the front panel.

Ignore case and only count alphabetic characters (i.e. 'a' through 'z').

0 Kudos
Message 1 of 4
(6,115 Views)

Here's my solution.

I used the native 'Search and Replace String' vi to count the occurence of each character. This has options to ignore case and to find all.

For the display I create a wordcloud using NI Vision vis.

Each letter size is scaled to correspond to it's frequency in the text and placed into an empty spot in the front panel image.

It tries to position each letter in the centre and spirals out until it finds a big enough space to place it.

Finally, you can make the picture prettier by changing the text to pink and adding a flowery border!

Bryan

0 Kudos
Message 2 of 4
(4,960 Views)

I see we are uploading soutions so here is my effort.

Basic operation:

Sample some existing text so I have an excuse to have a "generate" button

Go through the text an alphabetic character at a time, determine which letter it is by the byte-code and then increment the counts in the corresponding Counts Array. This can then be sorted by the number which is occurs most or least.

Produce an image of a periodic-table-esque "tile" using a cluster and a get control image invoke node. Arrange these images into a picture control which is displayed on the front panel.

John

0 Kudos
Message 3 of 4
(4,960 Views)

Here's my solution.

Dead simple: it converts a string to a byte value and then uses that value to increment an element in the counter array. The counted values are then displayed in an image control.

0 Kudos
Message 4 of 4
(4,960 Views)