1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-30 14:14:55 +08:00

Merge remote-tracking branch 'origin/koogua/v1.6.7' into koogua/v1.6.7

This commit is contained in:
xiaochong0302 2023-12-04 19:47:11 +08:00
commit 5268e6370c

View File

@ -14,13 +14,15 @@ class Word
public static function getWordCount($str) public static function getWordCount($str)
{ {
$imageWordCount = self::getImageWordCount($str);
$chineseWordCount = self::getChineseWordCount($str); $chineseWordCount = self::getChineseWordCount($str);
$str = self::filterChineseWords($str); $str = self::filterChineseWords($str);
$englishWordCount = self::getEnglishWordCount($str); $englishWordCount = self::getEnglishWordCount($str);
$count = $chineseWordCount + $englishWordCount; $count = $imageWordCount + $chineseWordCount + $englishWordCount;
return (int)$count; return (int)$count;
} }
@ -54,6 +56,11 @@ class Word
return (int)$count; return (int)$count;
} }
public static function getImageWordCount($str)
{
return 100 * substr_count($str, '<img');
}
public static function filterChineseWords($str) public static function filterChineseWords($str)
{ {
return preg_replace(self::CHINESE_PATTERN, '', $str); return preg_replace(self::CHINESE_PATTERN, '', $str);