Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[CONTRIBUTION] Sloppy Words Cleaner


Top_Speed

Recommended Posts

Excellent contribution, i'ts working truly fine, thanks a lot ;-)

 

I have one more request, and I didn' find how to code it as I'm quite new with php …

 

I notice the sentence in the account_word_cleaner.php are splitted into single words by the presence of a space " "

$words = split(" ", $string);

 

Would it be possible to get also a split with the caracters "-" and with the " ' "

 

So that we can get as result for example Rolland-Garros instead of Rolland-garros

and L'Aigle instead of L'aigle

 

Thanks

Azur42

Link to comment
Share on other sites

Hi,

Thanks for the praise :)

 

I was going to include these so called "in line exceptions" in the next release. I'm short on time right now but you can try this replacement for the pre-mentioned line:

 $words = split(" ", $string);

 

Play around with this replacement

 $words = split(" ","'","-", $string);

 

Let me know if it works or what tweak made it work

Thanks! -KJ

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

Thanks for your prompt answer.

 

So, I've tried with

$words = split(" ","'","-", $string);

but it returns as error "Wrong parameter count for split()"

Also, I presume with this method of one split the function will not put back the " - " and the " ' " after, but only spaces ?

 

I also tried

$words = split("-", $string);

...

return join("-", $newwords);

but then it doesn't work anymore for the space…

 

Probably, would it be possible to do the process once for each : one time for the " ", once for the " - " and once for the " ' ".

Sorry for my dummy questions as I'm not confident with php…

 

Have a nice week-end

Azur42

Link to comment
Share on other sites

Thanks for your prompt answer.

 

So, I've tried with

$words = split(" ","'","-", $string);

but it returns as error "Wrong parameter count for split()"

Also, I presume with this method of one split the function will not put back the " - " and the " ' " after, but only spaces ?

 

I also tried

$words = split("-", $string);

...

return join("-", $newwords);

but then it doesn't work anymore for the space…

 

Probably, would it be possible to do the process once for each : one time for the " ", once for the " - " and once for the " ' ".

Sorry for my dummy questions as I'm not confident with php…

 

Have a nice week-end

Azur42

 

I'll see when I can sneak some Trial & Error into this... the ' will be useful to French (L'Esteral instead of L'esteral) and of course the hyphenated names using - (Smith-Barney instead of Smith-barney))

 

