title: Flesch-Kincaid readability test in python
body: <p>I need help with this problem I'm having. I need to write a function that returns a FRES (Flesch reading-ease test) from a text. Given the formula:</p>
  
  <p><a href="https://i.stack.imgur.com/oW9bQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oW9bQ.png" alt="enter image description here"></a></p>
  
  <p>In other words my task is to turn this formula into a python function.</p>
  
  <p>this is the code from the <a href="https://stackoverflow.com/questions/49251629/converting-readability-formula-into-python-function/49259380?noredirect=1#comment85541910_49259380">previous question I had</a>:</p>
  
  <pre><code>import nltk
  import collections
  nltk.download('punkt')
  nltk.download('gutenberg')
  nltk.download('brown')
  nltk.download('averaged_perceptron_tagger')
  nltk.download('universal_tagset')
  
  import re
  VC = re.compile('[aeiou]+[^aeiou]+', re.I)
  def count_syllables(word):
      return len(VC.findall(word))
  
  from itertools import chain
  from nltk.corpus import gutenberg
  def compute_fres(text):
      """Return the FRES of a text.
      &gt;&gt;&gt; emma = nltk.corpus.gutenberg.raw('austen-emma.txt')
      &gt;&gt;&gt; compute_fres(emma) # doctest: +ELLIPSIS
      99.40...
      """
  
  for filename in gutenberg.fileids():
      sents = gutenberg.sents(filename)
      words = gutenberg.words(filename)
      num_sents = len(sents)
      num_words = len(words)
      num_syllables = sum(count_syllables(w) for w in words)
      score = 206.835 - 1.015 * (num_words / num_sents) - 84.6 * (num_syllables / num_words)
  return(score)
  </code></pre>
  
  <p>And this is the result I get:</p>
  
  <pre><code>Failure
  Expected :99.40...
  
  Actual   :92.84866041488623
  
  **********************************************************************
  File "C:/Users/PycharmProjects/a1/a1.py", line 60, in a1.compute_fres
  Failed example:
      compute_fres(emma) # doctest: +ELLIPSIS
  Expected:
      99.40...
  Got:
      92.84866041488623
  </code></pre>
  
  <p>My task is to pass the doctest and result in 99.40...
  I'm also not allowed the change the following code since it was given to me with the task itself:</p>
  
  <pre><code>import re
  VC = re.compile('[aeiou]+[^aeiou]+', re.I)
  def count_syllables(word):
      return len(VC.findall(word))
  </code></pre>
  
  <p>I feel like I'm getting close but not sure why I get a different result. Any help will be much appreciated.</p>