示例#1
0
ed_map.update(dict([('{state} Board of Education District {number}'.format(state=state[0], number=(int(sdpat.match(n).groupdict()['number']) if sdpat.match(n) else n)).lower(),{'name':n,'type':'school_district'}) for n in school_district]))
ed_map.update(dict([('{state} State Board of Education District {number}'.format(state=state[0], number=(int(sdpat.match(n).groupdict()['number']) if sdpat.match(n) else n)).lower(),{'name':n,'type':'school_district'}) for n in school_district]))

ed_map.update(dict([('Congressional District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'congressional_district'}) for n in congressional_district]))
ed_map.update(dict([('State Senate District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'state_senate_district'}) for n in state_senate_district]))
ed_map.update(dict([('State House District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'state_rep_district'}) for n in state_representative_district]))
ed_map.update(dict([('{state} State House of Representatives - District {number}'.format(state=state[0], number=(numberclean(n))).lower(),{'name':n,'type':'state_rep_district'}) for n in state_representative_district]))
ed_map.update(dict([('State Representative District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'state_rep_district'}) for n in state_representative_district]))
ed_map.update(dict([('State Legislature District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'state_rep_district'}) for n in state_representative_district]))
ed_map.update(dict([('Legislative District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'state_rep_district'}) for n in state_representative_district]))
ed_map.update(dict([('Judicial District {number}'.format(number=(numberclean(jdpat.match(n).groupdict()['number']+jdpat.match(n).groupdict()['extra']) if jdpat.match(n) else n)).lower(),{'name':n,'type':'judicial_district'}) for n in judicial_district]))
ed_map.update(dict([('State School Board District {number}'.format(number=(int(sdpat.match(n).groupdict()['number']) if sdpat.match(n) else n)).lower(),{'name':n,'type':'school_district'}) for n in school_district]))
ed_map.update(dict([('Board of Education District {number}'.format(number=(int(sdpat.match(n).groupdict()['number']) if sdpat.match(n) else n)).lower(),{'name':n,'type':'school_district'}) for n in school_district]))
ed_map.update(dict([('State Board of Education District {number}'.format(number=(int(sdpat.match(n).groupdict()['number']) if sdpat.match(n) else n)).lower(),{'name':n,'type':'school_district'}) for n in school_district]))

towndict = passdict({'PUTMAN':'PUTNAM','KILLLINGWORTH':'KILLINGWORTH'})
ed_map.update(dict([('{name} township'.format(name=towndict[n]).lower(), {'name':n,'type':'township'}) for n in township]))
ed_map.update(dict([('{name} (muni)'.format(name=towndict[n]).lower(), {'name':n,'type':'township'}) for n in township]))

for county in county_id:
    county = re.sub(r'(?P<prefix>[_\s]|^)s(?:ain)?t.?(?P<suffix>[_\s]|$)', _saintrep, county.lower().strip())
    county = county.replace("'",'')
    ed_map.update({'{name} County'.format(name=county).lower():{'name':county,'type':'county'}})

county_council_dicts = []
fillers = ('Commissioner District', 'County Commissioner', 'CO Commission District','CO Commissioner District','County District','County Commissioner District','County - Commission District','County Commission District','County Committee District','County - Commissioner District','County - Comm District','County - Council District','County Council District','County - County Commissioner District',)
for county in county_council:
    county = re.sub(r'(?P<prefix>[_\s]|^)s(?:ain)?t.?(?P<suffix>[_\s]|$)', _saintrep, county.lower().strip())
    county = county.replace("'",'')
    m =  re.match(r'(?P<county_name>[A-Za-z ]+)\s(?P<prefixed>(?:[A-Za-z]*#?\s?)?(?P<district_number>\d+)?(?:\.(?P<number_decimal>\d+))?)', county)
    if m and  m.groupdict()['district_number']:
示例#2
0
ed_map.update(dict([('State House District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'state_rep_district'}) for n in state_representative_district]))
ed_map.update(dict([('{state} State House of Representatives - District {number}'.format(state=state[0], number=(numberclean(n))).lower(),{'name':n,'type':'state_rep_district'}) for n in state_representative_district]))
ed_map.update(dict([('State Representative District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'state_rep_district'}) for n in state_representative_district]))
ed_map.update(dict([('State Legislature District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'state_rep_district'}) for n in state_representative_district]))
ed_map.update(dict([('Legislative District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'state_rep_district'}) for n in state_representative_district]))
ed_map.update(dict([('Judicial District {number}'.format(number=(numberclean(jdpat.match(n).groupdict()['number']+jdpat.match(n).groupdict()['extra']) if jdpat.match(n) else n)).lower(),{'name':n,'type':'judicial_district'}) for n in judicial_district]))
ed_map.update(dict([('State School Board District {number}'.format(number=(int(sdpat.match(n).groupdict()['number']) if sdpat.match(n) else n)).lower(),{'name':n,'type':'school_district'}) for n in school_district]))
ed_map.update(dict([('Board of Education District {number}'.format(number=(int(sdpat.match(n).groupdict()['number']) if sdpat.match(n) else n)).lower(),{'name':n,'type':'school_district'}) for n in school_district]))
ed_map.update(dict([('State Board of Education District {number}'.format(number=(int(sdpat.match(n).groupdict()['number']) if sdpat.match(n) else n)).lower(),{'name':n,'type':'school_district'}) for n in school_district]))

def county_name_clean(county):
    county = re.sub(r'(?P<prefix>[_\s]|^)s(?:ain)?te?\.?(?P<suffix>[_\s]|$)', _saintrep, county.lower().strip())
    county = county.replace("'",'')
    return county

mo_exceptions = passdict({'de kalb':'dekalb'})
for county in county_id:
    old_county = county
    county = mo_exceptions[county_name_clean(county)]
    ed_map.update({'{name} County'.format(name=county).lower():{'name':old_county,'type':'county'}})
    if county.endswith('city'):
        ed_map.update({'{name}'.format(name=county).lower():{'name':old_county,'type':'county'}})

county_council_dicts = []
fillers = ('County Commissioner Precinct','County Commission Precinct','County Comissioner District','Commissioner District', 'County Commissioner', 'CO Commission District','CO Commissioner District','County District','County Commissioner District','County - Commission District','County Commission District','County Committee District','County - Commissioner District','County - Comm District','County - Council District','County Council District','County - County Commissioner District','County - District','County Board District','County Board - District','- District', 'Commission District')
roman_map = {'I':1,'II':2,'III':3,'IV':4,'V':5,'i':1,'ii':2,'iii':3,'iv':4,'v':5}
def clean_county_number(district_number):
    try:
        return int(district_number)
    except:
        return roman_map[district_number]
示例#3
0
ed_map.update(
    dict([('Board of Education District {number}'.format(number=(
        int(sdpat.match(n).groupdict()['number']) if sdpat.match(n) else n
    )).lower(), {
        'name': n,
        'type': 'school_district'
    }) for n in school_district]))
ed_map.update(
    dict([('State Board of Education District {number}'.format(number=(
        int(sdpat.match(n).groupdict()['number']) if sdpat.match(n) else n
    )).lower(), {
        'name': n,
        'type': 'school_district'
    }) for n in school_district]))

towndict = passdict({'PUTMAN': 'PUTNAM', 'KILLLINGWORTH': 'KILLINGWORTH'})
ed_map.update(
    dict([('{name} township'.format(name=towndict[n]).lower(), {
        'name': n,
        'type': 'township'
    }) for n in township]))
ed_map.update(
    dict([('{name} (muni)'.format(name=towndict[n]).lower(), {
        'name': n,
        'type': 'township'
    }) for n in township]))

for county in county_id:
    county = re.sub(r'(?P<prefix>[_\s]|^)s(?:ain)?t.?(?P<suffix>[_\s]|$)',
                    _saintrep,
                    county.lower().strip())
示例#4
0
from data.reformat import _saintrep
from data.passdict import passdict
ss = reload(ss)
districts = ss.districts 
from collections import defaultdict
d_dict = defaultdict(lambda:[],districts.__dict__)
judicial_district = d_dict['judicial_district']
county_council = d_dict['county_council']
congressional_district = d_dict['congressional_district']
state_senate_district = d_dict['state_senate_district']
state_representative_district = d_dict['state_rep_district']
school_district = d_dict['school_district']
county_id = d_dict['county_id']
township = d_dict['township']
state = districts.state
state_senate_dict = passdict({'chittenden-grand isle':'grand isle'})

intpat = re.compile(r'^(?P<number>\d+)(?P<extra>\D*)$')
jdpat = re.compile(r'^(?:JD)?(?P<number>\d+)(?P<extra>\D*)$')
sdpat = re.compile(r'^(?:S[DS])?(?P<number>\d+)$')
def numberclean(n):
    m = intpat.match(n)
    if m:
        return str(int(m.groupdict()['number'])) + m.groupdict()['extra']
    else:
        return n

ed_map = {}
ed_map.update({state[0].lower():{'name':state[0].lower(), 'type':'state'}})

ed_map.update(dict([('{state} Congressional District {number}'.format(state=state[0], number=(numberclean(n))).lower(),{'name':n,'type':'congressional_district'}) for n in congressional_district]))
示例#5
0
ed_map.update(dict([('{state} Board of Education District {number}'.format(state=state[0], number=(int(sdpat.match(n).groupdict()['number']) if sdpat.match(n) else n)).lower(),{'name':n,'type':'school_district'}) for n in school_district]))
ed_map.update(dict([('{state} State Board of Education District {number}'.format(state=state[0], number=(int(sdpat.match(n).groupdict()['number']) if sdpat.match(n) else n)).lower(),{'name':n,'type':'school_district'}) for n in school_district]))

ed_map.update(dict([('Congressional District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'congressional_district'}) for n in congressional_district]))
ed_map.update(dict([('State Senate District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'state_senate_district'}) for n in state_senate_district]))
ed_map.update(dict([('State House District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'state_rep_district'}) for n in state_representative_district]))
ed_map.update(dict([('{state} State House of Representatives - District {number}'.format(state=state[0], number=(numberclean(n))).lower(),{'name':n,'type':'state_rep_district'}) for n in state_representative_district]))
ed_map.update(dict([('State Representative District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'state_rep_district'}) for n in state_representative_district]))
ed_map.update(dict([('State Legislature District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'state_rep_district'}) for n in state_representative_district]))
ed_map.update(dict([('Legislative District {number}'.format(number=(numberclean(n))).lower(),{'name':n,'type':'state_rep_district'}) for n in state_representative_district]))
ed_map.update(dict([('Judicial District {number}'.format(number=(numberclean(jdpat.match(n).groupdict()['number']+jdpat.match(n).groupdict()['extra']) if jdpat.match(n) else n)).lower(),{'name':n,'type':'judicial_district'}) for n in judicial_district]))
ed_map.update(dict([('State School Board District {number}'.format(number=(int(sdpat.match(n).groupdict()['number']) if sdpat.match(n) else n)).lower(),{'name':n,'type':'school_district'}) for n in school_district]))
ed_map.update(dict([('Board of Education District {number}'.format(number=(int(sdpat.match(n).groupdict()['number']) if sdpat.match(n) else n)).lower(),{'name':n,'type':'school_district'}) for n in school_district]))
ed_map.update(dict([('State Board of Education District {number}'.format(number=(int(sdpat.match(n).groupdict()['number']) if sdpat.match(n) else n)).lower(),{'name':n,'type':'school_district'}) for n in school_district]))

countydict = passdict({'LE FLORE':'LEFLORE','le flore':'leflore'})
def county_name_clean(county):
    county = countydict[county]
    county = re.sub(r'(?P<prefix>[_\s]|^)s(?:ain)?te?\.?(?P<suffix>[_\s]|$)', _saintrep, county.lower().strip())
    county = county.replace("'",'')
    return county

for county in county_id:
    old_county = county
    county = county_name_clean(county)
    ed_map.update({'{name} County'.format(name=county).lower():{'name':old_county,'type':'county'}})
    if county.endswith('city'):
        ed_map.update({'{name}'.format(name=county).lower():{'name':old_county,'type':'county'}})

roman_map = {'I':1,'II':2,'III':3,'IV':4,'V':5,'i':1,'ii':2,'iii':3,'iv':4,'v':5}
def clean_county_number(district_number):
示例#6
0
from data.reformat import _saintrep
from data.passdict import passdict
ss = reload(ss)
districts = ss.districts
from collections import defaultdict
d_dict = defaultdict(lambda: [], districts.__dict__)
judicial_district = d_dict['judicial_district']
county_council = d_dict['county_council']
congressional_district = d_dict['congressional_district']
state_senate_district = d_dict['state_senate_district']
state_representative_district = d_dict['state_rep_district']
school_district = d_dict['school_district']
county_id = d_dict['county_id']
township = d_dict['township']
state = districts.state
state_senate_dict = passdict({'chittenden-grand isle': 'grand isle'})

intpat = re.compile(r'^(?P<number>\d+)(?P<extra>\D*)$')
jdpat = re.compile(r'^(?:JD)?(?P<number>\d+)(?P<extra>\D*)$')
sdpat = re.compile(r'^(?:S[DS])?(?P<number>\d+)$')


def numberclean(n):
    m = intpat.match(n)
    if m:
        return str(int(m.groupdict()['number'])) + m.groupdict()['extra']
    else:
        return n


ed_map = {}