def extract_contract(block): block_as_str = block['string'] # extract the contract number contracts = [] contract_pattern = r'Contract No\. (\d{4}\d+)' contract_pattern = re.compile(contract_pattern) for m in contract_pattern.findall(block['string']): contracts.append(m) block['contracts'] = contracts # extract the addresses block['address'] = find_address(block) #extract the dollar amounts dollar_ammounts = [] for m in helpers.MONEY_PATTERN.findall(block['string']): m = m.replace('$','') m = m.replace(',','') m = float(m) dollar_ammounts.append(m) # If there are more than two dollar amounts, this probably is # being sent off to committee. if len(dollar_ammounts) > 2: block['type'] = 'to committee' # TODO -- parse out what committee. elif len(dollar_ammounts) == 2: # If there are two dollar amounts, it needs human intervention # to know what's up. It could be two contracts for referral, or # an ammended contract. block['type'] = 'contract' block['address'] = find_address(block) block['cost'] = dollar_ammounts[1] # it's probably the second. block = extract_votes(block) block['review'] = True elif len(dollar_ammounts) == 1: # One ammount almost certainly means its a contract. block['type'] = 'contract' block['address'] = find_address(block) block['cost'] = dollar_ammounts[0] block = extract_votes(block) else: # Hm, not sure what it could be. block['type'] = 'unknown' block['review'] = 'True' #if ('BEING REFERRED' in block_as_str) or ('TO BE REFERRED' in block_as_str) or ('WERE REFERRED' in block_as_str): # block['type'] = 'referral' block['dollar_ammounts'] = dollar_ammounts return block
def extract_planning(block): start = block['string'].find('Re: ') ends = ['The City of Detroit acquired as ', 'The above named'] for string in ends: end = block['string'].find(string) if start != -1 and end != -1: subject = block['string'][start:end] block['details'] = subject # Petition No. 3212 petitions = re.search('Petition No. (\d+)', block['string']) try: block['petition'] = int(petitions.group(0)) except: pass block = extract_votes(block) return block
def buildings_and_safety(block): ''' Re: Address: 4400 Bewick. Re: Dangerous Buildings. Re: Address: 9324-6 W. Fort ''' for line in block['lines']: if 'Re: ' in line: continue if 'Re: Address' in line: for direction in helpers.DIRECTIONS: # strip the periods from directions line = line.replace(direction + '.', direction) block['address'] = line.split('.')[0] if 'Re: Dangerous Buildings' in line: block['type'] = 'dangerous buildings' block = extract_votes(block) return block
from helpers import extract_votes, name_cleanup text = 'President Pro Tem Conyers, Pro-Tem Watson' text = name_cleanup(text) if text.find('Pro Tem') != -1: assert(False) if text.find('President') != -1: assert(False) print "Name cleanup passed" block1 = {} block1['string'] = 'Finance Department Purchasing Division September 16, 2009 Honorable City Council: The Purchasing Division of the Finance Department recommends a Contract with the following firm(s) or person(s): 2797973 -- 100% City Funding -- To provide Belle Isle - Scott Fountain Renova- tions -- Grunwell-Cashero Co., 1041 Major, Detroit, MI 48217 -- Contract Period: Upon Notice to Proceed -- Until Completion of the Project -- Contract Amount Not to Exceed: $300,000.00. Recreation. (Contract held by Council Member Sheila M. Cockrel during recess week of August 10, 2009) Respectfully submitted, CHRISTINA LADSON Interim Director Finance Dept./Purchasing Div. By Council Member Watson: Resolved, That Contract No. 2797973 referred to in the foregoing communica- tion, dated July 30, 2009, be hereby and is approved. Adopted as follows: Yeas -- Council Members S. Cockrel, Collins, Jones, Kenyatta, Reeves, Tinsley-Talabi, Watson, and President K. Cockrel, Jr. -- 8. Nays -- None. *WAIVER OF RECONSIDERATION (No. 36), per motions before adjournment.' block = extract_votes(block1) yeas = ['S. Cockrel', 'Collins', 'Jones', 'Kenyatta', 'Reeves', 'Tinsley-Talabi', 'Watson', 'K. Cockrel, Jr.'] nays = [] if block['nays'] != nays: assert(False) for person in block['yeas']: if person not in yeas: assert(False) print "No nays passed" block2 = {} block2['string'] = 'Finance Department Purchasing Division September 16, 2009 Honorable City Council: The Purchasing Division of the Finance Department recommends a Contract with the following firm(s) or person(s): 2797973 -- 100% City Funding -- To provide Belle Isle - Scott Fountain Renova- tions -- Grunwell-Cashero Co., 1041 Major, Detroit, MI 48217 -- Contract Period: Upon Notice to Proceed -- Until Completion of the Project -- Contract Amount Not to Exceed: $300,000.00. Recreation. (Contract held by Council Member Sheila M. Cockrel during recess week of August 10, 2009) Respectfully submitted, CHRISTINA LADSON Interim Director Finance Dept./Purchasing Div. By Council Member Watson: Resolved, That Contract No. 2797973 referred to in the foregoing communica- tion, dated July 30, 2009, be hereby and is approved. Adopted as follows: Yeas -- Council Members S. Cockrel, and Collins -- 2. Nays -- Council Members Jones, Kenyatta, Reeves, Tinsley-Talabi, Watson, and President K. Cockrel, Jr. -- 8. *WAIVER OF RECONSIDERATION (No. 36), per motions before adjournment.' block = extract_votes(block2)