Emily Dickinson Experiment (Part 1)

Moodle

Due Feb 14, 11:55 pm

You will turn in Repl.it links for 2, 7, 8

1. Lets' read some poetry, and see what we can do...

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

2. Could we count the number of times each vowel is used?

3. Can we break the lines into words?

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

4. Can we make a function countWords(word) to ask for a word and then count it?

5. What if we search for "see"? How about "see;"? How about "say", "say,', "Say", and "Say,"? What could we do about this?

6. Use the code from #3 to count the "was", and "was,". Why is there a difference? Consider the code below:

def removePunctuation(s):
  import string
  for c in string.punctuation:
    s= s.replace(c,"")
  return s

What does this code do? Call this on every line and search for "was". What changed?

7. Consider the function s.lower(), where s is a string. What does it do? How might this be useful to counts words?

8. Can you find and display all the lines that have a repeated word? Can you include the word, and the number of occurances in the line for each repeated word?

9. What would it take to create a list of all of the unique words and write them to a file, one word per line? More on this tonight!

Solutions

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2019-02-11 - 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