### Archive

Archive for July, 2010

## Word Frequency Analysis Program

Recently I was browsing for interesting programming problems and stumbled across a virtual “ghost town” of programming projects called  “Programming Fun Challenge”  While the activity has appeared to have died down long ago, most of the problems are still relevant and fun to tackle. I decided to take on the Word Count Challenge where you determine the word frequency for 35 of Shakespeare’s Plays.

The original post is here: Christmas Programming Fun Challenge 9

I did find the link to the book to analyze to be out of date, here is the corrected link: Shakespeare’s First Folio by William Shakespeare

Basic Strategy

• Read the entire file contents into meory
• Use a regular expression to break the text into words (ignoring all punctuation except apostrophes)
• Use a Hash Table (Dictionary<TKey, TValue> type) to keep track of each word and its frequency
• If the word hasn’t been seen before, add it to the Hash with a count of 1
• If the word has already been found, increment the count
• Sort the Hash in descending order based on the frequency count

Most of this behavior was captured in two methods. Here is the code:

```        public static Dictionary<string, int> AnalyzeWordFrequency(string textToAnalyze)
{
Dictionary<string, int> wordDistribution = new Dictionary<string,int>();
Regex allWordsPattern = new Regex(@"[w']+");
MatchCollection allWords = allWordsPattern.Matches(textToAnalyze.ToLower());
foreach(Match word in allWords)
{
if (wordDistribution.ContainsKey(word.Value))
{
wordDistribution[word.Value]++;
}
else
{
}
}

return wordDistribution;
}

public static void PrintDistributionToFile(Dictionary<string, int> distribution, string fileName)
{
StreamWriter dataWriter = new StreamWriter(new FileStream(fileName, FileMode.Create));
foreach(KeyValuePair<string, int> dataPoint in distribution.OrderByDescending(x => x.Value))
{
dataWriter.WriteLine(dataPoint.Key + " " + dataPoint.Value);
}
dataWriter.Close();
}
```

Word Frequency Data Collected With Program

Categories: Programming

## Ceramic Tile Mosaic

A few years back I took an art history class for fun with my wife.  The teacher her self was a local artist and was always looking for ways to teach without endless lectures and rote memorization. One of those approaches was an assignment to research a famous work of art and use it as inspiration for another piece in any medium.

I wanted something physical like sculpting or carving, but then the instructor gave me an idea I hadn’t considered: Mosaic. With modern materials and home stores there are actually a number of prefabricated tiles of precise size and color… but I decided to go the hammer and tile cutter route and do my version of Rodin’s “Thinker”.  I used normal ceramic tile fractured with a hammer and trimmed where needed to capture intricate details.  I spent about 30 hours on the project, much more than the minimum required, but time flew by as I was building it.

Materials

• Eye Protection
• Hammer
• Tile Cutter
• Putty Knife
• Ceramic Tiles (lots of them)
• Plexi Glass
• Permanent Marker
• Tile Cement
• Tile Grout
Categories: Art

## Coat Closet Shelves

With a growing family we are constantly running out of storage space.  One problem area has always been the coat closet. It had a single shelf with a bar to hang coats. I don’t think there has ever been a coat in this closet, but there has been a lot of food storage, camping equipment and miscellaneous children’s items.  So along with a friend I set out to reduce our storage woes and fight entropy.  The design I cam up with is the five shelf solution shown below.

The top two shelves feature a cut out to facilitate access to the topmost shelf. (which is nearly above the door frame) At a later time I will add finishing details to make these shelves have a little more curb appeal (simple molding, white paint) For now we have a simple and study shelving system.

Materials

• .75″ Plywood
• 1″ x 3″ boards
• Circular Saw
• Drill
• Wood Screws
• Bubble Level

The plan for the five shelves.

The final results before putting everything back in

## Read 100 Children’s Books With My Son in 6 Months

Success in my job requires a dedication to continuous learning. I want to instill that same love of learning in my children.  We always read, but I wanted to set a tangible goal to measure our progress. I set the bar at an arbitrary number of 100 books in six months with my 2 year old son. The challenge started in February 2010. All books had to meet the following criteria:

• My son had to pick the book (Many trips to the library…)
• We had to make it through the entire book
• Each book could only count once (even though most were read numerous times)

We were able to finish a bit ahead of schedule in June 2010. It was a great experience and I am looking forward to doing the same with my daughter as she gets older.

Here is the list:

1. B is for Bulldozer
2. Trucks Whiz! Zoom! Rumble!
3. Dig Dig Digging
4. Yankee Doodle
5. Under the Sea
6. Baby’s Book of Rhymes
7. If You Give a Mouse a Cookie
8. Goodnight, Little Hare
9. I’m a Big Brother!
10. The Foot Book
11. My Mom is Great
12. ABC
13. World of cars mini books
14. My Big Rig
15. Firebears The Rescue Team
16. When Papa Snores
17. First the Egg
18. Firefighters A to Z
19. Freight Train
20. Truck Duck
21. Arthur’s Teacher Moves in
22. Timothy and the Strong Pajamas
23. Jesus Wants Me for a Sun Beam
24. Hidden Treasures of the Book of Mormon
25. Owen
26. Babies
27. How Do I Love You
28. Buster Catches a Cold
29. Arthur’s Baby
30. Baby’s Book of Nature
31. The Party
32. I Can Do It Myself
33. I Spy At The Zoo
34. Oh, Bother! Someone’s Fibbing!
36. I Am Confident!
37. Are You My Mother?
38. I Can Make Good Choices
39. City Colors
40. The Little Engine That Could
41. Friday My Radio Flyer Flew
42. I Will Always Love You
43. Busy Busy City Street
44. A Rainbow All Around Me
45. Friends
46. Here Are My Hands
47. Puddles
48. Elmo’s Garden
49. Sir Arthur to the Rescue
50. Try It, You’ll Like It!
51. Arthur’s Birthday
52. A Silly Snowy Day
53. Froggy Plays In The Band
54. May the Best Engine Win!
55. Pooh and the Dragon
56. Love You Forever
57. Time’s Up
58. Mighty Movers Emergency
59. Tonka Look Inside Trucks
60. I want to be a firefighter
61. Three Little Pigs
62. Olive the Other Reindeer
63. No More Water In The Tub
64. Alexander and the Terrible, Horrible, No Good, Very Bad Day
65. The Great Race
66. Thomas Comes to Breakfast
69. Time
70. If You Take A Mouse To School
71. The Costume Party
72. What Time Is It Mr. Crocodile?
73. Silly Street
74. Big is Big (and little, little)
75. Arthur Goes to Camp
76. Miranda’s Beach Day
77. Hotshots!
78. Engine, Engine, Number Nine
79. This Truck
80. I’m the Biggest Thing in the Ocean
81. Time to Get Dressed
82. If You Give a Cat a Cupcake
83. D.W.’S Library Card
84. Tough Trucks
85. The Noisy Way to Bed
86. Those Shoes
87. Red Sled
88. Chuck’s Truck
89. Colors ABC Numbers
90. There Was an Old Woman That Lived in a Boot
91. Potty Time
92. The Trouble With Elephants
93. The Red Book
94. Arthur’s Underwear
95. D.W. Rides Again
96. Where The Wild Things Are
97. I’m Mighty!
98. Be Gentle!
99. ABC A Slide and Seek Book
100. Dogs In The Window