生成易于记忆的随机标识符 [英] Generating easy-to-remember random identifiers

查看:120
本文介绍了生成易于记忆的随机标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像所有开发人员一样,我们在日常工作中会不断处理某种标识符.大多数情况下,它是关于错误或支持通知单的.我们的软件在检测到错误后会创建一个具有时间戳和版本号格式的名称的软件包,这是创建合理的唯一标识符以避免混淆软件包的一种廉价方法.例如:"错误报告20101214 174856 6.4b2 ".

我的大脑并不擅长记住数字.我很想拥有一种生成易于记忆的字母数字标识符的简单方法.

在python中生成如下所示的算法大约需要5分钟,这会产生一半的可用结果:

import random

vowels = 'aeiuy' # 0 is confusing
consonants = 'bcdfghjklmnpqrstvwxz'
numbers = '0123456789'

random.seed()

for i in range(30):
    chars = list()
    chars.append(random.choice(consonants))
    chars.append(random.choice(vowels))
    chars.append(random.choice(consonants + numbers))
    chars.append(random.choice(vowels))
    chars.append(random.choice(vowels))
    chars.append(random.choice(consonants))
    print ''.join(chars)

结果如下:

re1ean
meseux
le1ayl
kuteef
neluaq
tyliyd
ki5ias

这已经很不错了,但是我觉得仍然很容易忘记它们的确切拼写,因此,如果您走到同事的桌子旁,想抬头看看其中的一个,那么仍然存在潜在的困难. /p>

我知道对文本进行三字母组合分析的算法(例如,您用德语为整本书喂它们),并且可以生成外观和感觉都像德语单词的字符串,因此通常更易于处理.但是,这需要大量数据,并且使其略微不适合为此目的而嵌入到应用程序中.

您知道有解决此问题的已发布算法吗?

谢谢!

卡尔

解决方案

我不确定这是否能回答您的问题,但也许想想您需要多少个唯一的错误报告编号.

仅使用四个字母的大写字母数字键(例如"BX-3D"),您就可以拥有36 ^ 4 = 170万个错误报告.

编辑:我刚刚看到了您的示例.如果您使用音节代替辅音和元音,也许结果可以得到很大的改善.

As all developers do, we constantly deal with some kind of identifiers as part of our daily work. Most of the time, it's about bugs or support tickets. Our software, upon detecting a bug, creates a package that has a name formatted from a timestamp and a version number, which is a cheap way of creating reasonably unique identifiers to avoid mixing packages up. Example: "Bug Report 20101214 174856 6.4b2".

My brain just isn't that good at remembering numbers. What I would love to have is a simple way of generating alpha-numeric identifiers that are easy to remember.

It takes about 5 minutes to whip up an algorithm like the following in python, which produces halfway usable results:

import random

vowels = 'aeiuy' # 0 is confusing
consonants = 'bcdfghjklmnpqrstvwxz'
numbers = '0123456789'

random.seed()

for i in range(30):
    chars = list()
    chars.append(random.choice(consonants))
    chars.append(random.choice(vowels))
    chars.append(random.choice(consonants + numbers))
    chars.append(random.choice(vowels))
    chars.append(random.choice(vowels))
    chars.append(random.choice(consonants))
    print ''.join(chars)

The results look like this:

re1ean
meseux
le1ayl
kuteef
neluaq
tyliyd
ki5ias

This is already quite good, but I feel it is still easy to forget how they are spelled exactly, so that if you walk over to a colleagues desk and want to look one of those up, there's still potential for difficulty.

I know of algorithms that perform trigram analysis on text (say you feed them a whole book in German) and that can generate strings that look and feel like German words and are thus easier to handle generally. This requires lots of data, though, and makes it slightly less suitable for embedding in an application just for this purpose.

Do you know of any published algorithms that solve this problem?

Thanks!

Carl

解决方案

I am not sure that this answers your question, but maybe think about how many unique bug report number you need.

Simply using a four letter uppercase alphanumeric key like "BX-3D", you can have 36^4 = 1.7 million bug reports.

Edit: I just saw your sample. Maybe the results could be considerably improved if you used syllables instead of consonants and vowels.

这篇关于生成易于记忆的随机标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