Function Repository Resource:

ReadabilityScore

Source Notebook

Calculate the readability of a text using a standard formula

Contributed by: Jesse Friedman

ResourceFunction["ReadabilityScore"][text]

calculates the Flesch–Kincaid grade level score of text.

ResourceFunction["ReadabilityScore"][text,type]

calculates the readability score of text using readability test type.

ResourceFunction["ReadabilityScore"][{text1,text2,},]

calculates the readability score of the texti.

ResourceFunction["ReadabilityScore"][text,{type1,type2,}]

calculates the readability score of text using readability tests typei.

ResourceFunction["ReadabilityScore"][type]

represents an operator form of ResourceFunction["ReadabilityScore"] that can be applied to an expression.

Details and Options

The following readability tests are supported:
"ARI"Automated Readability Index grade level »
"ColemanLiau"Coleman–Liau grade level »
"ColemanLiauCloze"Coleman-Liau cloze fraction »
"FleschKincaid"Flesch–Kincaid grade level(default)»
"FleschReadingEase"Flesch Reading Ease score »
"FORCAST"FORCAST grade level »
"GunningFog"Gunning fog index grade level »
"LensearWrite"Lensear Write index
"Rix"Interpolated Rix grade level
"RixScore"Rix score
"SMOG"SMOG grade level »
ResourceFunction["ReadabilityScore"]["Types"] returns a list of supported readability tests.
For the "ColemanLiauCloze", "FleschReadingEase", and "LensearWrite" tests, higher values indicate higher readability. For all other tests, higher values indicate lower readability.
Grade level indices are meant to estimate the U.S. grade level (or number of years of education, for values greater than 12) generally required to understand the text.
ResourceFunction["ReadabilityScore"][type][text] is equivalent to ResourceFunction["ReadabilityScore"][text,type].
The following option is supported:
"UseWordData"Falsewhether to check WordData for syllable hyphenation and phonetic data
Some readability tests require syllable metrics, which are obtained using the resource function WordSyllables. By default, only the built-in syllabic heuristics in WordSyllables are used. Setting "UseWordData"True will cause WordSyllables to check WordData for hyphenation data, which may be slightly more accurate but generally takes longer.

Examples

Basic Examples (3) 

Calculate the Flesch-Kincaid grade level score of Rudyard Kipling’s The Jungle Book:

In[1]:=
ResourceFunction["ReadabilityScore"][ResourceData["The Jungle Book"]]
Out[1]=

Calculate the Rix score of Charles Darwin’s On the Origin of Species:

In[2]:=
ResourceFunction["ReadabilityScore"][
 ResourceData["On the Origin of Species"], "RixScore"]
Out[2]=

Calculate the Automated Readability Index grade level score of Stephen Wolfram’s A New Kind of Science:

In[3]:=
ResourceFunction["ReadabilityScore"][
 ResourceData["Full Text of A New Kind of Science"], "ARI"]
Out[3]=

Scope (4) 

Calculate the grade level of Lewis Carroll’s Through the Looking-Glass using multiple different readability tests:

In[4]:=
ResourceFunction["ReadabilityScore"][
 ResourceData["Through the Looking Glass"], {"FleschKincaid", "GunningFog", "Rix"}]
Out[4]=

Compare the Lensear Write scores for two novels involving gabled houses (higher values indicate higher readability):

In[5]:=
ResourceFunction["ReadabilityScore"][{
  ResourceData["Anne of Green Gables"],
  ResourceData["The House of the Seven Gables"]
  }, "LensearWrite"]
Out[5]=

Calculate the Automated Readability Index grade levels of several works of fiction by Sir Arthur Conan Doyle:

In[6]:=
books = ResourceSearch[{"Creator" -> "Arthur Conan Doyle", "ContentTypes" -> "Text"}, "ResourceObject"];
In[7]:=
scores = ResourceFunction["ReadabilityScore"]["ARI"] /@ Association[
   books // SortBy[AbsoluteTime@#["SourceMetadata", "Date"] &] // Map[#["Name"] -> ResourceData[#] &]]
Out[7]=

Chart the scores:

In[8]:=
BarChart[Reverse@scores, BarOrigin -> Left, ChartLabels -> Placed[Automatic, Left]]
Out[8]=

List the readability score types supported by ReadabilityScore:

In[9]:=
ResourceFunction["ReadabilityScore"]["Types"]
Out[9]=

Options (2) 

UseWordData (2) 

By default, readability tests which require syllabic metrics are restricted to using the (generally excellent) built-in heuristics in WordSyllables:

In[10]:=
AbsoluteTiming@
 ResourceFunction["ReadabilityScore"][ResourceData["The Jungle Book"]]
Out[10]=

Setting "UseWordData"True allows WordSyllables to look up syllable hyphenation in WordData, which may be slightly more accurate but can take significantly longer to access:

In[11]:=
AbsoluteTiming@
 ResourceFunction["ReadabilityScore"][ResourceData["The Jungle Book"],
   "UseWordData" -> True]
Out[11]=

Neat Examples (1) 

Calculate and plot the Flesch-Kincaid grade level indices of American presidents’ inaugural addresses over time:

In[12]:=
addressScores = ResourceData["Presidential Inaugural Addresses"][
   GroupBy[Key[
       "Date"] -> ({#Name, ResourceFunction["ReadabilityScore"][#Text, "FleschKincaid"]} &)]/*Map[First]/*KeySort];
In[13]:=
DateListPlot[{
  addressScores[
   TimeSeries[KeyValueMap[{#1, #2[[2]]} &, #]] -> Values[#][[All, 1]] &]
  }, Joined -> True, Mesh -> All, PlotStyle -> Dashed, ImageSize -> Large]
Out[13]=

Publisher

Jesse Friedman

Version History

  • 1.0.0 – 22 October 2019

Source Metadata

Related Resources

License Information