Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #1920 > unrolled thread

Removing prepositions

Started byjwcarlton <jwcarlton@gmail.com>
First post2011-05-29 18:32 -0700
Last post2011-05-30 20:18 -0400
Articles 14 — 4 participants

Back to article view | Back to comp.lang.php


Contents

  Removing prepositions jwcarlton <jwcarlton@gmail.com> - 2011-05-29 18:32 -0700
    Re: Removing prepositions Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-29 23:20 -0400
    Re: Removing prepositions richard <member@newsguy.com> - 2011-05-29 21:06 -0700
      Re: Removing prepositions jwcarlton <jwcarlton@gmail.com> - 2011-05-30 00:08 -0700
        Re: Removing prepositions Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-30 09:00 -0400
          Re: Removing prepositions jwcarlton <jwcarlton@gmail.com> - 2011-05-30 15:13 -0700
            Re: Removing prepositions Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-30 20:15 -0400
              Re: Removing prepositions jwcarlton <jwcarlton@gmail.com> - 2011-05-30 17:36 -0700
                Re: Removing prepositions Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-30 22:47 -0400
                  Re: Removing prepositions jwcarlton <jwcarlton@gmail.com> - 2011-05-30 20:35 -0700
                    Re: Removing prepositions Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-31 07:43 -0400
                      Re: Removing prepositions jwcarlton <jwcarlton@gmail.com> - 2011-05-31 09:28 -0700
          Re: Removing prepositions Michael Fesser <netizen@gmx.de> - 2011-05-31 01:10 +0200
            Re: Removing prepositions Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-30 20:18 -0400

#1920 — Removing prepositions

Fromjwcarlton <jwcarlton@gmail.com>
Date2011-05-29 18:32 -0700
SubjectRemoving prepositions
Message-ID<afc0d014-f32b-4dc9-9f55-4fd156f2779a@c26g2000vbq.googlegroups.com>
I'm pretty sure that the answer to this is "no", but I thought I'd
ask, anyway.

Is there a better way to remove prepositions from a string than
putting them all in an array manually, then using str_ireplace()?

Here's what I'm currently doing, but I'm looking for a way to speed it
up:

// roughly 200 words and phrases here
$prepositions = array("a", "an", "as", "at", ...);

// remove non alphanumeric
$string = preg_replace("/[^a-zA-Z0-9\s]/", "", $string);

// convert \s to -
$string = preg_replace("/ /", "-", $string);

// remove prepositions
$string = str_ireplace($prepositions, "", $string);

// shorten $string
if (strlen($string) > 50)
  $string = substr($string, 0, 50);

If it matters, I'm using this in a message board, and I'm plugging the
subject into the link to the thread (for search engines). Since I'm
limiting the length to 50 characters, I want to make sure that as many
keywords as possible are in there.

TIA,

Jason

[toc] | [next] | [standalone]


#1922

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-05-29 23:20 -0400
Message-ID<irv2dr$jf7$1@dont-email.me>
In reply to#1920
On 5/29/2011 9:32 PM, jwcarlton wrote:
> I'm pretty sure that the answer to this is "no", but I thought I'd
> ask, anyway.
>
> Is there a better way to remove prepositions from a string than
> putting them all in an array manually, then using str_ireplace()?
>
> Here's what I'm currently doing, but I'm looking for a way to speed it
> up:
>
> // roughly 200 words and phrases here
> $prepositions = array("a", "an", "as", "at", ...);
>
> // remove non alphanumeric
> $string = preg_replace("/[^a-zA-Z0-9\s]/", "", $string);
>
> // convert \s to -
> $string = preg_replace("/ /", "-", $string);
>
> // remove prepositions
> $string = str_ireplace($prepositions, "", $string);
>
> // shorten $string
> if (strlen($string)>  50)
>    $string = substr($string, 0, 50);
>
> If it matters, I'm using this in a message board, and I'm plugging the
> subject into the link to the thread (for search engines). Since I'm
> limiting the length to 50 characters, I want to make sure that as many
> keywords as possible are in there.
>
> TIA,
>
> Jason

Don't even try.  Users will get very upset when you change that they 
type in.  It's their text, and their responsibility to determine what 
they want in there - not yours.

Of course, if you want to look for more ways to drive people away from 
your site, this is a good start.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#1923

Fromrichard <member@newsguy.com>
Date2011-05-29 21:06 -0700
Message-ID<dhvm1y4hsyvo$.dlg@evanplatt.sux>
In reply to#1920
On Sun, 29 May 2011 18:32:30 -0700 (PDT), jwcarlton wrote:

