相关疑难解决方法(0)

Flesch-Kincaid可读性:改进PHP功能

我编写了这个PHP代码来实现Flesch-Kincaid可读性分数作为函数:

function readability($text) {
    $total_sentences = 1; // one full stop = two sentences => start with 1
    $punctuation_marks = array('.', '?', '!', ':');
    foreach ($punctuation_marks as $punctuation_mark) {
        $total_sentences += substr_count($text, $punctuation_mark);
    }
    $total_words = str_word_count($text);
    $total_syllable = 3; // assuming this value since I don't know how to count them
    $score = 206.835-(1.015*$total_words/$total_sentences)-(84.6*$total_syllables/$total_words);
    return $score;
}
Run Code Online (Sandbox Code Playgroud)

您有如何改进代码的建议吗?这是对的吗?它会起作用吗?

我希望你能帮助我.提前致谢!

php readability formula flesch-kincaid

7
推荐指数
3
解决办法
2725
查看次数

计算字符串中的句子数

如何计算给定字符串中的句子数?

c# string

2
推荐指数
2
解决办法
3219
查看次数

标签 统计

c# ×1

flesch-kincaid ×1

formula ×1

php ×1

readability ×1

string ×1