SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post HOW TO CLASSIFY THE WEB PAGE?

    Here i attached my codings i going to classify the web page like sports,education,etc i used explode function for split abbreviation in url and used switch case for string comparison but i ll expect category value like 0,1,2,etc.. which it belogs to?At the same time i ll expect the category value in notepad also but the solution is didnt work,help me sir.

    <?php

    ....
    string y[6]={'arts','sports','finance'....}
    for(i=0;i<=6;i++)
    {
    b=strcmp($x,$y[i])
    if(b==0)
    {
    c=y[i];
    }
    }

    switch ($c)
    {
    case "arts":
    return att1=1;
    break;
    case "sports":
    return att1=2;
    break;
    case "finance":
    return att1=3;
    break;
    .
    .
    .
    }

    $myFile = "dataset_doc.txt";
    $fh = fopen($myFile, 'a');
    $format="1:";
    fwrite($fh,$format);
    fwrite($fh, $att0);

    ?>

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,400
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    Welcome to the SP forums.

    I'm sorry, but I don't understand what you're asking, and I also don't understand what that code is supposed to do?

  3. #3
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Woah.

    That's a mix of PHP and something else C-based right there. I'd suggest sticking to learning one programming language at a time.

    First of all, name your variables well! Things get very complicated if you don't, and longer naming isn't taxing on the compiler.

    Secondly, to learn PHP isn't just learning the syntax and applying C-logic. There is a whole library of functions and structures you can use in PHP which aren't available in C (and the reverse is also true).
    PHP Code:
    $Categories = array('Arts''Sports''Finance''etc');
    $Search 'Sports';

    $CategoryKey array_search($Search$Categories);

    if(
    $CategoryKey === false){
        
    $CategoryKey "Not Found";
    }else{
        
    $CategoryKey++;
    }

    file_put_contents('dataset_doc.txt''1:' $CategoryKey); 
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •