検索用語を入力
検索フォームを送信
my-Tool.com: 文字列とテキスト - 文字列とテキストを操作する。 - 統計
IPアドレス
MaximaPHP
正規表現テスタ
数学
ゲーム
ネットワーク
インターネットコード
日付と時間
文字列とテキスト
ワードドメイン
コードテスタ
ビーワイズビット
ランキン
質問と答え
僕について
フォーラム
AdManner
無料広告サイト
インドネシア語
英語
スプレッドシート
ケース変換
サイト抽出
EditArea
置換
統計
TinyMCE
統計
サイズ、行数、単語数そして各単語の数といったテキストの統計を集計する。
このツールは動くのにJavaScriptが必要。ブラウザーでJavaScriptを使用可能にしてください。
統計 サイズ、行数、単語数そして各単語の数といったテキストの統計を集計する。 このテキストを自分のものに置き換えて、以下のボタンを押すことで統計情報を取得できる。 ごゆっくり統計取得を!
単語の分離文字:
非単語
アンダースコア (_)
数字 (0-9)、 その他:
大小文字区別しない
このツールを利用したほとんどのお客様は以下のツールも利用しました。
統計
(22.2%),
Tex
(11.1%),
Equations
(6.7%)
このツールのソースコードは以下に示す。
<?php /****************************************************************** * * Statistics, サイズ、行数、単語数そして各単語の数といったテキストの統計を集計する。 * Copyright (C) 2006, Bowo Prasetyo * * http://www.my-tool.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation below, * * http://www.gnu.org/licenses/gpl.html#TOC1 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * * このプログラムはフリーソフトウェアです。あなたはこれを、以下のURLにフリーソフトウェ * ア財団によって発行された GNU 一般公衆利用許諾契約書の定める条件の下で * 再頒布または改変することができます。 * * http://www.gnu.org/licenses/gpl.html#TOC1 * * このプログラムは有用であることを願って頒布されますが、*全くの無保証* * です。商業可能性の保証や特定の目的への適合性は、言外に示されたものも含 * め全く存在しません。詳しくはGNU 一般公衆利用許諾契約書をご覧ください。 * * あなたはこのプログラムと共に、GNU 一般公衆利用許諾契約書の複製物を一部 * 受け取ったはずです。もし受け取っていなければ、フリーソフトウェア財団ま * で請求してください(宛先は the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA)。 * *****************************************************************/ /** * 現在のツールを表示する * * @param int $depth インデックスページからどれぐらい深いか * @param string $qstring 親ツールのクエリー文字列 */ $nonword = 'yes'; $underscore = 'no'; $number = 'no'; $other = ''; $nocase = 'yes'; $text = <<<EOT 統計 サイズ、行数、単語数そして各単語の数といったテキストの統計を集計する。 このテキストを自分のものに置き換えて、以下のボタンを押すことで統計情報を取得できる。 ごゆっくり統計取得を! EOT; if(isset($_POST['text'])) { $text = trim(stripslashes($_POST['text'])); if(isset($_POST['nonword'])) $nonword = 'yes'; else $nonword = 'no'; if(isset($_POST['underscore'])) $underscore = 'yes'; else $underscore = 'no'; if(isset($_POST['number'])) $number = 'yes'; else $number = 'no'; if(isset($_POST['other'])) $other = $_POST['other']; if(isset($_POST['nocase'])) $nocase = 'yes'; else $nocase = 'no'; } ?> <script type="text/javascript"> google_ad_client = "pub-6269511881695171";ngoogle_alternate_ad_url = "http://www.my-tool.com/a120_90.php"; google_ad_width = 728; google_ad_height = 15; google_ad_format = "728x15_0ads_al_s"; google_ad_channel = ""; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "A9501B"; google_color_text = "000000"; google_color_url = "008000"; </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script><br /><br /> <script src="/statistics-ja.js"> </script> <noscript> このツールは動くのにJavaScriptが必要。ブラウザーでJavaScriptを使用可能にしてください。 </noscript> <form name="my_tool_form" action="#"> <textarea name="text" rows="20" cols="60"><?php echo $text ?></textarea><br> 単語の分離文字:<br> <input type="checkbox" name="nonword" value="yes" <?php echo $nonword=='yes'?'checked':'' ?>> 非単語 <input type="checkbox" name="underscore" value="yes" <?php echo $underscore=='yes'?'checked':'' ?>> アンダースコア (_) <input type="checkbox" name="number" value="yes" <?php echo $number=='yes'?'checked':'' ?>> 数字 (0-9)、 その他: <input type="text" name="other" size="5" value="<?php echo $other ?>"><br> <input type="checkbox" name="nocase" value"yes" <?php echo $nocase=='yes'?'checked':'' ?>> 大小文字区別しない <input type="button" value="統計を取得する" onClick="var stat = new Statistics(this.form.text.value, this.form.nocase.checked, this.form.nonword.checked, this.form.underscore.checked, this.form.number.checked, this.form.other.value); this.form.stat.value = stat.getStatistics(); return false;"><br> <textarea name="stat" rows="20" cols="60" style="border:none" readonly></textarea><br> </form> <br><br> <?php ?>
'statistics-ja.js'のソースコードは以下に示す。
<!-- hide script from old browsers /** * @fileoverview * テキスト中の単語の統計を集計するクラスを含んでいる * * <pre> * statistics.js, サイズや行数や単語数や各単語の数などのテキストの統計を集計する。 * * Copyright (C) 2006-2007, Bowo Prasetyo * * http://www.my-tool.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation below, * * http://www.gnu.org/licenses/gpl.html * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * * このプログラムはフリーソフトウェアです。あなたはこれを、以下のURLにフリーソフトウェ * ア財団によって発行された GNU 一般公衆利用許諾契約書の定める条件の下で * 再頒布または改変することができます。 * * http://www.gnu.org/licenses/gpl.html * * このプログラムは有用であることを願って頒布されますが、*全くの無保証* * です。商業可能性の保証や特定の目的への適合性は、言外に示されたものも含 * め全く存在しません。詳しくはGNU 一般公衆利用許諾契約書をご覧ください。 * * あなたはこのプログラムと共に、GNU 一般公衆利用許諾契約書の複製物を一部 * 受け取ったはずです。もし受け取っていなければ、フリーソフトウェア財団ま * で請求してください(宛先は the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA)。 * </pre> */ /** * Statisticsのオブジェクトを生成する * * @class * テキスト中の単語の統計を集計するクラス. * * <br><br>使用例: * <code><pre> * var stat = new Statistics('This is a sample_text1. The words of this sample_text2 will be counted.', false, true, false, true, ''); * document.write('<pre>'+stat.getStatistics()+'</pre>');</pre></code> * * 以上の例は以下の結果を出力する: * <br> * <pre> * Size : 71 bytes. * Lines : 1 * Words : 13 * * sample_text : 2 * : 1 * The : 1 * This : 1 * a : 1 * be : 1 * counted : 1 * is : 1 * of : 1 * this : 1 * will : 1 * words : 1 * </pre> * * @constructor * @param {String} text 統計を集計するテキスト * @param {bool} nocase 大・小文字を無視するかどうか * @param {bool} nonword 区切りとして非単語の文字を用いるかどうか * @param {bool} underscore 区切りとしてアンダースコアを用いるかどうか * @param {bool} number 区切りとして数字を用いるかどうか * @param {String} other 区切りとして他の文字を用いるかどうか * @author Bowo Prasetyo <praNzjOp@SgmaPilA.cMom> (take N O S P A M for email) */ function Statistics(text, nocase, nonword, underscore, number, other) { this.text = ''; if (nocase) this.text = text.toLowerCase(); else this.text = text; this.res = "["; if (nonword) this.res += "\\W"; if (underscore) this.res += "_"; if (number) this.res += "0-9"; if (other.length > 0) this.res += other; this.res += "]+"; if (this.res.length == 3) this.res = "\\W+"; this.re = new RegExp(this.res); } /** * キー・値のペアを格納するための内部クラス * * @param {Object} k キー * @param {Object} v 値 */ Statistics.prototype.keyval = function(k, v) { this.key = k; this.val = v; } /** * 値そしてキーを用いて配列を並べ替えるコールバックメソッド * * @param {keyval} a * @param {keyval} b * @return 並べ替えの順序 * @type int */ Statistics.prototype.sortByValue = function(a, b) { var c = b.val - a.val; return c===0?(a.key>b.key?1:a.key<b.key?-1:0):c; } /** * 単語の統計を取得する * * @return テキスト中の単語の統計 * @type String */ Statistics.prototype.getStatistics = function() { var lines = this.text.split("\n"); var wordNum = 0; var num = new Array(); var tmp = new Array(); var result, i, j, key; for (i=0; i<lines.length; i++) { var words = lines[i].split(this.re); wordNum += words.length; for (j=0; j<words.length; j++) { if (num[words[j]]===undefined) num[words[j]] = 1; else num[words[j]]++; } } i = 0; for (key in num) { tmp[i] = new this.keyval(key, num[key]); i++; } tmp.sort(this.sortByValue); result = "Size\t: "+this.text.length+" bytes.\n"; result += "Lines\t: "+lines.length+"\n"; result += "Words\t: "+wordNum+"\n\n"; for (i=0; i<tmp.length; i++) { result += tmp[i].key+"\t: "+tmp[i].val+"\n"; } return result; } // end hiding script from old browsers -->
©2006 my-Tool.com