counts average words per sentence
This commit is contained in:
parent
bcb74d57b7
commit
140495fe26
24
readability_is_king.py
Normal file
24
readability_is_king.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Readability is King Codewars Kata https://www.codewars.com/kata/52b2cf1386b31630870005d4
|
||||
|
||||
def avarage_words_sentence(text):
|
||||
sentences = text.split(".")
|
||||
sentences.pop(-1)
|
||||
|
||||
average_words_sentence = []
|
||||
|
||||
for sentence in sentences:
|
||||
sentence = sentence.split()
|
||||
average_words_sentence.append(len(sentence))
|
||||
|
||||
return sum(average_words_sentence) / len(average_words_sentence)
|
||||
|
||||
def avarage_syllables(text):
|
||||
vowels = {"a", "e", "i", "o", "u"}
|
||||
|
||||
def flesch_kincaid(text):
|
||||
average_words_sentence = avarage_words_sentence(text)
|
||||
avaraage_syllables = avaraage_syllables(text)
|
||||
|
||||
return average_words_sentence
|
||||
|
||||
print(flesch_kincaid("To be or not to be. That is the question."))
|
||||
Loading…
x
Reference in New Issue
Block a user