Hey guys, i'm struggling to develop a form where the users submits text and it must then be displayed as a cloud .. It is based upon the premise that metadata, in the form of tags, is
displayed in various font sizes and weights based upon their importance. The more
important a tag, the bigger it is displayed.
How will it work?
Your user must be presented with a form containing a single text area where he/she can
enter as much text as they like. They do, however, have to enter a minimum of 100 words. If
they fail to do so they should be advised and enabled to correct it.
To construct the tag cloud you will have to follow through a series of steps:
1. The first is to clean the text. Remove all punctuation from it and convert everything
to lower case. Also remove all stop words. These are words like the, and, you etc.,
- Now you’ll have to count the number of occurrences of each word in the text.
- Once you know how many times the words appear in the text you can construct your
cloud.
How to construct the cloud
It is important that you use your own creativity and originality when constructing your tag
cloud. Nevertheless, there are certain guidelines which you should follow. Your tag cloud
will always consist of 20 tags which must be sorted alphabetically. If the user entered 150
words, you have to select the 20 words which occurred most and display these in your
cloud. You have complete freedom with regards to the style of your cloud (colours, font
types, font sizes) but you must implement a clearly visible visual hierarchy to distinguish
between more and less important terms.
User Options
When the tag cloud is displayed to the user, you should provide him with the option to
update the tag cloud by adding additional text to it. It is important, therefore, that you store
the original text entered by the user in a session variable and combine it with any new text
he enters. The new cloud should be constructed using both the original and the new text.
Alternatively the user should have the option to create a completely new tag cloud.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Tag Cloud Constructor</title>
</head>
<body bgcolor="black">
<center>
<br/><br/>
<table border="0">
<tr>
<td background='bike.jpg' width='710' height='490' valign='top' style="text-align:left;color:white;font-family:tahoma;font-size:12;border:1 solid white;padding:20px;">
<span style="font-size:35">Tag Cloud Constructor</span><br/><br/><br/>
<?php
if(isset($_POST['submitted']))
if(empty($_POST['text']))
{
print "<span style='color:red;font-weight:bold;'>Please enter some text!!</span><p/>";
include('form.php');
}
else
{
$cloud_one=$_POST['text'];
$cloud_one=strtolower(stripslashes($cloud_one));
$cloud_one=explode(' ',$cloud_one);
$cloud_one=str_replace(".","",$cloud_one);
$cloud_one=str_replace("'","",$cloud_one);
$cloud_one=str_replace(":","",$cloud_one);
$cloud_one=str_replace(";","",$cloud_one);
$cloud_one=str_replace(",","",$cloud_one);
$cloud_one=str_replace("!","",$cloud_one);
$cloud_one=str_replace("?","",$cloud_one);
$cloud_one=str_replace("_","",$cloud_one);
$cloud_two=array_unique($cloud_one);
sort($cloud_two);
$count_words = array();
foreach($cloud_one as $a){
if (array_key_exists($a, $count_words)){
$count_words[$a]++;
}else{
$count_words[$a]=1;
}
}
}
else
{
include('form.php');
}
?>
</body>
</html>
form.php code
<form name='cloud_constructor' method='post' action='index.php'>
<table cellspacing='10px'>
<tr><td style="vertical-align:top;color:white;font-family:tahoma;font-size:12;">Please enter some text and click submit to create a cloud: </td><td><textarea name='text' rows='10' cols='30'></textarea>
</table>
<input type="hidden" name="submitted" value="TRUE"/>
<input type='submit' value='Submit'/>
</form>
The thing is i do not know how to create the tags and how to use session variables..i would appreciate your help..