AI Hints
Home›NLP Tutorial›Scoring Language
NLP · Lesson 69 of 106

Readability

How hard is this to read?.

⏱ 2 min read▶ Video at 2:01:44🎓 Free
Watch this lesson in the NLP courseWatch on YouTube ↗Full NLP course

Bright Books' refund emails are written by the legal team. Customers keep calling, because they can't understand them. How can you measure whether writing is too hard? A formula from nineteen forty eight still does the job.

Readability
From the video: Readability
  • Refund emails written by lawyers
  • Customers can't understand them
  • A formula from 1948

Flesch reading ease

The formula uses only two things. How long the sentences are, and how long the words are. Long sentences and long words make text harder. We count syllables using a simple rule, as each group of vowels is about one syllable. Run it. The friendly message scores a hundred and two, which is very easy. The legal one scores minus one hundred and seventy six, which is off the bottom of the scale. Now you can check every template that you send. Add a limit, and flag anything too hard.

readability.pypython
import re

def syllables(word):
    return max(1, len(re.findall(r"[aeiouy]+", word.lower())))

def flesch(text):
    sentences = max(1, len(re.findall(r"[.!?]", text)))
    words = re.findall(r"[a-zA-Z]+", text)
    s = sum(map(syllables, words))
    return 206.835 - 1.015 * len(words) / sentences - 84.6 * s / len(words)

easy = "Your book is on its way. It will be here on Friday."
hard = "Notwithstanding unforeseen logistical complications, consignment remuneration necessitates additional administrative authorisation."
print(f"Easy text: {flesch(easy):.0f}")
print(f"Hard text: {flesch(hard):.0f}")
Output
Easy text: 102
Hard text: -176

Using readability

Use this as a quick check, rather than as a target. Aim for a score of sixty or above with general customers. It knows nothing about meaning, so nonsense in short words scores very well. But you can now combine this with a model. Ask a language model to rewrite a hard email, then check the result with this formula. That's a nice, simple, measurable loop.

Aim for 60+general customers
Not about meaningshort nonsense scores well
Combine with an LLMrewrite and check
Add to your pipelineflag hard templates

Summary

Short sentences and short words. Next, finding what your customers are talking about, with no labels at all.

Key takeaways
  • Sentence and word length
  • Check every template
  • Combine with rewriting
Next up: Clustering Text — why embeddings changed everything