Dictionary - Word Frequency revisited

Step One

Consider the following dictionary:

words={"the":3,"kenyon":2,"college":4,"learn":6,"python":2}

Can we writecode to add 1 to the number associated with Kenyon? Write code to enter a word and

Step Two

Write code to enter a word and if that word is in the dictionary, add one. If it is not, add the word with a 1. Then print the new dictionary

Step Three

Write a funciton countWords that we pass a dictionary and a string to it. For each word in the string it adds the word to the dictionary if it's not ther, with a 1, or it increments that number for that word is if is.

Step Four

Consider the code we wrote to find and count the words in Emily Dickenson. Can we improve this codes with a dictionary?

Now let's review the solution we did before with files:

https://repl.it/@JimSkon/EmilyDickinsonUnique

Let's fork this and try to modify it.

Step Five

Modify the code to use the countWords function

sol

Sol2

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2019-10-30 - JimSkon
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback