Long string to short ID

Ian Hobson hobson42@REDACTED
Fri Aug 13 22:26:15 CEST 2021


Hi Lloyd

On 13/08/2021 20:44, Lloyd R. Prentice wrote:
> Hello,
> 
> What might be a nifty way to turn a long book title with spaces into a short human-readable ID?
> 
> Thanks,
> 
> LRP
>
I can think of two ways.

1) Append the initials of the title (perhaps omitting short functions 
words like "The", "Of" etc) to the initials of the Author. Also it would 
help to convert numbers to digits first.

"The Four Hour Work Week", by Tim Ferriss becomes  TF4HWW

Its easy to remember and may even be guessable in context.

2) You could hash the title and express the result in a high base (being 
careful to avoid confusable letters (I1l, O0 etc), and append that to 
the Author's initials.

So the example might be TFkUw4

This would probably make all the keys a similar length, but would not be 
guessable.

In both cases you will have to have some way to recognise name clashes, 
and disambiguate them - perhaps adding -1, -2 etc to the duplicates.

Regards

Ian

-- 
Ian Hobson
Tel (+351) 910 418 473

-- 
This email has been checked for viruses by AVG.
https://www.avg.com



More information about the erlang-questions mailing list