Page 1 of 1

keyword generator

Posted: Sun Apr 20, 2008 2:41 am
by syed
Hi every one
can anyone help me to generate keyword from the text
but i have a condition that is we be submitting
title
subtitle
body
for title cost is 5, subtitlecost is 3 and body cost is 2
and then sort the keywords on ascending order and get 10 best keywords
My problem is i cannot get the value for keytitle
here is my code

Code: Select all

 
 <?php>
   function keywords()
   {
      $filterarray =array("a","is","the","what","why","how","and","because","much","or","yes","no","will","be","I");
      $title = " starbucks coffee shop shop  shop stis better than other coffee shop  ";
      $subtitle = " the publication the company";
      $body = "hi every one how  how is going" ;
      $a_title = explode(" ", $title );
      $a_subtitle = explode(" ", $subtitle );
      $a_body = explode(" ", $body ); 
      $counttitle = array(sizeof($title));
      $countsubtitle = array(sizeof($subtitle));
      $countbody = array(sizeof($body));
      $costttitle = array(sizeof($title));
      $costsubtitle = array(sizeof($subtitle));
      $costbody = array(sizeof($body));
      $keytitle = array(sizeof($title));
      $keysubtitle = array(sizeof($subtitle));
      $keybody = array(sizeof($body));
      $wsordcount= 0;
 
         //for generating count for title
 
         for($i=0;$i<sizeof($a_title);$i++)
         {
            if($a_title[$i]!="")
            {
            $wsordcount = substr_count($title,$a_title[$i]);    
            $counttitle[$i] = $wsordcount;
            echo "tile $a_title[$i] count $wsordcount <br>";
            }
            //echo "tile $a_title[$i] count $wsordcount <br>";
         }
        
        //for generating count for sub title
 
         for($i=0;$i<sizeof($a_subtitle);$i++)
         {  
            if($a_subtitle[$i]!="")
            {
            $wsordcount = substr_count( $subtitle, $a_subtitle[$i]);    
            $countsubtitle[$i] = $wsordcount;
            echo "tile $a_subtitle[$i] count $wsordcount <br>";
            }
            //echo "tile $a_title[$i] count $wsordcount <br>";
         }
         
           //for generating count for body
 
          for($i=0;$i<sizeof($a_body);$i++)
         {
            if($a_body[$i]!="")
            {
            $wsordcount = substr_count($body,$a_body[$i]);  
            $countbody[$i] = $wsordcount;
            echo "tile $a_body[$i] count $countbody[$i] <br>";
            }
            //echo "tile $a_title[$i] count $wsordcount <br>";
         }
        
 
           //  for generating Cost
 
           for($i=0;$i<sizeof($a_title);$i++)
          {
            $costttitle[$i]= $counttitle[$i] * 5;
            echo "tile $a_title[$i] count $counttitle[$i] cos = $costttitle[$i]<br>";
          }
         
          for($i=0;$i<sizeof($a_subtitle);$i++)
          {
            $countsubtitle[$i]= $countsubtitle[$i] * 3;
            echo "tile $a_title[$i] count $countsubtitle[$i] cos = $countsubtitle[$i]<br>";
          }
         
         for($i=0;$i<sizeof( $a_body);$i++)
          {
            $costbody[$i]= $countbody[$i] * 2;
            echo " $costbody[$i] cos = $countbody[$i]<br>";
          }
           
            $mymax=sizeof($a_title); 
 
         // Gerating Key
          $stw= "XX";
               for ($j=0; $j <= $mymax ; $j++)
               {
                   $k= $j;
                   $str1 = $a_title[$j];
                  for($i=$j+1; $i<=$mymax; $i++)
                  {
                     if ((strcmp( $str1, $a_title[$i])) ==  0)
                     {
                           echo " hello";
                          $a_title[$i] = $stw;
                        //$a_title[$i] ="XX";
                     }
                  }
               echo "$a_title[$j] <BR>";
            }
            
          
             $mymaxsubtitle = sizeof($a_subtitle);  
           for ($j=0; $j <= $mymaxsubtitle ; $j++)
               {
                   $k= $j;
                   $str1 = $a_subtitle[$j];
                  for($i=$j+1; $i<=$mymaxsubtitle; $i++)
                  {
                     if ((strcmp( $str1,$a_subtitle[$i])) ==  0)
                     {
                           echo " hello two ";
                          $a_subtitle[$i] = $stw;
                        //$a_title[$i] ="XX";
                     }
                  }
               echo "$a_subtitle[$j] <BR>";
            }
            
 
                 $mymaxbody = sizeof($a_body);  
                for ($j=0; $j <= $mymaxsubtitle ; $j++)
                {
                  $k= $j;
                  $str1 = $a_body[$j];
                 for($i=$j+1; $i<=$mymaxsubtitle; $i++)
                {
                if ((strcmp( $str1, $a_body[$i])) ==  0)
                 {
                  echo " hello two ";
                  $a_body[$i] = $stw;
                   //$a_title[$i] ="XX";
                     }
                  }
               echo " $a_body[$j] <BR>";
            }
 
 //---------------------
            $stw= "XX";
             for($i=0; $i<10; $i++)
             {
                $cost = $costtiltle[$i];
                $temp = $a_title[$i];
                $k=$k+1;
                if ((strcmp( $stw , $a_title[$i])) !=  0)
                 {
                  $keytitle[$k] = $a_title[$i];
                  $costsubtitle[$k] =  $cost;
                  $k=$k+1;
                   echo "$costsubtitle[$k] wer $keytitle[$k]";
                  }
                echo " onetwo $keytitle[$k] <BR>";
               }
   
  }
 
keywords();
 
 
 
 
 </php>
 
 
 
 
 
 

Thanks for your help
Syed