Ask your own question, for FREE!
Computer Science 14 Online
OpenStudy (anonymous):

can any one now python language

OpenStudy (e.mccormick):

I am not sure what you are asking, but Python is free any anyone can learn it.

OpenStudy (anonymous):

can you help me to solve this assignment

OpenStudy (e.mccormick):

Well, what part are you having trouble with? What did you try that gave you an error?

OpenStudy (anonymous):

i cannot understand average sentence function completely. can you help me to solve this function.and also compare signature function. plz help me'

OpenStudy (e.mccormick):

So these three: ``` def avg_sentence_length(text): """ (list of str) -> float Precondition: text contains at least one sentence. A sentence is defined as a non-empty string of non-terminating punctuation surrounded by terminating punctuation or beginning or end of file. Terminating punctuation is defined as !?. Return the average number of words per sentence in text. >>> text = ['The time has come, the Walrus said\n', 'To talk of many things: of shoes - and ships - and sealing wax,\n', 'Of cabbages; and kings.\n', 'And why the sea is boiling hot;\n', 'and whether pigs have wings.\n'] >>> avg_sentence_length(text) 17.5 """ # To do: Fill in this function's body to meet its specification. def avg_sentence_complexity(text): """ (list of str) -> float Precondition: text contains at least one sentence. A sentence is defined as a non-empty string of non-terminating punctuation surrounded by terminating punctuation or beginning or end of file. Terminating punctuation is defined as !?. Phrases are substrings of sentences, separated by one or more of ,;: Return the average number of phrases per sentence in text. >>> text = ['The time has come, the Walrus said\n', 'To talk of many things: of shoes - and ships - and sealing wax,\n', 'Of cabbages; and kings.\n', 'And why the sea is boiling hot;\n', 'and whether pigs have wings.\n'] >>> avg_sentence_complexity(text) 3.5 """ # To do: Fill in this function's body to meet its specification. def compare_signatures(sig1, sig2, weight): """ (list, list, list of float) -> float Return a non-negative float indicating the similarity of the two linguistic signatures, sig1 and sig2. The smaller the number the more similar the signatures. Zero indicates identical signatures. sig1 and sig2 are 6-item lists with the following items: 0 : Author Name (a string) 1 : Average Word Length (float) 2 : Type Token Ratio (float) 3 : Hapax Legomena Ratio (float) 4 : Average Sentence Length (float) 5 : Average Sentence Complexity (float) weight is a list of multiplicative weights to apply to each linguistic feature. weight[0] is ignored. >>> sig1 = ["a_string" , 4.4, 0.1, 0.05, 10.0, 2.0] >>> sig2 = ["a_string2", 4.3, 0.1, 0.04, 16.0, 4.0] >>> weight = [0, 11.0, 33.0, 50.0, 0.4, 4.0] >>> compare_signatures(sig1, sig2, weight) 12.000000000000007 """ # To do: Fill in this function's body to meet its specification. ```

OpenStudy (e.mccormick):

def avg_sentence_length(text) just averages the length of each string, so not too bad. def avg_sentence_complexity(text) will take a little more. You need to find what a phrase is, probably involves punctuation, and average the number of those. def compare_signatures(sig1, sig2, weight) needs everything else first. Then it does multiplicative weighting. Did they give an example of what multiplicative weighting is or do you ned help with that?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!