Re: [PHP] Trying to build intelligent query from question

2002-07-14 Thread Peter J. Schoenster

> > foreach($words as $Key=>$Value) {
> > if($ignoreWords[strtolower($Value)]) {
> > continue;
> > }
> 
> You would be better off using array_diff().

Jason,

Thanks, that works except that it doesn't account for case. I want to ignore case as 
it doesn't apply here. But I was able to get rid of the 
associative array. So I reckoned it best to LC the question and copy it because I want 
to return the original question as is back to the browser.

$_string = strtolower ($Config['input']['question']);

$words = explode(" ",$_string);
$ignoreWords = 
array('brazil','like','the','this','that','why','are','there','where','find',);

$FindTheseWords = array_diff($words, $ignoreWords);

Peter

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




Re: [PHP] Trying to build intelligent query from question

2002-07-14 Thread Jason Wong

On Monday 15 July 2002 01:00, Peter J. Schoenster wrote:

> I may be doing this all the wrong way :) so feel free to let me know,
> thanks.

I'm not going to comment on your overall concept.

> I've been developing a q/a database. I don' want to search on "what I
> consider" common words. Certainly there must be a list of these. Anyhow, I
> explode the question string into words and then iterate as such:
>
>
> foreach($words as $Key=>$Value) {
>   if($ignoreWords[strtolower($Value)]) {
>   continue;
>   }

You would be better off using array_diff().

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Conquering Russia should be done steppe by steppe.
*/


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




[PHP] Trying to build intelligent query from question

2002-07-14 Thread Peter J. Schoenster

Hi,

I may be doing this all the wrong way :) so feel free to let me know, thanks.

I've been developing a q/a database. I don' want to search on "what I consider" 
common words. Certainly there must be a list of these. Anyhow, I explode the 
question string into words and then iterate as such:


foreach($words as $Key=>$Value) {
if($ignoreWords[strtolower($Value)]) {
continue;
}

Here is my $ignoreWords array:

$ignoreWords = 
array('brazil'=>1,'like'=>1,'the'=>1,'this'=>1,'that'=>1,'why'=>1,'are'=>1,'there'=>
1,'where'=>1,'find'=>1,);

What do you think? Do I just build up $ignoreWords like I'm doing or this there 
another way I've missed? Also, does someone have a list of "common words 
to ignore"?

Thanks,

Peter



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