My problem is I only have 2 "live" shops and since moving them to dedicated servers I have no test shop anymore. So my trial & error (especially this time of the busy Xmas season) can lock up some customers account creations :(

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

Hi Azure42

I rewrote the function code for you so it will work with your inline words...

simply copy this over your existing account_word_cleaner.php file

 

This is the base for the new version I'm working on (ver1.3)

catalog/includes/functions/account_word_cleaner.php

<?php
/*
 $Id: account_word_cleaner.php,v 1.21 11/20/2007 09:55:01 Sloppy Words Cleaner Exp $
 http://www.gokartsrus.com

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/


function RemoveShouting($name) {
$name = strtolower($name);
$name = join("'", array_map('ucwords', explode("'", $name)));
$name = join("-", array_map('ucwords', explode("-", $name)));
$name = join("Mac", array_map('ucwords', explode("Mac", $name)));
$name = join("Mc", array_map('ucwords', explode("Mc", $name)));
$name = join("Dis", array_map('ucwords', explode("Dis", $name)));
return $name;
}

?>

 

Let me know if it does what you want! :)

KJ

Edited by Top_Speed

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

Sloppy Words Cleaner v1.3 Released and Tested :)

 

=== All new function file with these new features ===

1. Accounts for (-) in names (smith-barney = Smith-Barney)

2. Accounts for (') in names (l'esteral = L'Esteral) [see suffix* feature 4.]

3. Now accounts for multiple surnames as a prefix code like Mc, Mac, Dis, Da etc. (MCWILLIAMS = McWilliams, Disbennett = DisBennett, defelice = DeFelice, DASHAWN = DaShawn)

4. *New suffix coding allows for ('S) on the end of words (mcdonald's or MCDONALD'S = McDonald's)

...without this addition the above addition (feature 2.) would make (word's = Word'S) so this was much needed.

5. Acoounts for non-English names (De La = de la, De Las = de las, Der = der, Van De = van de, Van Der = vander, Von = von

 

 

 

-------------------------------------------------------------

Existing v1.2 Users? Simple Upgrade:

 

--> UPLOAD NEW catalog/includes/functions/account_word_cleaner.php

 

Done!!!

--------------------------------------------------------------

 

Any problems or comments please post them in this Support Thread!

 

 

-KJ Miller (top_speed)

www.gokartsRus.com

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

Nice feature update with the new version. However one of the previous "features" is now broken. If user puts in John Doe Iv.

Prior Version: John Doe IV

New version: John Doe Iv

 

Once again thanks for your efforts on this function build out!

Edited by bob61
Link to comment
Share on other sites

Nice feature update with the new version. However one of the previous "features" is now broken. If user puts in John Doe Iv.

Prior Version: John Doe IV

New version: John Doe Iv

 

Once again thanks for your efforts on this function build out!

 

Thanks Bob, I forgot about adding the roman numerals like "IV"

 

On the "De" there is no answer for those since the word goes both ways, I guess it's best to leave the "Da" and "De" out > I'll remove them from the function and add the roman numerals, the ver will still be 1.3, look for the latest upload avail.

 

Thanks for the troubleshooting!

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

Thanks Bob, I forgot about adding the roman numerals like "IV"

 

On the "De" there is no answer for those since the word goes both ways, I guess it's best to leave the "Da" and "De" out > I'll remove them from the function and add the roman numerals, the ver will still be 1.3, look for the latest upload avail.

 

Thanks for the troubleshooting!

Classic case of darned if you do and darned if you don't ;)

 

Agree that it's best to leave "DA" and "DE" out. Was thinking though, I actually know of a person who's last name is Ix - so the roman numeral change will now convert that. I'll probably edit my file to catch the common roman numerals used in a name (II, III and IV) and drop the others as I don't think I've seen any personal names using any of the other (might be some business names, but not that critical for my purpose).

 

You keep up the good work and I'll keep troubleshooting.....

Link to comment
Share on other sites

Yeah the extended roman numerals is probably a bit overboard.

 

Since this contrib is still in development (however it works well as is) but it needs a few more tweaks I'm thinking of making a dual function file (within the one account_word_cleaner.php). The one function will be used for last names only (and maybe the company input line as well depending on the users wants).

 

So I'll explain....

1 function (existing) "RemoveShouting()" will be for any line inputs that doesn't require a last name prefix like Mc or Mac (ie) McDonald

1 new function "LastName()" which will have the Mc and Mac prefix.

 

Why?

Split functions will allow just the last name (or company name if wanted) to inherit the prefix Mc, Mac

 

Example without split functions...

John MacDonald

16 MacAroni Drv

Nowhere, CA 12345

 

Example with split functions...

John MacDonald

16 Macaroni Drv

Nowhere, CA 12345

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

Sloppy Words Cleaner 1.4 tested and stable! :)

 

ahh... my ongoing quest.

I know it will not (and cannot ever, ever) be perfect (but neither is osCommerce;) nor the English language system for that matter... lmao.

 

So this brings me to my latest wacky brain storm... multiple-function file for multiple input fields. hmm, simple enough, not sure why I didn't think of it sooner ;( ...I blame it on my g/f walking around the house wearing just a thong. dang.. now what was i talking about??

 

---------------------------------

 

v1.4 now has newly added separate functions for Last Name and Company Name fields. This results in using the "Mc" and "Mac"

prefixes only in the Last name field -and- company initials only as CAPS in the company input field like... IBM or GM etc.

(the function file is now documented (//remarked) so you can edit the exceptions, prefixes, suffixes along with the company initials you would like to allow like "ABC Cleaners" "BB King CD Collections" "XXX Bookstore Inc." etc, etc... all to your exact liking :)

 

Prior versions cleaned text example...

Zz Top Tee Shirt Co.

John MacDonald

12 MacAroni Lane

MacKy, TX 12345

 

v1.4+ cleaned text example...

ZZ Top Tee Shirt Co.

John MacDonald

12 Macaroni Lane

Macky, TX 12345

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

  • 2 weeks later...
I've noticed an issue with German Umlauts:

letters like ä,ö,ü,ß cause cause the following letter to get capitalized.

Is there any solution for this problem?

 

Yes you can keep those in lowercase if you wish.

FILE TO EDIT: catalog/includes/functions/account_word_cleaner.php (make a backup first ;)

FIND:

   if ($is_name) {
   $all_uppercase = '';
   $all_lowercase = 'Or|And';

 

EDIT EXAMPLE (adding in your German Umlauts)

   if ($is_name) {
   $all_uppercase = '';
   $all_lowercase = 'Or|And|ä|ö|ü|ß';

 

Remember there are now 3 functions within this file, 1 for overall words, 1 for last name and 1 for company name. You can scroll down to the other functions if you wish to have the German Umlauts there as well... use the above example. Since I do not use these letters I did not test it live in my shops but it should work OK with no problems... but let us know!

 

Cheers,

KJ

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

My knowledge of German Umlauts is very limited. I know basics like Alt-0196 (on your keyboard) = Ä etc.

 

The problem lies in the utf8 formatted text that you use (and I don't). I know there are wrote functions that "convert" the text to actual text etc. ...This is not what you want (I know you want the Umlauts preserved) the below code will convert the accent words ;(

$txt = strtr($txt,
"\xe1\xc1\xe0\xc0\xe2\xc2\xe4\xc4\xe3\xc3\xe5\xc5".
"\xaa\xe7\xc7\xe9\xc9\xe8\xc8\xea\xca\xeb\xcb\xed".
"\xcd\xec\xcc\xee\xce\xef\xcf\xf1\xd1\xf3\xd3\xf2".
"\xd2\xf4\xd4\xf6\xd6\xf5\xd5\x8\xd8\xba\xf0\xfa".
"\xda\xf9\xd9\xfb\xdb\xfc\xdc\xfd\xdd\xff\xe6\xc6\xdf",
"aAaAaAaAaAaAacCeEeEeEeEiIiIiIiInNoOoOoOoOoOoOoouUuUuUuUyYyaAs")

 

So with my limited knowledge of German Umlauts (and accent letters) I may need a lot of Trial & Error BUT... right now I'm in the holiday shopping rush with my own online shops. When I can dedicate to this I will, till then I hope somebody with the German Umlauts (utf8) or the (European) accent letters experience jumps in and adds it to the function file.

 

Happy Holidays!

KJ

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

  • 4 weeks later...

Hello KJ - great contribution - I like it very much.

 

Unfortunately I got also hit bei the German-Umlaute problem and I wonder if you meanwhile have gotten an idea how to 'tackle' this small problem?

 

best regards

 

Dieter from germany

Link to comment
Share on other sites

  • 3 weeks later...

OK. I searched and hope I just didnt miss it.

 

Anyway, great contribution. It works great and saves us a ton of time.

 

What we are looking for is the possibility for this to fix issues like my example below:

 

Customer Enters:

Joe Shmoe

123ValleyRoad

Austin, Texas51515

 

Corrected:

Joe Shmoe

123 Valley Road

Austin, Texas 51515

 

Any help or direction would be appreciated!

Link to comment
Share on other sites

OK. I searched and hope I just didnt miss it.

 

Anyway, great contribution. It works great and saves us a ton of time.

 

What we are looking for is the possibility for this to fix issues like my example below:

 

Customer Enters:

Joe Shmoe

123ValleyRoad

Austin, Texas51515

 

Corrected:

Joe Shmoe

123 Valley Road

Austin, Texas 51515

 

Any help or direction would be appreciated!

 

Hi lefty

Thanks for the compliment. I have looked at this problem before and here is what I have got so far:

 

THe above can be coded in "if" customer inputs an uppercase letter before the supposedly line break. Well that pretty much shoots up the contrib b/c it's for people who can't or don't know when to use upper/lowercase correctly.

 

Catch 22 basically and here's an (using your) example (we'll take out the city, state, zip as it's another input line)

 

Customer Enters:

Joe Shmoe

123ValleyRoad

Austin, Texas51515

 

making line breaks (spaces) at uppercase would make as you said

Joe Shmoe

123 Valley Road

Austin, Texas 51515

 

NOW... what about if he enters:

Joe Shmoe

123valleyroad

Austin, Texas51515

 

We could target off a numeric entry and then make a space but we could never decide about the combined word, so it really could be "Valleyroad" sometimes.

 

So the bottom line is I guess input users (your customers) have to be somewhat responsible for entering their personal info b/c a program or "computer" as everybody calls it just can't be human :(

 

 

 

Contrib's "taskbar":

--------------------------------------------------

I've had a few PM's asking about how my contrib handles names with an ' --->Another words name entered as lisa D'antonio (or whatever mix) "will it be correctly formatted?" YES! It will be shown as Lisa D'Antonio

--------------------------------------------------

German Umlauts? I'm hoping somebody who uses German jumps in and writes in the Umlauts into the exception lists as I don't know the correct usages and phrases for them... I apologize to all of our German user/friends!

--------------------------------------------------

Also had requests for EZ-Mod install compatibility. Yes I can make the change to the install.txt quite easily but there are a few lines that may not be in everybody's osc snapshot. The install is very easy and I think keeping it as such is probably less confusing considering how the shop owner wants each line effected [e.g.] shopowner may not want "[email protected]" lowercased as "[email protected]" so he can just ommit that line in the install.txt!)

--------------------------------------------------

No reported lockups or "fubars" (hehe... an old computer programming term). But as always BACKUP all effected files before installing this (or any) contrib!

 

KJ.gif

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

  • 4 weeks later...
Hi.

Thanks for the contribution - it was needed.

 

is there a way to make it understand Scandinavian characters ?

like workds like "HÅKHØYVEIEN " and "SÆTER" are not correctly lower-cased.

 

Thank you.

 

Hi AndreD

Yes, you can change the standard ISO unicode character set within the contribs function file.

It is set to standard ISO (it's base vocabulary is for english and a bunch of other languages) but what ASCII didn't contain was accented characters (àéñ) and Scandinavian letters (åäöæøðþ). In a quick search I found ISO 8859-1 to include these. As said edit the character set line, then you have the task of changing or adding the exceptions (which as the German umlauts I have no knowledge of correct usages and short phrases that may be "CAPPED" or ""Not in addresses, names etc., sorry but it should be an easy change-over to include these characters to the function file for your (Scandinavian) native accent words/terminology since you know and use these in a everyday inviorment.

 

Cheers and please post your function file when done for other Scandinavians :)

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

  • 1 month later...

Hi there,

 

This is a great contibution, esp to format order information correctly so that it can be uploaded in a csv to generate shipping labels into 3rd party systems without throwing up any errors!

 

So far I have it working fine on the billing address but i'm struggling to get it to work on the shipping address. The problem I have is that i'm trying to get this to work on a combined billing/shipping address page as used in Fast Easy Checkout. It works great on fixing the billing address but I cannot figure how to get it to correct the shipping address.

 

Here is the page, I must be missing something simple, any ideas?

 

Thanks

 

Dave

Link to comment
Share on other sites

  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...