<HTML><HEAD><TITLE><?php echo "Word Frequency List Generator";?></TITLE></HEAD> 
<BODY> 
	<H1 ALIGN=center>Word Frequency List Generator</H1> 
	<FORM ACTION=wordFrequency.php3 METHOD=get> 
		<P>Filename: <INPUT NAME=filename TYPE=text></P> 
		<P><INPUT TYPE=submit></P> 
	</FORM> 

<? 
class PHP3 
{ 
var $str = $filename; 
function init($str) 
   { 
     $this->str = $str; 
   } 
} 

$form = $filename; //new PHP3; 

# Get the URL name 
$url = $filename; 
echo "<Word Frequency List for $url>";  
     

#Add http:// to the url 
$url = "http://$url"; //|| "~ /^http:\/\///"); 

#Get the HTML code from the URL:
$urlhtml = $filename; 

if ($urlhtml == undef) 
{ 
print "<H1>$url is not found.</H1>";
  print "<H2>Please verify your entry.</H2>";
  //  die "Narf!";
} 
   print "<H1>Word Frequency List for <A HREF=$url>$url</A></H1>\n"; 

#Removing HTML Tags here:
// $urlhtml =~ s/<[^>]+>/ /g; 

// Splitting Words 
// @word($word); // = split /[^A-Za-z']+/, "\L$urlhtml\E"; 

//clears null values
if ($word[0] == "")
{
  // Don't do anything shift @words;
} 

#store words in list
//my ($count, %frequency, $word);

 parse_url($filename); //string $filename) 
//parse_url($word); 
//ksort($word); 
$count = 0;

for(each; $word; $count)
{ 
 
  $frequency = $word++;  
    $count++;
} 

print "<TABLE BORDER>\n";
print "<TR><TH>Word</TH><TH>Count</TH><TH>Percentage</TH>\n";

#sort and display words with the number of their occurance
#my ($key, $percent);
for(each; $key; $frequency) 
{ 
  print "<TR>\n<TD>$word\n<TD ALIGN=right>$frequency\n<TD ALIGN=right>";
  $percent = ($frequency * $key)/$count*100;
  $PERCENT;
  write;
  print "\n</TR>\n";
} 
print "</TABLE>"; 

//print $form->end_html;

# Format for percentage
  $PERCENT =
  @###.##%
  $percent; 
 
?> 
 <H1><A HREF="wordFrequency.php3">Process another URL</H1> 
</BODY> 
</HTML> 

