日本語の文字数と内訳 / Japanese Text Breakdown
日本語
開いている文書か選択範囲の文字を数えて、数だけを表示します。
- ステータスバー:「文字 1,234」。選択があれば「選択 56 / 文字 1,234」。数は「文字(書記素)」です。UTF-16 のコードユニットで 1,000,000 を超える文書は、ステータスバーでは数えず、コマンドで数えます。テキストのエディターがアクティブでないときと、内訳の画面がアクティブな間は、表示しません。
- コマンド「文字数の内訳を表示」(ステータスバーの数をクリックしても開きます):選択があれば選択範囲だけを、なければ文書の全体を数えます。内訳は実行した時点の数で、文書を変えても更新しません(数え直すには、もう一度実行します)。エディターの横に、読み取り専用のテキストで、次の数を表示します。
- 文字(書記素)、文字(改行を除く)、文字(空白と改行を除く)、行、文、いちばん長い文(書記素)
- 種類ごと:ひらがな(Script=Hiragana)、カタカナ(Script=Katakana)、漢字(Script=Han)、英字 A-Z a-z、全角英字 A-Z a-z、数字 0-9、全角数字 0-9、「、」「。」「,」「.」、空白と改行、その他
- 数えるのは、文書のテキストそのものです。Markdown の「#」や「*」などの記号も、ほかの文字と同じように数えます。
- このパッケージには、ブラウザー版の VS Code(VS Code for the Web)用の入口(
package.json の browser)がありません。ブラウザー版では確かめていません。
数え方
内訳の画面の「数え方」と同じ文です。
- 文字は、Intl.Segmenter(granularity "grapheme")で分けた書記素です。CR LF は 1 つです。
- 改行は CR LF、LF、CR です。空白は Unicode の White_Space です。「文字(改行を除く)」は改行を除き、「文字(空白と改行を除く)」は、最初のコードポイントが空白の書記素もすべて除きます。
- 行は改行で分けた数で、空の行を含みます。空の文書は 0 行です。
- 文は、最初のコードポイントが「。」「!」「?」「!」「?」の書記素の後、改行、テキストの終わりで区切ります。空白でない書記素がある文を数えます。長さは、両端の空白を除いた書記素の数で、区切りの記号があれば含みます。例:
「行く。」 は 2 文です(「行く。 の 4 と 」 の 1)。
- 各書記素は、最初のコードポイントで、ちょうど 1 つの種類に入ります。ひらがな・カタカナ・漢字は、Unicode の Script の値 Hiragana・Katakana・Han です。「々」は Script=Han なので漢字に、長音符「ー」は Script=Common なので「その他」に入ります。「その他」は、ほかのどの種類にも入らない書記素です。
- 選択が複数あるときは、選択ごとに数えて足します。いちばん長い文は、そのうちの最大の数です。
- これは数だけです。文章の良し悪しや正しさは表しません。
通信も保存もしません。 この拡張は、ネットワークに接続せず、ファイルに書き込まず、設定や履歴も保存しません。数えた結果は、表示のためにメモリに置くだけで、内訳の文面は最新の 1 回分だけを持ちます。
English
Counts the characters in the open document or the selection and shows the numbers only.
- Status bar: "Characters 1,234", or "Selection 56 / Characters 1,234" when text is selected. The number is "Characters (graphemes)". Documents longer than 1,000,000 UTF-16 code units are not counted in the status bar; run the command. The item is hidden while no text editor is active and while the breakdown page is the active editor.
- Command "Show the character count breakdown" (also opened by clicking the status bar item) counts the selection when there is one, otherwise the whole document. The breakdown holds the numbers at the time of the command and is not updated when the document changes (run the command again to count again). It opens beside the editor as read-only text and shows:
- Characters (graphemes), Characters without line breaks, Characters without white space and line breaks, Lines, Sentences, Longest sentence (graphemes)
- By kind: Hiragana (Script=Hiragana), Katakana (Script=Katakana), Kanji (Script=Han), Letters A-Z a-z, Fullwidth letters A-Z a-z, Digits 0-9, Fullwidth digits 0-9, 、 。 , ., White space and line breaks, Other
- What is counted is the text of the document as it is: Markdown markup such as # or * is counted like any other character.
- The package has no entry point for VS Code for the Web (
browser in package.json). It has not been tested there.
How it counts
The same sentences as "How it counts" in the breakdown.
- A character is a grapheme as split by Intl.Segmenter (granularity "grapheme"); CR LF is one grapheme.
- Line breaks are CR LF, LF and CR. White space is Unicode White_Space. "Characters without line breaks" leaves out the line breaks; "Characters without white space and line breaks" also leaves out every grapheme whose first code point is white space.
- Lines are the pieces between line breaks, empty lines included; an empty document has 0 lines.
- A sentence ends after a grapheme whose first code point is 。 ! ? ! or ?, at a line break, or at the end of the text. A sentence counts when it has a grapheme that is not white space. Its length is its grapheme count without white space at both ends, the end mark included when there is one. For example,
「行く。」 is 2 sentences (「行く。 with 4 and 」 with 1).
- Each grapheme is counted in exactly one kind, decided by its first code point. Hiragana, katakana and kanji are the Unicode Script values Hiragana, Katakana and Han: 々 is Script=Han and counts as kanji, and the long vowel mark ー is Script=Common and counts as Other. Other holds every grapheme that is in none of the other kinds.
- With several selections, each selection is counted on its own and the numbers are added; the longest sentence is the largest of them.
- These are counts only. They do not say whether a text is good or correct.
No network, nothing stored. The extension makes no network connection, writes no files and stores no settings or history. The counts are held in memory only to display them, and only the text of the latest breakdown is kept.
ライセンス / License
MIT License(全文は同梱の LICENSE.txt)。 / MIT License (full text in the bundled LICENSE.txt).
Author
sitebuild-note — https://sitebuild-note.pages.dev/
| |