2678777127 发表于 2018-2-11 12:09:16


            本文实例为大家分享了英文单词统计器php 实现,供大家参考,具体内容如下
程序开始运行, 按"浏览"钮选择一个英文文档, 再按"统计 Statistics"钮, 即可得到按字母顺序列出的所有单词,及其出现的次数
用于测试的数据文档: data.txt
驱动程序:word.php
output.php 和 StringTokenizer.php 是 要求在同一个文件夹中的程序
1. words_statistics_PHP.png   
http://files.jb51.net/file_images/article/201606/2016623154403481.png?2016523154417
2. word.php

td{
background-color:#CF6;
width:100px;
margin:5px;
}

0)
echo "Error: " . $_FILES["file"]["error"] . "
";
else {
$myfile = fopen($_FILES["file"]["tmp_name"], "r") or die("Unable to open file!");
$str = fread($myfile,filesize($_FILES["file"]["tmp_name"]));
$delim = "?\\,. /:!\"()\t\n\r\f%";
$st = new StringTokenizer($str, $delim);
echo '找到字符串: '.$st->countTokens();
$list=new LinkedList();
while ($st->hasMoreTokens()) {
$list->orderInsert($st->nextToken());
}
$list->words_count();
$list->traversal();
fclose($myfile);
}
}
?>
英文文档单词统计 Statistics on English words
程序开始运行, 按"浏览"钮选择一个英文文档, 再按"统计 Statistics"钮,
即可得到按字母顺序列出的所有单词,及其出现的次数

英文文档名 File Name:



页: [1]
查看完整版本: php英文单词统计器