diff --git a/src/prompt_funcs.py b/src/prompt_funcs.py index c8ff729..c7831b5 100644 --- a/src/prompt_funcs.py +++ b/src/prompt_funcs.py @@ -161,6 +161,7 @@ def run_top_down(filename, text_dict): return td_final # List of list of dictionaries +# Takes list of dictionaries, updates vals in dictionaries to be lists instead of strings. N/A->empty list, single val -> [single_val], multiple val -> [val1, val2] def clean_td(td): td_clean = [] for d in td: @@ -177,8 +178,9 @@ def clean_td(td): else: new_d[k] = d[k] td_clean.append(new_d) - return td_clean + return td_clean # List of dictionaries where values in each dict are lists +# Takes list of dictionaries, returns one dictionary with unique values def get_unique_td(td): unique_td_dict = {} for d in td: @@ -197,19 +199,19 @@ def td_bu_combine(td, bu, text_dict): td_dicts = td.copy() td_dicts_clean = clean_td(td_dicts) - unique_td = get_unique_td(td_dicts_clean) + unique_td = get_unique_td(td_dicts_clean) # Unique values in entire contract combined_list = [] for bud_ in bu_dicts: bud = bud_.copy() - for key, value in unique_td.items(): + for key, value in unique_td.items(): # value is list of unique values if len(value) == 0: # No value in contract bud.update({key : ""}) elif len(value) == 1: # 1 value in contract bud.update({key : value[0]}) else: # More than one value in contract # Check for value on the page - page_value = [] + page_value = [] # page_value = list of all values of key on the same page as bud for d in td_dicts_clean: if (d['page_num'] == bud['page_num']) and (key in d.keys()): for v in d[key]: @@ -218,11 +220,11 @@ def td_bu_combine(td, bu, text_dict): if len(page_value) == 1: # One value on page bud.update({key : page_value[0]}) elif len(page_value) > 1: # Multiple values on page - bud.update({key : ', '.join(page_value)}) + bud.update({key : ', '.join(page_value)}) # Faizan - Change line to prompt check (pass in page_value) (commit ce3f4c17f281c4c3851d9967c51a14468ee06230) elif len(page_value) == 0: - bud.update({key : ""}) + bud.update({key : ""}) # Faizan - Change line to prompt check previous page (pass in page_value) - (ce3f4c17f281c4c3851d9967c51a14468ee06230) combined_list.append(bud) - return combined_list + return combined_list # List of dictionaries def run_prompts(file_object): diff --git a/src/prompts.py b/src/prompts.py index 2506edd..a465112 100644 --- a/src/prompts.py +++ b/src/prompts.py @@ -144,7 +144,12 @@ def LOB_CHECK(bu_dict, td_dicts, page): Service: {bu_dict['SERVICE']} Methodology: {bu_dict['FULL_METHODOLOGY']} -Listed above is page of a contract, as well as a Service and Methodology found on this page. Your job is to identify which of the following entities this specific Service is associated with. Here are the entities, represented as dictionary objects: +Listed above is page of a contract, as well as a Service and Methodology found on this page. +Your job is to identify which of the following entities this specific Service is associated with. + +----Change Below---- + +Here are the entities, represented as dictionary objects: {td_dicts}