> I'm pretty sure that the answer to this is "no", but I thought I'd
> ask, anyway.
> 
> Is there a better way to remove prepositions from a string than
> putting them all in an array manually, then using str_ireplace()?
> 
> Here's what I'm currently doing, but I'm looking for a way to speed it
> up:
> 
> // roughly 200 words and phrases here
> $prepositions = array("a", "an", "as", "at", ...);
> 
> // remove non alphanumeric
> $string = preg_replace("/[^a-zA-Z0-9\s]/", "", $string);
> 
> // convert \s to -
> $string = preg_replace("/ /", "-", $string);
> 
> // remove prepositions
> $string = str_ireplace($prepositions, "", $string);
> 
> // shorten $string
> if (strlen($string) > 50)
>   $string = substr($string, 0, 50);
> 
> If it matters, I'm using this in a message board, and I'm plugging the
> subject into the link to the thread (for search engines). Since I'm
> limiting the length to 50 characters, I want to make sure that as many
> keywords as possible are in there.
> 
> TIA,
> 
> Jason

Problem is, many common words use those prepositions even though they are
not.

In your example, eliminating "a" would change "about" to "bout".
"reply" becomes "ply".
So why bother?

[toc] | [prev] | [next] | [standalone]


#1925

Fromjwcarlton <jwcarlton@gmail.com>
Date2011-05-30 00:08 -0700
Message-ID<c30d9a56-c590-41e7-a56b-b3b2e095d94e@w36g2000vbi.googlegroups.com>
In reply to#1923
> Problem is, many common words use those prepositions even though they are
> not.
>
> In your example, eliminating "a" would change "about" to "bout".
> "reply" becomes "ply".
> So why bother?

Well, that was just a quick bit of sample code. Since I'm converting
whitespaces to hyphens, it's a simple matter of removing "-a-" instead
of "a".

Jerry, I'm not entirely sure that you understand my point. Currently,
they would go to www.example.com/forum/, and if they wanted to go
directly to a thread, it would be something like:

www.example.com/forum/view/?msg=12345

I doubt that anyone is typing this in directly, but the link would
still work, so bookmarks would be fine. They would still go to
www.example.com/forum/; I'm just changing the link to the thread to:

www.example.com/forum/this-is-the-subject/12345/

[toc] | [prev] | [next] | [standalone]


#1933

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-05-30 09:00 -0400
Message-ID<is04db$3mi$1@dont-email.me>
In reply to#1925
On 5/30/2011 3:08 AM, jwcarlton wrote:
>> Problem is, many common words use those prepositions even though they are
>> not.
>>
>> In your example, eliminating "a" would change "about" to "bout".
>> "reply" becomes "ply".
>> So why bother?
>
> Well, that was just a quick bit of sample code. Since I'm converting
> whitespaces to hyphens, it's a simple matter of removing "-a-" instead
> of "a".
>
> Jerry, I'm not entirely sure that you understand my point. Currently,
> they would go to www.example.com/forum/, and if they wanted to go
> directly to a thread, it would be something like:
>
> www.example.com/forum/view/?msg=12345
>
> I doubt that anyone is typing this in directly, but the link would
> still work, so bookmarks would be fine. They would still go to
> www.example.com/forum/; I'm just changing the link to the thread to:
>
> www.example.com/forum/this-is-the-subject/12345/
>

Sure I understand your point, and my statement stands.

Additionally, why do you think this will do you any good?  Search 
engines are very good at finding sites who try to scam them for better 
ratings.

Build a good site and it will get ranked high.  Build a crappy site and 
it will be ranked low.  Try to scam the search engines and it won't be 
ranked at all.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#1942

Fromjwcarlton <jwcarlton@gmail.com>
Date2011-05-30 15:13 -0700
Message-ID<6d56979c-5038-4d7b-9220-767a53ab19e9@hd10g2000vbb.googlegroups.com>
In reply to#1933
> Additionally, why do you think this will do you any good?  Search
> engines are very good at finding sites who try to scam them for better
> ratings.


We were just discussing it on alt.www.webmaster, and all of the
replies seemed to think that it was a good idea.

http://groups.google.com/group/alt.www.webmaster/browse_frm/thread/ccd2acf826660517/c18d430d6a2451bf?lnk=raot#c18d430d6a2451bf

[toc] | [prev] | [next] | [standalone]


