To create the sketch for this week, I took the text from the main page of the syllabus for each of my classes this semester and played with it a bit. I thought it would be interesting to see if any patterns popped out!
After following along with the video “Coding Challenge #40.1: Word Counter in JavaScript”, I decided to see how much of that I could replicate myself after watching the video. I was able to get quite a bit of it without having to refer, unfortunately, I got stuck quite a bit. This exercise took about 3 hours to complete, but I really enjoyed taking about, smashing together, and looking to see if there were any interesting bits in the text.
If you’re curious, my classes this semester are “Programming A to Z”, “Reading and Writing Electronic Text”, “Time”, and “Imagination and Distributed Learning.” As far as the details of the execution of this sketch, I copied all of my syllabi from my classes and compiled them into one file called “syllabi.txt”. I didn’t do much massaging of the data beforehand, with the exception of removing student names, websites, and email addresses.
Following the challenge flow, I imported the text. I had it join by space, “ “, then broke up the text up by separating each thing that wasn’t a space and adding it to an array. Once I had the words in an array, I could see which ones were most and least common. From there, I broke the words up into groups based on how many occurrences there were of each word. (These groups are 100+, 50-99, 25-49, 15-24, 10-14, and then groups for each word that had 9, 8, 7, 6, 5, 4, 3, 2, and 1 instances in the text.)
Next, I created a sentence by displaying random words from each grouping arranged in order using the groupings above (in that order.) I also did a little work to figure out how to capitalize the first word of the sentence and added a number of random punctuation options to put at the end. I also tried creating a reset button, but I wasn’t able to figure out how to clear the previous text so that it didn’t show from behind, so I just left it off. One other quirk for this assignment is that there are a number of the last parts of contractions, ie ‘ve’, ‘s’, ‘t’ and a number of roman numbers that appear in the text; however, i did use a RegEx, (!/\d+/), to prevent numbers from appearing in the results.
If you want to check it out yourself, here’s a link to the sketch and the code used to produce it!
Personally, I didn’t necessarily feel like there was a pattern to pull from the sentences that came up for me; however, I do appreciate how the rarer words appear at the end of the sentence, making it more interesting as you go along. I hope you enjoy learning about what I’ll be learning about this semester!