なぜテキスト統計が必要なのか?
| シーン |
必要な指標 |
| SEO 最適化 |
文字数、キーワード密度、可読性 |
| コンテンツ価格設定 |
文字数、読了時間 |
| 学術論文 |
文字数(中文・英文を分けて集計) |
| ソーシャルメディア |
文字数(280/2000 制限) |
| 翻訳の見積もり |
文字数/単語数 |
中文と英文の文字数カウントの違い
核心的な問題:中文には単語を区切るスペースがない
英文:Hello World → 2 単語(スペース区切り)
中文:你好世界 → 4 文字(1 文字ずつ)か 2 語(你好/世界)か?
3 つのカウント方法
| 方法 |
アルゴリズム |
"你好World" の結果 |
適用シーン |
| 文字数 |
すべての文字 |
7 |
ソーシャルメディアの制限 |
| 字/語数 |
中文は字単位、英文は単語単位 |
6(4 字 + 2 語) |
コンテンツ価格設定、SEO |
| バイト数 |
UTF-8 エンコード長 |
10(4×3 + 2×1) |
ストレージ容量 |
JavaScript 実装
function countText(text: string) {
// ゼロ幅文字を除去
const clean = text.replace(/[\u200B-\u200D\uFEFF]/g, '');
// 文字数
const charCount = clean.replace(/\s/g, '').length;
// 中文の字数
const chineseChars = (clean.match(/[\u4e00-\u9fff]/g) || []).length;
// 英文の単語数
const englishWords = (clean.match(/[a-zA-Z]+/g) || []).length;
// 数字のグループ数
const numbers = (clean.match(/\d+/g) || []).length;
// 合計字/語数
const wordCount = chineseChars + englishWords + numbers;
// バイト数(UTF-8)
const byteCount = new TextEncoder().encode(clean).length;
// 行数
const lineCount = clean.split(/\n/).filter(l => l.trim()).length;
// 段落数
const paragraphCount = clean.split(/\n\s*\n/).filter(p => p.trim()).length;
return {
charCount,
wordCount,
chineseChars,
englishWords,
numbers,
byteCount,
lineCount,
paragraphCount,
};
}
読了時間の推定
計算式
中文の読書速度:約 500 字/分
英文の読書速度:約 200〜250 語/分
読了時間 = 中文字数 / 500 + 英文単語数 / 225
実装
function estimateReadingTime(text: string) {
const chineseChars = (text.match(/[\u4e00-\u9fff]/g) || []).length;
const englishWords = (text.match(/[a-zA-Z]+/g) || []).length;
const minutes = chineseChars / 500 + englishWords / 225;
if (minutes < 1) return '1 分未満';
if (minutes < 60) return `約 ${Math.ceil(minutes)} 分`;
const hours = Math.floor(minutes / 60);
const mins = Math.ceil(minutes % 60);
return `約 ${hours} 時間 ${mins} 分`;
}
コンテンツ種別ごとの読書速度
| コンテンツ種別 |
中文速度 |
英文速度 |
| 小説・随筆 |
500〜700 字/分 |
250〜300 語/分 |
| 技術ドキュメント |
300〜400 字/分 |
150〜200 語/分 |
| 法的文書 |
200〜300 字/分 |
100〜150 語/分 |
| ソーシャルメディア |
600〜800 字/分 |
300+ 語/分 |
キーワード密度分析
キーワード密度とは?
キーワード密度 = キーワード出現回数 / 総単語数 × 100%
例:
総単語数:500
「前端」が 15 回出現
密度 = 15 / 500 × 100% = 3%
SEO 推奨密度
| 密度 |
評価 |
| < 1% |
低すぎ。検索エンジンに重視されない可能性 |
| 1-3% |
✅ 最適な範囲 |
| 3-5% |
やや高め。自然さに注意 |
| > 5% |
❌ キーワードスタッフィング。ペナルティの恐れ |
実装
function analyzeKeywordDensity(text: string, keyword: string) {
const regex = new RegExp(keyword, 'gi');
const occurrences = (text.match(regex) || []).length;
const chineseChars = (text.match(/[\u4e00-\u9fff]/g) || []).length;
const englishWords = (text.match(/[a-zA-Z]+/g) || []).length;
const totalWords = chineseChars + englishWords;
const density = (occurrences / totalWords) * 100;
return {
keyword,
occurrences,
totalWords,
density: density.toFixed(2) + '%',
evaluation: density < 1 ? '低すぎ' : density <= 3 ? '最適' : density <= 5 ? '高め' : '過剰',
};
}
テキスト可読性スコア
Flesch Reading Ease(英文)
スコア = 206.835 - 1.015 × (総単語数/総文数) - 84.6 × (総音節数/総単語数)
スコア対応表:
90-100 非常に易しい(小学 5 年生)
60-70 標準(中学 2〜3 年生)
30-50 難しい(大学生)
0-30 非常に難しい(専門・学術)
中文の可読性
中文には音節の概念がないため、通常は平均文長で評価します:
function chineseReadability(text: string) {
const sentences = text.split(/[。!?;\n]/).filter(s => s.trim());
const chineseChars = (text.match(/[\u4e00-\u9fff]/g) || []).length;
const avgSentenceLength = chineseChars / sentences.length;
if (avgSentenceLength <= 15) return { score: '読みやすい', level: '一般向け' };
if (avgSentenceLength <= 25) return { score: '適度', level: '標準' };
if (avgSentenceLength <= 40) return { score: 'やや難しい', level: '専門的' };
return { score: '難しい', level: '学術的' };
}
ツールボックスでテキストを集計する
- 文字数カウントツールを開く
- テキストを貼り付けるか入力
- 自動表示:文字数、字/語数、行数、段落数、読了時間
- 中文・英文混合の集計に対応
SEO ライティング最適化の実践
1. タイトルの長さ
// Google の表示は約 60 文字(中文なら約 30 字)
function checkTitle(title: string) {
const length = title.length;
return {
length,
status: length <= 60 ? '✅' : '❌ 60 文字超過',
};
}
2. ディスクリプションの長さ
// Google の表示は約 160 文字(中文なら約 80 字)
function checkDescription(desc: string) {
const length = desc.length;
return {
length,
status: length <= 160 ? '✅' : '❌ 160 文字超過',
};
}
3. 本文の長さ
| ページ種別 |
推奨文字数 |
| ブログ記事 |
1500〜3000 字 |
| 製品ページ |
300〜800 字 |
| トップページ |
300〜500 字 |
| チュートリアル |
2000 字以上 |
4. キーワードの配置
✅ 良い配置:
タイトルにキーワードを含む
第 1 段落にキーワードを含む
本文中に自然に 3〜5 回出現
H2/H3 小見出しに変化形を含む
❌ 悪い配置:
すべての段落でキーワードを繰り返す
文脈と無関係なキーワード
非表示テキストでのスタッフィング
よくある質問
Word とオンラインツールで集計結果が違う?
Word の「文字数」集計ルールはオンラインツールと異なる場合があります:
- Word 2019 以降は中文を「字」単位で集計
- 一部のツールは中文を「文字」単位で集計
- 1 つのツールに統一することを推奨。見積もりのトラブルを回避できます
コード中のコメント率を集計するには?
function commentRate(code: string, language: string) {
const totalLines = code.split('\n').length;
let commentLines = 0;
if (language === 'javascript') {
const singleLineComments = (code.match(/\/\/.*/g) || []).length;
const multiLineComments = (code.match(/\/\*[\s\S]*?\*\//g) || []).length;
commentLines = singleLineComments + multiLineComments;
}
return (commentLines / totalLines * 100).toFixed(1) + '%';
}
まとめ
テキスト統計は単純に見えて奥が深いものです。中英混合の集計、読了時間の推定、キーワード密度分析にはそれぞれコツがあります。これらの指標をマスターすれば、SEO 最適化、コンテンツ価格設定、翻訳見積もりのいずれでも確かな判断ができます。ツールボックスの 文字数カウントツールなら、すべての指標をワンクリックで取得でき、コンテンツ作成に集中できます。