project:human_name_creativity

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
project:human_name_creativity [2019/09/10 23:30] dsieviproject:human_name_creativity [2019/09/24 01:34] (current) – [Human Name Creativity] dsievi
Line 5: Line 5:
 Unfortunately it wasn’t finished until the end of the Hackathon, no UI, but here's the last draft version of the code:  Unfortunately it wasn’t finished until the end of the Hackathon, no UI, but here's the last draft version of the code: 
 <code> <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))
 </code> </code>
  
  • project/human_name_creativity.txt
  • Last modified: 2019/09/24 01:34
  • by dsievi