]> src.bluestatic.org Git - isso.git/blob - docs/tools/wordrunner.php
Update version number
[isso.git] / docs / tools / wordrunner.php
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 <head>
5 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
6 <title>WordRunner</title>
7 </head>
8 <body>
9
10 <?php
11
12 error_reporting(E_ALL & ~E_NOTICE);
13
14 // ### END HTML ######################################################
15
16 if (empty($_POST['do']))
17 {
18 // ### START HTML ####################################################
19 ?>
20
21 <h1>Welcome to WordRunner</h1>
22 <p>This script will count the number of times a word is used in a passage. Simply copy and paste your article into the text area below and press "Run Words" to start the process.</p>
23
24 <?php
25 // ### END HTML ######################################################
26 }
27 else
28 {
29
30 // ### START HTML ####################################################
31 ?>
32
33 <h1>Document Word Run Complete</h1>
34 <p>WordRunner has finished processing your document: the results are listed below.</p>
35
36 <table cellpadding="4" cellspacing="2" border="1">
37 <tr style="background-color:#696969">
38 <td><strong>Word</strong></td>
39 <td><strong>Usage Index</strong></td>
40 </tr>
41
42 <?php
43 // ### END HTML ######################################################
44 $wordrunner_text = htmlspecialchars($_POST['wordtext']);
45
46 $punctstrip = str_replace(array('&quot;', '"', '\'', '&', '/', '.', ',', '!', '@', ';', ':', '[', ']', '(', ')'), '', $wordrunner_text);
47 $wordarray = preg_split('#[\s]+#', $punctstrip);
48
49 foreach ($wordarray as $word)
50 {
51 if (!is_int($word) && trim($word))
52 {
53 $outputlist[ ucwords(strtolower($word)) ]++;
54 }
55 }
56
57 arsort($outputlist);
58
59 foreach ($outputlist as $word => $count)
60 {
61 if (($_POST['ignoresmalls'] && $count > 3) || !$_POST['ignoresmalls'])
62 {
63 echo "<tr>\r\t<td>$word</td>\r\t<td>$count</td>\r</tr>\r";
64 }
65 }
66
67 echo "</table>\r<br />";
68 }
69
70 // ### START HTML ####################################################
71 ?>
72
73 <form action="wordrunner.php" method="post" name="wordrunner">
74 <input type="hidden" name="do" value="init">
75 <textarea name="wordtext" rows="60" cols="20" style="width:75%; height:50%"><?= $wordrunner_text ?></textarea>
76 <div><input type="submit" name="submit" value=" Run Words " /> <input type="checkbox" name="ignoresmalls" value="1" checked="checked" />Ignore Words With Small Counts</div>
77 </form>
78
79 <div align="center">WordRunner &copy;2004 Robert Sesek</div>
80
81 </body>
82 </html>