Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 KB | None | 0 0
  1. def get_average_sentence_length(text):
  2.     text_replaced_a = text.replace("?", ".")
  3.     text_replaced_b = text_replaced_a.replace("!", ".")
  4.     sentences_in_text = text_replaced_b.split(".")
  5.  
  6.    
  7.  
  8.     words_mini_list = []
  9.     for sentence in sentences_in_text:
  10.         words_mini_list.append(sentence.split())
  11.    
  12.     sentences_with_their_word_lists = []
  13.     sentence_lengths_list = []
  14.    
  15.    
  16.     sentences_with_their_word_lists.append(words_mini_list)
  17.    
  18.     for sentence in sentences_with_their_word_lists:
  19.         sentence_lengths_list.append(len(sentence))
  20.            
  21.     return sentence_lengths_list  
  22.    
  23.  
  24.     # words_and_sentences_list.append(sentence.split())
  25.        
  26.  
  27.     #   list_of_words = []
  28.     #for sentences in sentences_in_text:
  29.      #   list_of_words.append(sentences.split())
  30.  
  31.    
  32.     #sentence_lengths_list = []
  33.     #for item in list_of_words:
  34.      #   sentence_lengths_list.append(len(item))
  35.     return sentence_lengths_list    
  36.    
  37.     #separate_words_by_comma = []
  38.     #words_and_sentences_list = []
  39.     #for sentence in sentences_in_text:
  40.      #   separate_words_by_comma.append(sentence.split())
  41.        
  42.     #words_mini_list = []
  43.    
  44.      #   for word in sentence:
  45.       #      words_mini_list.append(word)
  46.    
  47.     #sentence_lengths_list = []
  48.     #for item in words_and_sentences_list:
  49.      #   sentence_lengths_list.append(len(item))
  50.            
  51.    
  52.     #return list_of_words
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement