Dictionary - Word Frequency revisited

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

What approach should we take?

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


Let's fork this and try to modify it.

For all of these read the file only once

Step One

Write a function that, when passes a filename, returns the number of unique words in the dictionary. Use a dictionary.

Step Two

Can we write a function that, given a word, tells how many time that words occurs in the file (including 0 if there are none)

Step Three

Can we write a function that lists the lines in a file with matching words.


Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2019-03-26 - 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