def run_fec_query(name, state=None, office=None, cycle=None, fuzzy=True):
    if debug:
        print "run_fec_query = state=%s office=%s cycle=%s" % (state,office, cycle)
        
    result = hash_lookup(name, state, office, cycle)
    if result:
        return result
    if not fuzzy:
        return []
    
    # don't even bother if there are less than 4 letters 
    if (len(name) < 4):
        return []
    
    result_array = match_by_name(name, state=state, office=office, cycle=cycle, reverse_name_order=False)
    
    # If there are no matches, maybe the name got flipped? 
    if CHECK_FOR_NAME_REVERSALS and len(result_array)==0:
        result_array = match_by_name(name, state=state, office=office, cycle=cycle, reverse_name_order=True)
    
    result_array = sorted(result_array, key=itemgetter('score'), reverse=True)
    return result_array
dataset/ETHPy150Open sunlightlabs/read_FEC/fecreader/reconciliation/fec_reconciler.py/run_fec_query/original