in reply to Generate unique initials from a list of names

If fitting data onto one line is essential

In your situation, I would look into Soundex and similar name encoding algorithms.

Normally they are used to match up variant spellings of names, but since they convert a name to a code, yet still have a chancee of recognizing the name from the code.


Consider multi-line output

Alternatly, you could look into using format and turning the Consumer section into a multi-line component:

Date Range Level Consumers -------------------------- ------- ---------------------------------- 13 Mar 2004 to 23 Mar 2004 7 John Wayne, John Dillinger, George W. Bush, Federico Felini, Ian Sutherland, Katherine Hepburn, + Madonna

No messy encodings, no problems figuring out the identities of the people in the Consumers list, only a minor inconvenience learning to use a format.

--
TTTATCGGTCGTTATATAGATGTTTGCA

Replies are listed 'Best First'.
Re: Re: Generate unique initials from a list of names
by EdwardG (Vicar) on Mar 12, 2004 at 14:08 UTC

    The multi-line approach is probably my most realistic fallback, and I must confess that this has (for me) turned into a bit of an academic exercise, just for fun.

    I did briefly consider a soundex encoding (metaphone actually), but I couldn't find a suitable encoding. Text::Soundex gives results like 'E460' and 'L222', and Text::Metaphone gives results that are in some cases worse than my Initials hack -

    D:\tmp>cat metaphone.pl use Text::Metaphone; print $_,' => ', Metaphone($_),"\n" for map {chomp;$_} <DATA>; __DATA__ Stephen Thrasher Steve Trasher D:\tmp>metaphone.pl Stephen Thrasher => STFN0RXR Steve Trasher => STFTRXR D:\tmp>initials.pl Stephen Thrasher => StTh Steve Trasher => StTr D:\tmp>