Question:
CS python!!!! help plz?
Kevin
2012-12-08 16:26:11 UTC
Problem 1
Following the pattern of the lecture slides, create plain text files consisting of at least two books each of
at least two authors. (Three or four authors is better.) Later, when we compare samples from the two
books by the same author we will expect them to have similar properties. When we compare samples
from different authors, we will expect to find distinguishing properties.


Problem 2
Write a function named getFileText() that has one parameter – the name of a file. Return the content of
the file as a string.


Problem 3
Write a function named makeCleanWordList() that takes one parameter – a string. Return a list of the
words in the string, excluding empty strings, with all punctuation stripped from the beginning and end
of each word and with all the words in lower case.


Problem 4
Write a function named makeWordDictionary() that takes one parameter – a list of words. Return a
dictionary of key:value pairs in which each key is a word in the list and its value is the number of
occurrences of the word.


Problem 5
Write a function named makeWordLengthDictionary() that takes one parameter that can be either a list
of words or a dictionary in which they keys are words. Return a dictionary in which each key is a word
length of some word in the parameter and the value of each key is the number of occurrences of words
of that length.


Problem 6
Write a function named makeParaLenDict() that takes one parameter – a string. You should assume that
paragraphs in the parameter string are delimited by two consecutive end lines ('\n\n'). Return a
dictionary of key:value pairs, where key is the length (in words) of a paragraph in the string parameter
and value of the key is the number of occurrences of paragraphs of that length.


Problem 7
Write a function named makeSentenceLenDict() that takes one parameter – a string. As in problem 6,
assume that the string parameter may contain multiple paragraphs delimited by two consecutive end
lines ('\n\n'). As a first approximation, assume that sentences within a paragraph are delimited by a
period and a space. (For better results, take into account other sentence delimiters.) Return a dictionary
of key:value pairs, where key is the length (in words) of a sentence in the string parameter and value of
the key is the number of occurrences of sentences of that length.


Problem 8
Apply the functions is problems 4, 5, 6 and 7 to the files created in Problem 1. Save the results as
pickled files (look this up in Python help). Upload the pickled files as solutions to Problem 8.
Three answers:
anonymous
2012-12-12 09:44:16 UTC
Use the .getfile method, see here: http://stackoverflow.com/questions/2186525/use-a-glob-to-find-files-recursively-in-python
anonymous
2017-01-01 11:50:34 UTC
the guy on YouTube is a liar. The longest one ever checklist became six ft, and that became woman. Ball pythons can't attain 8 ft. men frequently attain approximately 3 to 4 ft, each and every from time to time 5. And a 10 gall aquarium will suffice for a infant, and a thirty gallon could be ultimate for an person, I desire 40 gallons, in spite of the undeniable fact that.
padillo
2016-12-08 14:47:27 UTC
the guy on YouTube is a liar. The longest one ever checklist became six ft, and that became lady. Ball pythons won't be able to attain 8 ft. adult males many times attain approximately 3 to 4 ft, sometimes 5. And a 10 gall aquarium will suffice for a toddler, and a thirty gallon could be ultimate for an grownup, I desire 40 gallons, inspite of the undeniable fact that.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...