Can anyone please tell me where I am going wrong with this for loop which is meant to take as input a specific corpus, sample size and number of samples and then give the averages of the expected sentiment tokens, normalised lexical diversity and probability of short sentences. It is also meant to give me the standard deviation of these three statistics too. I'm a real beginner with Python so not really sure where I've gone wrong Thanks a lot in advance.
When I call for example
, the following output is given:
Code:
def test_iterate(corpus_reader, sample_size, number_of_samples): for i in xrange(number_of_samples): tokens = corpus_reader.sample_words_by_sents(sample_size) sents = corpus_reader.sample_sents(sample_size) expected_sentiment_tokens(tokens) normalised_lexical_diversity(tokens) prob_short_sents(sents) stats = expected_sentiment_tokens(tokens) stats_two = normalised_lexical_diversity(tokens) stats_three = prob_short_sents(sents) print "Average expected no of sentiment tokens: %s" % average(stats) print "Average normalised lexical diversity: %s" % average(stats_two) print "Average probability of short sentences: %s" % average(stats_three) print "Standard deviation of sentiment tokens: %s" % std(stats) print "Standard deviation of normalised lexical diversity: %s" % std(stats_two) print "Standard deviation of probability of short sentences: %s" % std(stats_three)
Code:
test_iterate(tcr, 500, 3)
Code:
127.333333333 2.08398681196 0.506 116.25 2.21737363871 0.518 123.333333333 1.9821801535 0.534 Average expected no of sentiment tokens: 110.416666667 Average normalised lexical diversity: 2.89485940038 Average probability of short sentences: 0.518 Standard deviation of sentiment tokens: 0.0 Standard deviation of normalised lexical diversity: 0.0 Standard deviation of probability of short sentences: 0.0
Comment