I think it’s a common situation when one needs to contract certain phrases to make identifiers, preserving the original sense. Is there a software/algorithms to facilitate it?
I have a hundred word combinations each around 20 characters long which I want to turn into no-more-than-12-character-long identifiers.
An example:
CUSTOMER_ACCOUNT -> CUSTOMER_ACC
or even
CUSTOMER_ACCOUNT -> CUST_ACC
Solution A
Do it manually, load your words into any text processing editor, run Find-And-Replace with your words, for example:
CUSTOMERCUSTIt is human readable but requires manual work.
Solution B
Use hashtable:
Hash function will be unique and you can tailor its length, the problem is, it is not human-readable.
Solution C
If you store this somewhere (db, xml, etc.) you can have a structure like
Each phrase has its own unique id and the text. Internally you use GUID, but for display purposes you use text representation.