#1944

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-05-30 20:15 -0400
Message-ID<is1bui$c4p$1@dont-email.me>
In reply to#1942
On 5/30/2011 6:13 PM, jwcarlton wrote:
>> Additionally, why do you think this will do you any good?  Search
>> engines are very good at finding sites who try to scam them for better
>> ratings.
>
>
> We were just discussing it on alt.www.webmaster, and all of the
> replies seemed to think that it was a good idea.
>
> http://groups.google.com/group/alt.www.webmaster/browse_frm/thread/ccd2acf826660517/c18d430d6a2451bf?lnk=raot#c18d430d6a2451bf

Interesting, because I'm on there also, and that's not at all what 
people were saying.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#1946

Fromjwcarlton <jwcarlton@gmail.com>
Date2011-05-30 17:36 -0700
Message-ID<b3cadeaa-6d72-44f0-9aa1-df6001a666d6@f11g2000vbx.googlegroups.com>
In reply to#1944
> Interesting, because I'm on there also, and that's not at all what
> people were saying.

Is Google Groups not showing me everything? I know that some people's
readers are set to ignore posts from Google Groups, but I don't know
if there's an issue the other way around. But I don't use NGs enough
to justify a separate program.

What I'm seeing is:

1. Me asking whether I should change the link (per above)

2. John Bokma giving advice on how to do it

3 & 4. Me replying

5. John Bokma saying that I should use a - instead of a _

6. You saying that I need to set Multiviews option in Apache.

7. Steve Sobol saying that query strings aren't SEO friendly, so I
should definitely make this change.

[toc] | [prev] | [next] | [standalone]


#1947

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-05-30 22:47 -0400
Message-ID<is1ks5$n7k$1@dont-email.me>
In reply to#1946
On 5/30/2011 8:36 PM, jwcarlton wrote:
>> Interesting, because I'm on there also, and that's not at all what
>> people were saying.
>
> Is Google Groups not showing me everything? I know that some people's
> readers are set to ignore posts from Google Groups, but I don't know
> if there's an issue the other way around. But I don't use NGs enough
> to justify a separate program.
>

No, GG doesn't show everything, but it also shows a lot of spam.

> What I'm seeing is:
>
> 1. Me asking whether I should change the link (per above)
>
> 2. John Bokma giving advice on how to do it
>
> 3&  4. Me replying
>
> 5. John Bokma saying that I should use a - instead of a _
>
> 6. You saying that I need to set Multiviews option in Apache.
>
> 7. Steve Sobol saying that query strings aren't SEO friendly, so I
> should definitely make this change.

Which is NOT what they were talking about.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#1948

Fromjwcarlton <jwcarlton@gmail.com>
Date2011-05-30 20:35 -0700
Message-ID<191d2a9a-4100-433a-b5f0-bcb8b7bf761b@bl1g2000vbb.googlegroups.com>
In reply to#1947
> Which is NOT what they were talking about.

I hate to be obtuse, man, but no one in the thread (including you)
said that I should NOT do it. The purpose of the thread was to ask
whether I should bother, and the answers seemed to be affirmative.

I don't think that plugging the subject in to the link would be
considered spamming by search engines, though. So can you be more
specific on why you're now thinking it's a bad idea?

[toc] | [prev] | [next] | [standalone]


#1949

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-05-31 07:43 -0400
Message-ID<is2k8a$k7s$1@dont-email.me>
In reply to#1948
On 5/30/2011 11:35 PM, jwcarlton wrote:
>> Which is NOT what they were talking about.
>
> I hate to be obtuse, man, but no one in the thread (including you)
> said that I should NOT do it. The purpose of the thread was to ask
> whether I should bother, and the answers seemed to be affirmative.
>
> I don't think that plugging the subject in to the link would be
> considered spamming by search engines, though. So can you be more
> specific on why you're now thinking it's a bad idea?

This has gone way off topic in this newsgroup.  But you're talking 
apples and oranges.  What people told you there was something completely 
different.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#1957

Fromjwcarlton <jwcarlton@gmail.com>
Date2011-05-31 09:28 -0700
Message-ID<1c11f839-4e2c-40d9-b990-ff8b564897ae@e26g2000vbz.googlegroups.com>
In reply to#1949
> This has gone way off topic in this newsgroup.  But you're talking
> apples and oranges.  What people told you there was something completely
> different.

I wasn't sure if we were going off topic or not. If you were trying to
say that removing prepositions from the subject string was a bad idea,
then it was an appropriate response to the thread.

