[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: [sqr-users] SQR Code needed to convert employee name from upper case to m...
My effort is below. It correctly converts the following:
Old Surname New Surname
DE BASTO de Basto
DE LOS ANGELES de los Angeles
MCDONALD McDonald
O'REILLY O'Reilly
DUNCAN-SMITH Duncan-Smith
TWOO WORDS Twoo Words (I can't think of a real life example, but it happens)
HO LING Ho Ling
MORRIS EL Morris El (this name came up in a newspaper recently)
SMITH Smith
Caveats:
1. To properly do Chinese names, you need an ethnic code, $ethnic, to
identify your Orientals. UK PeopleSoft has such a thing, global PeopleSoft
doesn't.
Without a specific code, HO LING becomes Ho ling.
2. The procedure works on the kind of names you find in Europe - you'd have
to hard-code any 'funnies' you get in your locality. It's a heuristic, i.e. it
usually gives a good answer, but if you want to be perfect, you have to use
the Mark I Eyeball.
3. Please note that Eric Rection is a pseudonym (E.Rection - geddit? Maturity
is for cheeses). Credit me, huh?
4. The procedure works on the PeopleSoft demo DB but I admit I haven't tried
it on a huge quantity of data.
5. The spacing looks nice on PFE but not here. Bummer.
begin-procedure capitalise($name,$ethnic,:$capitalised)
let $capitalised = ''
let #len = length($name)
let #current_char = 1
let #new_word = 1
let $old_char = ' '
while #current_char <= #len
let #found_space = instr($name,' ',#current_char)
let $current_char = substr($name,#current_char,1)
if
! de Basto, de los Angeles but not two word surnames
(
(
instr($name,' ',#current_char) > 0 and
$ethnic <> '8' and
not ($old_char = ' ' and
instr($name,' ',#current_char) > #current_char+3)
) or
! exempt Chinese surnames from the above rule - requires a specific Chinese
ethnic group code
(
$ethnic = '8' and
$old_char <> ' '
) or
! Conventional surnames
(
instr($name,' ',#current_char) = 0 and
$old_char <> ' '
)
) and
! McDonald, O'Leary
not
(
#current_char = 3 and
(
substr($name,1,2) = 'MC' or
substr($name,1,2) = 'O'''
)
) and
! Duncan-Smith
$old_char <> '-'
let $current_char = lower($current_char)
else
let $current_char = upper($current_char)
end-if
#ifdef debugx
show $current_char ' ' #current_char ' new word ' #new_word ' 1st spc '
#found_space
#endif
if $current_char = ' '
let #new_word = #current_char
end-if
let $capitalised = $capitalised || $current_char
let #current_char = #current_char + 1
let $old_char = $current_char
end-while
end-procedure
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users