Jump to content


Corporate Sponsors


Latest News: (loading..)

* * * - - 2 votes

[CONTRIBUTION] Sloppy Words Cleaner


63 replies to this topic

#21 Top_Speed

  • Community Member
  • 357 posts
  • Real Name:KJ Miller
  • Location:SU-ville (Syracuse)

Posted 21 November 2007, 21:47

Hey Bob,

Good info, I'll add the checkout_payment_process.php page

And.. the set $ names we'll inherit also. Since I started this as a personal "hack" (maily b/c I was fed up with crappy looking customer profiles/invoices) I kind of chopped away at the input fields and came up with the current code but clearly as far as mass users installing the later suggestion is going to be easier!!

:) I'll upload the revised install.txt after this writing.

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

#22 bob61

  • Community Member
  • 34 posts
  • Real Name:Bob

Posted 22 November 2007, 01:31

View PostTop_Speed, on Nov 21 2007, 04:47 PM, said:

Hey Bob,

Good info, I'll add the checkout_payment_process.php page

And.. the set $ names we'll inherit also. Since I started this as a personal "hack" (maily b/c I was fed up with crappy looking customer profiles/invoices) I kind of chopped away at the input fields and came up with the current code but clearly as far as mass users installing the later suggestion is going to be easier!!

:) I'll upload the revised install.txt after this writing.

Thanks!
-KJ
Totally understand about need to clean up user input fields. I took a simpler approach that was about 95% effective for my purposes - your function closed the gap. New install update looks good and hopefully will make it easier for others to use your personal "hack" to add a feature that should be standard with OSCommerce. Happy Holidays!

Edited by bob61, 22 November 2007, 01:38.


#23 Tsuri Japan

  • Community Member
  • 415 posts
  • Real Name:Nigel

Posted 22 November 2007, 17:06

I've been keeping an eye on this one since it first came out... the first one was a bit code intensive so I waited. But I was glad to see a much easier quicker version to install. It only took me about 5 minutes to do.

This contrib was needed, I was getting tired of my customers CAPING everything on site.

Cheers,

Nigel

#24 Top_Speed

  • Community Member
  • 357 posts
  • Real Name:KJ Miller
  • Location:SU-ville (Syracuse)

Posted 22 November 2007, 17:49

Glad you guys like it, I think it should be a part of the standard osC also. Hopefully some osC hierarchy will find this and consider it for embedding within the new upcoming version :)

Actually the new "easier to install" version is much less time to install, but the original code w/ line edits was actually cleaner (no redundant calls, it just issued the commands right at each input line).

BUT for a contribution (and not just my personal hack anymore), this new method is easier and I think many people will find it less confusing :)

Anybody having problems or comments... pls post!

Glad to help others always! Happy Holidays!
KJ Miller (top_speed)
define('PROJECTS', 'Something that goes on forever!');

#25 marcusdesign

  • Community Member
  • 142 posts
  • Real Name:Marcus A. Kaptein
  • Gender:Male
  • Location:Netherlands

Posted 22 November 2007, 19:28

View PostTop_Speed, on Nov 22 2007, 07:49 PM, said:

Glad you guys like it, I think it should be a part of the standard osC also. Hopefully some osC hierarchy will find this and consider it for embedding within the new upcoming version :)

Actually the new "easier to install" version is much less time to install, but the original code w/ line edits was actually cleaner (no redundant calls, it just issued the commands right at each input line).

BUT for a contribution (and not just my personal hack anymore), this new method is easier and I think many people will find it less confusing :)

Anybody having problems or comments... pls post!

Glad to help others always! Happy Holidays!
KJ Miller (top_speed)


Hi there,

Just wanna say it's working fine. It's really a great contribution and it's already up and running with no errors.

Thanks a lot !!!

Marcus

#26 Azur42

  • Community Member
  • 2 posts
  • Real Name:Christophe Gravereau

Posted 24 November 2007, 08:45

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

#27 Top_Speed

  • Community Member
  • 357 posts
  • Real Name:KJ Miller
  • Location:SU-ville (Syracuse)

Posted 24 November 2007, 17:51

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!');

#28 Azur42

  • Community Member
  • 2 posts
  • Real Name:Christophe Gravereau

Posted 24 November 2007, 18:17

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

#29 Top_Speed

  • Community Member
  • 357 posts
  • Real Name:KJ Miller
  • Location:SU-ville (Syracuse)

Posted 26 November 2007, 16:35

View PostAzur42, on Nov 24 2007, 01:17 PM, said:

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!');

#30 Top_Speed

  • Community Member
  • 357 posts
  • Real Name:KJ Miller
  • Location:SU-ville (Syracuse)

Posted 26 November 2007, 20:26

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, 26 November 2007, 20:32.

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

#31 Top_Speed

  • Community Member
  • 357 posts
  • Real Name:KJ Miller
  • Location:SU-ville (Syracuse)

Posted 27 November 2007, 17:47

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!');

#32 bob61

  • Community Member
  • 34 posts
  • Real Name:Bob

Posted 27 November 2007, 22:32

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, 27 November 2007, 22:41.


#33 bob61

  • Community Member
  • 34 posts
  • Real Name:Bob

Posted 27 November 2007, 23:07

Another problem - Any input that starts with "de" gets modified. Example if input is "dependable" the name becomes "DePendable". Input is Denton become DeNton :o

#34 Top_Speed

  • Community Member
  • 357 posts
  • Real Name:KJ Miller
  • Location:SU-ville (Syracuse)

Posted 28 November 2007, 14:37

View Postbob61, on Nov 27 2007, 05:32 PM, said:

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!');

#35 bob61

  • Community Member
  • 34 posts
  • Real Name:Bob

Posted 28 November 2007, 23:01

View PostTop_Speed, on Nov 28 2007, 08:37 AM, said:

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.....

#36 Top_Speed

  • Community Member
  • 357 posts
  • Real Name:KJ Miller
  • Location:SU-ville (Syracuse)

Posted 29 November 2007, 14:34

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!');

#37 Top_Speed

  • Community Member
  • 357 posts
  • Real Name:KJ Miller
  • Location:SU-ville (Syracuse)

Posted 29 November 2007, 22:50

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!');

#38 tfrischholz

  • Community Member
  • 10 posts
  • Real Name:Tobias Frischholz

Posted 11 December 2007, 15:12

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?

#39 Top_Speed

  • Community Member
  • 357 posts
  • Real Name:KJ Miller
  • Location:SU-ville (Syracuse)

Posted 11 December 2007, 20:25

View Posttfrischholz, on Dec 11 2007, 10:12 AM, said:

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!');

#40 Top_Speed

  • Community Member
  • 357 posts
  • Real Name:KJ Miller
  • Location:SU-ville (Syracuse)

Posted 11 December 2007, 20:28

(maybe) my bad...

Did you actually mean "following" letter?. If so give me some examples of what it does.

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