Please feel free to offer any insight to the thread on
alt.www.webmaster. The subject is "Any value to changing variables to
a directory link?", and the last post is May 25 @ 12:34pm (I'm
assuming EST).

[toc] | [prev] | [next] | [standalone]


#1943

FromMichael Fesser <netizen@gmx.de>
Date2011-05-31 01:10 +0200
Message-ID<b888u614r1ed0038h0s1lhakqbgeh6mtih@mfesser.de>
In reply to#1933
.oO(Jerry Stuckle)

>On 5/30/2011 3:08 AM, jwcarlton wrote:
>>
>> Jerry, I'm not entirely sure that you understand my point. Currently,
>> they would go to www.example.com/forum/, and if they wanted to go
>> directly to a thread, it would be something like:
>>
>> www.example.com/forum/view/?msg=12345
>>
>> I doubt that anyone is typing this in directly, but the link would
>> still work, so bookmarks would be fine. They would still go to
>> www.example.com/forum/; I'm just changing the link to the thread to:
>>
>> www.example.com/forum/this-is-the-subject/12345/
>>
>
>Sure I understand your point

Obviously not.

>and my statement stands.

No. Neither does he change what users type in, nor does he touch their
texts, nor does he drive users away. He just generates URLs from the
submitted content like almost every blog software on this planet. He
just asked about how to optimize it.

If you upload a picture to an image hoster, would you get upset and be
driven away by the fact that a script on that site will automatically
generate a thumbnail from what you've uploaded?

>Additionally, why do you think this will do you any good?

User-friendly and readable/speaking URLs.

Compare these:

www.example.com/forum/?msg=12345
www.example.com/forum/this-here-is-the-text-about-that-something
www.example.com/forum/text-about-something

Obviously the last one would be preferred.

>Search 
>engines are very good at finding sites who try to scam them for better 
>ratings.

Who's trying to scam here?

>Build a good site and it will get ranked high.  Build a crappy site and 
>it will be ranked low.  Try to scam the search engines and it won't be 
>ranked at all.

A good site will be even better with good URLs. And all the OP wants is
to automatically create them - short and precise.

Micha

[toc] | [prev] | [next] | [standalone]


#1945

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-05-30 20:18 -0400
Message-ID<is1c44$c4p$2@dont-email.me>
In reply to#1943
On 5/30/2011 7:10 PM, Michael Fesser wrote:
> .oO(Jerry Stuckle)
>
>> On 5/30/2011 3:08 AM, jwcarlton wrote:
>>>
>>> Jerry, I'm not entirely sure that you understand my point. Currently,
>>> they would go to www.example.com/forum/, and if they wanted to go
>>> directly to a thread, it would be something like:
>>>
>>> www.example.com/forum/view/?msg=12345
>>>
>>> I doubt that anyone is typing this in directly, but the link would
>>> still work, so bookmarks would be fine. They would still go to
>>> www.example.com/forum/; I'm just changing the link to the thread to:
>>>
>>> www.example.com/forum/this-is-the-subject/12345/
>>>
>>
>> Sure I understand your point
>
> Obviously not.
>

I understand EXACTLY what he's talking about.

>> and my statement stands.
>
> No. Neither does he change what users type in, nor does he touch their
> texts, nor does he drive users away. He just generates URLs from the
> submitted content like almost every blog software on this planet. He
> just asked about how to optimize it.
>
> If you upload a picture to an image hoster, would you get upset and be
> driven away by the fact that a script on that site will automatically
> generate a thumbnail from what you've uploaded?
>

He is changing what the user types in - and plugging it into urls.  Not 
at all like "almost every blog software on this planet".

>> Additionally, why do you think this will do you any good?
>
> User-friendly and readable/speaking URLs.
>
> Compare these:
>
> www.example.com/forum/?msg=12345
> www.example.com/forum/this-here-is-the-text-about-that-something
> www.example.com/forum/text-about-something
>
> Obviously the last one would be preferred.
>

But then that's not what he's trying to do, is he?

>> Search
>> engines are very good at finding sites who try to scam them for better
>> ratings.
>
> Who's trying to scam here?
>

He is - and obviously, you are if you support it.

>> Build a good site and it will get ranked high.  Build a crappy site and
>> it will be ranked low.  Try to scam the search engines and it won't be
>> ranked at all.
>
> A good site will be even better with good URLs. And all the OP wants is
> to automatically create them - short and precise.
>
> Micha

You really should learn something about SEO.  In the meantime, I suggest 
you stick to PHP coding.


-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web