mcpField
R
readability-scorer

readability-scorer

github.com/dkyazzentwatwa文档处理12463 次安装29 周前更新
代码仓库

关于 readability-scorer

readability-scorer 使用多种公式分析文本可读性,适合编辑和文档编写者评估文本复杂度。它可批量分析和比较文本,但仅适用于英文,且不评估实际理解程度。

主要功能

  1. 01多种可读性公式评分
  2. 02估算美国年级水平
  3. 03计算阅读难易度分数
  4. 04统计词语、句子和音节
  5. 05批量分析与文本比较

适用场景

  1. 01评估文章的阅读难度
  2. 02对比文档修订前后的可读性
  3. 03批量检查文档目录中的文本
  4. 04查看文本复杂度统计

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/dkyazzentwatwa/chatgpt-skills --skill readability-scorer

安装后在 Claude Code 中输入/readability-scorer确认已加载。

附带文件scripts/readability_scorer.pyscripts/requirements.txt

详细介绍

可读性评分器

使用行业标准公式分析文本可读性。获取年级估算、复杂度指标以及提升清晰度的建议。

快速开始

from scripts.readability_scorer import ReadabilityScorer

# Score text
scorer = ReadabilityScorer()
scores = scorer.analyze("Your text to analyze goes here.")
print(f"Grade Level: {scores['grade_level']}")
print(f"Flesch Reading Ease: {scores['flesch_reading_ease']}")

功能

  • 多种公式:Flesch-Kincaid、Gunning Fog、SMOG、Coleman-Liau、ARI
  • 年级水平:美国年级水平估算
  • 阅读易读度:0-100 分的易读度评分
  • 文本统计:单词、句子、音节、复杂单词
  • 批量分析:处理多个文档
  • 对比:比较不同文本的可读性

API 参考

初始化
scorer = ReadabilityScorer()
分析
scores = scorer.analyze(text)
# Returns:
# {
#     'flesch_reading_ease': 65.2,
#     'flesch_kincaid_grade': 8.1,
#     'gunning_fog': 10.2,
#     'smog_index': 9.5,
#     'coleman_liau': 9.8,
#     'ari': 8.4,
#     'grade_level': 8.5,  # Average
#     'reading_time_minutes': 2.3,
#     'stats': {
#         'words': 250,
#         'sentences': 15,
#         'syllables': 380,
#         'complex_words': 25,
#         'avg_words_per_sentence': 16.7,
#         'avg_syllables_per_word': 1.52
#     }
# }
单项评分
# Get specific scores
fre = scorer.flesch_reading_ease(text)
fkg = scorer.flesch_kincaid_grade(text)
fog = scorer.gunning_fog(text)
smog = scorer.smog_index(text)
批量分析
texts = [text1, text2, text3]
results = scorer.analyze_batch(texts)

# From files
results = scorer.analyze_files(["doc1.txt", "doc2.txt"])
对比
# Compare two texts
comparison = scorer.compare(text1, text2)
print(f"Text 1 grade: {comparison['text1']['grade_level']}")
print(f"Text 2 grade: {comparison['text2']['grade_level']}")

CLI 用法

# Analyze text
python readability_scorer.py --text "Your text here"

# Analyze file
python readability_scorer.py --input document.txt

# Compare files
python readability_scorer.py --compare doc1.txt doc2.txt

# Batch analyze directory
python readability_scorer.py --input-dir ./docs --output report.csv

# Specific formula only
python readability_scorer.py --input doc.txt --formula flesch
CLI 参数
参数描述默认值
--text要分析的文本-
--input输入文件-
--input-dir文件目录-
--output输出文件(json/csv)-
--compare对比两个文件-
--formula指定公式all

评分解读

Flesch 阅读易读度
评分难度年级水平
90-100非常容易5 年级
80-89容易6 年级
70-79较容易7 年级
60-69标准8-9 年级
50-59较难10-12 年级
30-49困难大学
0-29非常困难大学毕业
年级水平量表
年级受众
1-5小学
6-8初中
9-12高中
13-16大学
17+研究生水平

示例

分析博客文章
scorer = ReadabilityScorer()

blog_post = """
Writing clear content is essential for engaging readers.
Short sentences help. Simple words work best.
Your audience will thank you for making things easy to understand.
"""

scores = scorer.analyze(blog_post)
print(f"Flesch Reading Ease: {scores['flesch_reading_ease']:.1f}")
print(f"Grade Level: {scores['grade_level']:.1f}")
print(f"Reading Time: {scores['reading_time_minutes']:.1f} minutes")

if scores['grade_level'] > 8:
    print("Consider simplifying for a wider audience.")
对比文档版本
scorer = ReadabilityScorer()

original = open("original.txt").read()
simplified = open("simplified.txt").read()

comparison = scorer.compare(original, simplified)

print("Original:")
print(f"  Grade Level: {comparison['text1']['grade_level']:.1f}")
print(f"  Flesch Ease: {comparison['text1']['flesch_reading_ease']:.1f}")

print("\nSimplified:")
print(f"  Grade Level: {comparison['text2']['grade_level']:.1f}")
print(f"  Flesch Ease: {comparison['text2']['flesch_reading_ease']:.1f}")

improvement = comparison['text1']['grade_level'] - comparison['text2']['grade_level']
print(f"\nImprovement: {improvement:.1f} grade levels easier")
批量分析文档
scorer = ReadabilityScorer()
import os

results = []
for filename in os.listdir("./docs"):
    if filename.endswith(".md"):
        text = open(f"./docs/{filename}").read()
        scores = scorer.analyze(text)
        results.append({
            'file': filename,
            'grade': scores['grade_level'],
            'ease': scores['flesch_reading_ease']
        })

# Sort by difficulty
results.sort(key=lambda x: x['grade'], reverse=True)

print("Documents by Difficulty:")
for r in results:
    print(f"  {r['file']}: Grade {r['grade']:.1f}")

依赖项

nltk>=3.8.0

局限性

  • 仅支持英语
  • 公式针对散文设计(可能不适用于列表、代码等内容)
  • 音节计数为估算值(可能存在轻微误差)
  • 不评估理解能力,只评估表层复杂度

评论

支持 Markdown