Jump to content

underwinefx

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

underwinefx's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I need a stopword removal implementation. I am flabbergasted with few issues. For eg: [quote] stopword.txt is the that this [/quote] [code] <? //loading the stopword from a text file 'stopword.txt' which contains a list of words containing one word per line and entered by pressing the ENTER key after every word $stopword=array('is', 'the', 'that', 'this',);//I assume that the previous line gives the same effect as this line...am I wrong? and this LINE would NOT be in the code..since I will be using $text="this is a quote to say that anything is possible";//contains stopwords that need to be removed. //using explode to make the text string into separate array elements using <space> as the delimiter. $keyword=explode(" ",$text); $keyword=array_diff($keyword,$stopword); ?> [/code] The above code works... [code] <? $myFile = "stopword.txt";//the file containing the stopwords //opening the stopword.txt file $fh = fopen($myFile, 'r'); //reading the stopword.txt file $theData = fread($fh, filesize($myFile)); //to get the data from the text file as separate array elements using explode //$stopword=explode("\n",$theData); $keyword=explode(" ",$text); $keyword=array_diff($keyword,$stopword); [/code] The above code does NOT work..why? And I would Like to know what else can be done? To compare each element from one array to the other element and unset/remove it? Should I use looping? I am a starter and I am at loss how to implement this .. [quote][b]In brief:[/b] 1. load the stopword list from stopword.txt into stopword array 2. separate the string into keywords by using space as delimiter. 3. compare each word of stopword array with each element in the keyword array 4. remove the elements from keyword array which are present in stopword array 5. return results of new keyword array without the stopwords for further coding [/quote] How to implement this? Regards, Underwinefx
  2. I tried to implement the "similar article" tutorials available in internet using "FULLTEXT" search index. The database -"quotation" contains a table "quotation_list" with two fields -> "quotation_id" and another text field "quote" with quotations (or any text data). The precise method said in the tutorial is as follows; 1. use some method to separate the data stored in text field using <space> as separator to get each word of the quotation separately. 2. Now, each 'data'(word) retrieved by the explode function is compared using "MATCH" function with the text data field "QUOTE" 3. Now, the matching "quotation_id" (numeric PRIMARY KEY field of the table) are listed as a list side by side for eg; as follows: RELATED QUOTE NO: 1, 4, 5, 6, 7 I am able to display the entire list of data in a single page: [code] <?php Code begins //Database details to connect to mysql server $username="username"; $password="password"; $database="quotation"; //Mysql Database Connection mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); //Mysql Query to retrieve quotation id and the quotation from quotation table $result=mysql_query("SELECT * FROM quotation"); //Getting the number of rows of result from the query to be used in the loop to display results... $num=mysql_num_rows($result); //Title of the page echo "<b><center>List Of Quotation</center></b><br><br>"; //Loop to get the data $i=0; while ($i < $num) { $quotation_id=mysql_result($result,$i,"quotation_id"); $quotation_text=mysql_result($result,$i,"quotation_text"); //Data output on page one below the other echo "Quote No:<b>$quotation_id</b><br>Quote: $quotation_text<br><hr><br>"; $i++; } //end of code ?> [/code] But I have difficulty in using the php mysql coding to retrieve the related data and displaying it. I want the related quotation numbers displayed below every quote automatically. Since I am new to the forum and do NOT know if displaying the external link of the tutorial that I read to try to add the related quote function to this code, I am NOT adding the link here. Now, actually I would be happy to have a single quote output per page with a list of all related text data...I mean, the quotation id and quotation in a single page instead of having the entire quotation list in the same page. The rough idea is as follows: [quote] Page 1: <previous page link><next page link> [hr] Quote No: <quotation_id> Quote 1: <quote text> [hr] Related Quotes: related quote id 1 related quote 1 related quote id 2 related quote 2 ........ ...... ..... .. [hr] <previous page> <next page> [/quote] Can someone help me with this? Pagination is NOT a necessity and I would be perfectly content with even a simple script since I am going to use it only locally on my system for my personal use. Regards, underwinefx
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.