Skip to content

Commit

Permalink
Add Gunning Fog Index calculation and documentation to readability me…
Browse files Browse the repository at this point in the history
…trics notebook
  • Loading branch information
dkhundley committed Dec 15, 2024
1 parent 4e3087d commit e2be905
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion notebooks/text/readability_metrics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"outputs": [],
"source": [
"# Importing the necessary Python libraries\n",
"from whetstone.metrics.text.readability_metrics import calculate_flesch_kincaid_reading_ease, calculate_flesch_kincaid_grade_level"
"from whetstone.metrics.text.readability_metrics import calculate_flesch_kincaid_reading_ease, calculate_flesch_kincaid_grade_level, calculate_gunning_fog_index"
]
},
{
Expand Down Expand Up @@ -121,6 +121,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Flesch-Kincade Reading Ease\n",
"\n",
"The Flesch-Kincade Reading Ease metric is a readiability formula used to assess teh complexity of English texts by assigning a score that reflects how easy or difficult it is to understand.\n",
"\n",
"This metric measures the readability of a text on a scale from 0 to 100, with higher scores indicating easier readability. The formula for the Flesch-Kincaid Reading Ease score is:\n",
Expand Down Expand Up @@ -215,6 +217,66 @@
"print(f'Low quality text: {low_quality_flesch_kincaid_grade_level_score}')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Gunning Fog Index\n",
"The Gunning Fog Index is a readability metric used to estimate the complexity of English-language text and the level of education required to understand it on a first reading. It was developed by Robert Gunning in 1952 and is widely applied in journalism, business communication, and education to assess whether written material is appropriate for its intended audience.\n",
"\n",
"The formula for the Gunning Fog Index is:\n",
"\n",
"$$\n",
"0.4 \\times (\\text{average words per sentence} + 100 \\times \\text{percentage of complex words})\n",
"$$\n",
"\n",
"The following table provides an interpretation of the Gunning Fog Index:\n",
"\n",
"| Fog Index Score | Description | Target Audience |\n",
"|------------------|------------------------------------------|--------------------------------------|\n",
"| **7-8** | Easy to read | Suitable for middle school students |\n",
"| **9-12** | Moderately difficult | Suitable for high school students |\n",
"| **13-16** | Difficult | Requires college-level reading |\n",
"| **17+** | Very complex | Suitable for post-graduate level |\n",
"\n",
"To optimize the Gunning Fog index, consider applying the following strategies:\n",
"\n",
"- Use shorter sentences.\n",
"- Avoid complex words where simpler alternatives exist.\n",
"- Focus on clarity and brevity."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Results for Gunning Fog Index:\n",
"High quality text: 15.422296918767508\n",
"Low quality text: 8.670723684210527\n"
]
}
],
"source": [
"# Calculating the Gunning Fog Index score for the high and low quality text\n",
"print('Results for Gunning Fog Index:')\n",
"high_quality_gunning_fog_index_score = calculate_gunning_fog_index(high_quality_text)\n",
"low_quality_gunning_fog_index_score = calculate_gunning_fog_index(low_quality_text)\n",
"print(f'High quality text: {high_quality_gunning_fog_index_score}')\n",
"print(f'Low quality text: {low_quality_gunning_fog_index_score}')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit e2be905

Please sign in to comment.