Re: Google Style Search Results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yay, Questionnaire time

I love this part of the game



a) I'm not very familiar with regex at all and was wondering if you could
tell me how your regex would handle two matched search strings that
exist within a few words of each other in the text. For example "A
larger server would be sufficient I think".

Answer: As I think I may have mentioned "All I did was conjure up a regular expression "

True, I didn't imply I wrote that regex in under 32 seconds...But I'm sure I was trying to come across with the fact that with improvement it could be much more powerful.

Like this example:

http://aries.the-spectrum.org/webdev/wawd/forums/search.php?q=were%2Badd&st=post&sb%5B%5D=*&maxres=25&ob=datetime&ot=DESC


Is that better??

multiple words within the same piece of string..

Again, much much much more work can be done, this was a very quick "stub" example to show the flexibility of regex..

Now a new issue that has been presented is if you DO have multiple words close together it will only grab x amount of words to the before and after that central word, including perhaps another keyword.. as you can see on above link..


Again, give me another 3 minutes in the code and I'm sure I'll work that one too..

b)Also in the link you provided (reproduced below) the first matched
word is surrounded by 4 words and the second by 5 words, is there a
reason for this?

Answer: Ooh this is my favourite :-) Yes, great reason why when you conduct a search such as this:
http://aries.the-spectrum.org/webdev/wawd/forums/search.php?q=sufficient%2Blarge&st=post&sb%5B%5D=*&maxres=25&ob=datetime&ot=DESC

You received the 4 word and 5 word output.. Why don't you head over to the link that is generated on that search result entry??

Look around at the actual content of that forum entry and you will soon see that the first match occurs on a line that physically only has 9 words, therefore it can only really match what exists.

Good point though, for a split second I actually thought to myself there might be something wrong, but as usual and until I'm proved wrong; I'm right again. PHP and REGEX have never failed me.

I'm sure you all are well aware already of the saying that describes how there is no such thing as computer errors, only stupid humans.

And that is precisely it, I have been and still am a stupid human, and I will usually sit there for quite a while reloading and running a regex in my head to ensure it runs and parses as it should.

Simple ones like this don't take too much planning, but they can get hairy :-)




Hopefully that answers your queries Graham..



Kindest Regards to everybody!

Julien Bonastre


---oOo--- Allowing users to execute CGI scripts in any directory should only be considered if: ... a.. You have no users, and nobody ever visits your server. ... Extracted Quote: Security Tips - Apache HTTP Server ---oOo--- ------oOo---------------oOo------ Julien Bonastre [The_RadiX] The-Spectrum Network CEO ABN: 64 235 749 494 julien@xxxxxxxxxxxxxxxx www.the-spectrum.org ------oOo---------------oOo------ ----- Original Message ----- From: "Graham Cossey" <graham.cossey@xxxxxxxxx>
To: "Julien Bonastre" <julien@xxxxxxxxxxxxxxxx>; <php-db@xxxxxxxxxxxxx>
Sent: Friday, December 09, 2005 7:10 PM
Subject: Re:  Google Style Search Results


On 12/9/05, Julien Bonastre <julien@xxxxxxxxxxxxxxxx> wrote:
<snip>
http://aries.the-spectrum.org/webdev/wawd/forums/search.php?q=sufficient%2Blarge&st=post&sb%5B%5D=*&maxres=25&ob=datetime&ot=DESC

<snip>

All I did was conjure up a regular expression that basically just matches words :-) haha ironically..


Here it is:

  $extract_result="";
preg_match_all("/((?:[\w]+ ?){0,5})[\w \.\,\-\;]((?:".join("|",$q_arr)."))([\w]*)[\w \.\,\-\;]((?:[\w]+ ?){0,5})/i",$row["content"],$ext_matches,PREG_SET_ORDER);
  foreach($ext_matches as $ext_arr) {
$extract_result .= $ext_arr[1]." <B>".$ext_arr[2]."</B>".$ext_arr[3]." ".$ext_arr[4]." ... ";
  }


Are you familiar with regex?

<snip>

I'm not very familiar with regex at all and was wondering if you could
tell me how your regex would handle two matched search strings that
exist within a few words of each other in the text. For example "A
larger server would be sufficient I think".

Also in the link you provided (reproduced below) the first matched
word is surrounded by 4 words and the second by 5 words, is there a
reason for this?

"An example of a larger post can be found ... we were to add a
sufficient amount of text than we ..."

Thank you.

--
Graham

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux