project:human_name_creativity

Following the last years project about dog names Dog Name Creativity Survey of New York City Dog Name Creativity Survey of New York City. The focus this year was on human names. The swiss post provides datasets with the top 5 names from each postal code. The goal was again to create a creativity index. But this year, under the motto of user involvement with the option to enter your own name, set the language your name is from and to see yourself in the ranking. The datasets are not perfect for this task, because they don’t contain all the names, only the top 5 per postal code. So the user has a high chance to get a “score-buff” for uniqueness. Nevertheless it is a fun project.

Unfortunately it wasn’t finished until the end of the Hackathon, no UI, but here's the last draft version of the code:

import pandas as pd

HaufeD_ = {"e":1,"n":2,"i":3,"r":4,"s":5,"-":5,"t":6,"a":7,"d":8,"h":9,"u":10,"l":11,"c":12,"g":13,"m":14,"o":15,"b":16, \
           "w":17,"f":18,"k":19,"z":20,"v":21,"p":22,"ü":23,"ä":24,"ö":25,"j":26,"x":27,"y":28,"q":29}
HaufeF_ = {"e":1,"a":2,"s":3,"t":4,"i":5,"-":5,"r":6,"n":7,"u":8,"l":9,"o":10,"d":11,"m":12,"c":13,"p":14,"é":15,"v":16, \
           "h":17,"g":18,"f":19,"b":20,"q":21,"j":22,"à":23,"x":24,"è":25,"ê":26,"z":27,"y":28,"k":29,"ô":29,"û":29,"w":29 \
           ,"â":29,"î":29,"ü":29,"ù":29,"ë":29,"Œ":29,"ç":29,"ï":29}
#HaufeI_ =
landics = {"d":HaufeD_,"f":HaufeF_}

def KreaWert(name_,lan):
    dic = landics[lan]
    name_ = str(name_)
    wert_ = 0
    for letter in str.lower(name_):
        temp_ = 0
        if letter in dic :
            temp_ += dic[letter]
            wert_ += temp_
        else:
            temp_ += 20
            wert_ += temp_
    try:
        H_[name_]
        wert_ = wert_* ((Hmax-H_[name_])/(Hmax-1)*5 + 0.2)
    except KeyError as exception:
        pass
    if len(name_) < (DNL-2) or len(name_) > (DNL+2):
        wert_ = wert_/10*8
    return round(wert_,1)

df = pd.read_csv("vornamen_proplz.csv", sep = ",")
df["vorname"] = df["vorname"].str.strip()

insgeNamLan_ = 0
for name in df["vorname"]:
    insgeNamLan_ += len(str(name))
    
#unkreativitätsrange = weniger als 4 / mehr als 8
DNL = round(insgeNamLan_ / len(df["vorname"]))
    
#Häufigkeit der Namen = H_
H_ = {}
counter = 0
for name in df["vorname"]:
    if name in H_:
        H_[name] += df["anzahl"][counter]
        counter += 1
    else:
        H_[name] = df["anzahl"][counter]
        counter +=1
sortH_ = sorted(H_.values())
Hmax = sortH_[len(sortH_)-1]
Hmin = sortH_[0] 

lan = input("Set the language of your name (d/i/f): ")
name_ = input("What is your first name? ")

print(KreaWert(name_,lan))
  • project/human_name_creativity.txt
  • Last modified: 2019/09/24 01:34
  • by dsievi