Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_average_sentence_length(text):
- text_replaced_a = text.replace("?", ".")
- text_replaced_b = text_replaced_a.replace("!", ".")
- sentences_in_text = text_replaced_b.split(".")
- words_mini_list = []
- for sentence in sentences_in_text:
- words_mini_list.append(sentence.split())
- sentences_with_their_word_lists = []
- sentence_lengths_list = []
- sentences_with_their_word_lists.append(words_mini_list)
- for sentence in sentences_with_their_word_lists:
- sentence_lengths_list.append(len(sentence))
- return sentence_lengths_list
- # words_and_sentences_list.append(sentence.split())
- # list_of_words = []
- #for sentences in sentences_in_text:
- # list_of_words.append(sentences.split())
- #sentence_lengths_list = []
- #for item in list_of_words:
- # sentence_lengths_list.append(len(item))
- return sentence_lengths_list
- #separate_words_by_comma = []
- #words_and_sentences_list = []
- #for sentence in sentences_in_text:
- # separate_words_by_comma.append(sentence.split())
- #words_mini_list = []
- # for word in sentence:
- # words_mini_list.append(word)
- #sentence_lengths_list = []
- #for item in words_and_sentences_list:
- # sentence_lengths_list.append(len(item))
- #return list_of_words
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement