def check_nick (maplight_name,nameobj): full_name =encode.decodeuc(nameobj['nick'].lower() + " "+ nameobj['last'].lower()) full_name2 =encode.decodeuc(nameobj['first'].lower() + " "+ nameobj['nick'].lower() + " "+ nameobj['last'].lower()) if (full_name == maplight_name): return person_match(full_name) elif (full_name2 == maplight_name): return person_match(full_name2) else: return check_suffix(full_name,maplight_name,nameobj)
def check_nick(maplight_name, nameobj): full_name = encode.decodeuc(nameobj["nick"].lower() + " " + nameobj["last"].lower()) full_name2 = encode.decodeuc( nameobj["first"].lower() + " " + nameobj["nick"].lower() + " " + nameobj["last"].lower() ) if full_name == maplight_name: return person_match(full_name) elif full_name2 == maplight_name: return person_match(full_name2) else: return check_suffix(full_name, maplight_name, nameobj)
def check_middle_initial (maplight_name,nameobj): full_name =encode.decodeuc(nameobj['first'].lower() + " "+ nameobj['middle'][0].lower() + ". "+ nameobj['last'].lower()) full_name2 =encode.decodeuc(nameobj['first'].lower() + " "+ nameobj['middle'][0].lower() + " "+ nameobj['last'].lower()) if (full_name == maplight_name) : return person_match(full_name) elif (full_name2 == maplight_name) : return person_match(full_name) elif check_suffix(full_name,maplight_name,nameobj) : return person_match(full_name) else : return check_suffix(full_name2,maplight_name,nameobj) return False
def check_simple(maplight_name,nameobj): full_name =encode.decodeuc(nameobj['official_full'].lower()) full_name2 =encode.decodeuc(nameobj['first'].lower() + " "+ nameobj['last'].lower()) if (full_name == maplight_name) : return person_match(full_name) elif (full_name2 == maplight_name) : return person_match(full_name) elif 'nick' in nameobj : return check_nick(maplight_name,nameobj) elif 'middle' in nameobj : return check_middle(maplight_name,nameobj) else: # print "Fail last:\"%s\"" % maplight_name, "name:",nameobj return False
def check_simple(last_obj,nameobj): full_name =encode.decodeuc(nameobj['official_full'].lower()) full_name2 =encode.decodeuc(nameobj['first'].lower() + " "+ nameobj['last'].lower()) if (full_name == last_obj) : person_match(full_name) return True elif (full_name2 == last_obj) : person_match(full_name) return True elif 'nick' in nameobj : return check_nick(last_obj,nameobj) elif 'middle' in nameobj : return check_middle(last_obj,nameobj) else: # print "last",last_obj,"name",nameobj,"term",last_term return False
def check_simple(maplight_name, nameobj): full_name = encode.decodeuc(nameobj["official_full"].lower()) full_name2 = encode.decodeuc(nameobj["first"].lower() + " " + nameobj["last"].lower()) if full_name == maplight_name: return person_match(full_name) elif full_name2 == maplight_name: return person_match(full_name) elif "nick" in nameobj: return check_nick(maplight_name, nameobj) elif "middle" in nameobj: return check_middle(maplight_name, nameobj) else: # print "Fail last:\"%s\"" % maplight_name, "name:",nameobj return False
def check_middle_initial (last_obj,nameobj): full_name =encode.decodeuc(nameobj['first'].lower() + " "+ nameobj['middle'][0].lower() + ". "+ nameobj['last'].lower()) if (full_name == last_obj) : # print "match!",full_name person_match(full_name) return True else: return check_suffix(full_name,last_obj,nameobj)
def check_nick (last_obj,nameobj): full_name =encode.decodeuc(nameobj['nick'].lower() + " "+ nameobj['last'].lower()) if (full_name == last_obj) : # print "match6!",full_name # return True person_match(full_name) return True else: return check_suffix(full_name,last_obj,nameobj)
def check_middle_initial(maplight_name, nameobj): full_name = encode.decodeuc( nameobj["first"].lower() + " " + nameobj["middle"][0].lower() + ". " + nameobj["last"].lower() ) full_name2 = encode.decodeuc( nameobj["first"].lower() + " " + nameobj["middle"][0].lower() + " " + nameobj["last"].lower() ) if full_name == maplight_name: return person_match(full_name) elif full_name2 == maplight_name: return person_match(full_name) elif check_suffix(full_name, maplight_name, nameobj): return person_match(full_name) else: return check_suffix(full_name2, maplight_name, nameobj) return False
def check_middle (maplight_name,nameobj): full_name =encode.decodeuc(nameobj['first'].lower() + " "+ nameobj['middle'].lower() + " "+ nameobj['last'].lower()) if (full_name == maplight_name) : # print "match3!",full_name return person_match(full_name) else : if (not check_middle_initial(maplight_name,nameobj)) : return check_suffix(full_name,maplight_name,nameobj) return False
def load(): legis = loadlegis() # legis = cache.cache ( "legis",loadlegis) data = { 'wp' : {}, 'raw' : legis } for l in legis: if 'wikipedia' in l['id'] : wp = l['id']['wikipedia'] wp = wp.replace(" ","_") wp = encode.decodeuc(wp) data['wp'][wp]=l else: print "no wikipedia ", l return data
def load(): legis = loadlegis() # legis = cache.cache ( "legis",loadlegis) data = {'wp': {}, 'raw': legis} for l in legis: if 'wikipedia' in l['id']: wp = l['id']['wikipedia'] wp = wp.replace(" ", "_") wp = encode.decodeuc(wp) data['wp'][wp] = l else: print "no wikipedia ", l return data
def check_middle(maplight_name, nameobj): full_name = encode.decodeuc( nameobj["first"].lower() + " " + nameobj["middle"].lower() + " " + nameobj["last"].lower() ) if full_name == maplight_name: # print "match3!",full_name return person_match(full_name) else: if not check_middle_initial(maplight_name, nameobj): return check_suffix(full_name, maplight_name, nameobj) return False
def apply(data): for l in data['raw'] : if 'wikipedia' in l['id'] : wp = l['id']['wikipedia'] wp = wp.replace(" ","_") wp = encode.decodeuc(wp) new = data['wp'][wp] l['id']=new['id'] # if ('ballot' in new['id']) : # clean up the ballot if 'ballot' in l['id']: b = l['id']['ballot'] del l['id']['ballot'] b=b.replace("_"," ") l['id']['ballotpedia']=b return data
def apply(data): for l in data['raw']: if 'wikipedia' in l['id']: wp = l['id']['wikipedia'] wp = wp.replace(" ", "_") wp = encode.decodeuc(wp) new = data['wp'][wp] l['id'] = new['id'] # if ('ballot' in new['id']) : # clean up the ballot if 'ballot' in l['id']: b = l['id']['ballot'] del l['id']['ballot'] b = b.replace("_", " ") l['id']['ballotpedia'] = b return data