有什么好的姓氏数据库吗?

red*_*alx 7 database testing test-data

我正在寻找生成一些数据库测试数据,特别是包含人名的表列.为了更好地指示索引在基于名称的搜索方面的工作情况,我希望尽可能接近真实世界名称及其真实的频率分布,例如,许多不同的名称,其频率分布在某些幂律分布上.

理想情况下,我正在寻找一个免费提供的数据文件,其名称后跟每个名称的单个频率值(或等效概率).

基于盎格鲁撒克逊人的名字会很好,尽管来自其他文化的名字也会有用.

red*_*alx 5

我发现了一些符合要求的美国人口普查数据.唯一需要注意的是它只列出至少出现100次的名字......

通过此博客条目找到,也显示了幂律分布曲线

此外,您可以使用轮盘赌选择从列表中进行采样,例如(未测试)

struct NameEntry
{
    public string _name;
    public int _frequency;
}

int _frequencyTotal; // Precalculate this.


public string SampleName(NameEntry[] nameEntryArr, Random rng)
{
    // Throw the roulette ball.
    int throwValue = rng.NextDouble() * frequencyTotal;
    int accumulator = 0.0;

    for(int i=0; i<nameEntryArr.Length; i++)
    {
        accumulator += nameEntryArr[i]._frequency;
        if(throwValue <= accumulator) {
            return nameEntryArr[i]._name;
        }
    }

    // If we get here then we have an array of zero fequencies.
    throw new ApplicationException("Invalid operation. No non-zero frequencies to select.");
}
Run Code Online (Sandbox Code Playgroud)