consolidation updates
This commit is contained in:
committed by
Michael McGuinness
parent
3b7f56110d
commit
2e8804ccd5
+1
-30
@@ -3,7 +3,7 @@ import os
|
||||
import shutil
|
||||
import pandas as pd
|
||||
from collections import defaultdict
|
||||
import concurrent.futures
|
||||
|
||||
|
||||
import config
|
||||
import utils
|
||||
@@ -51,17 +51,7 @@ def run_bottom_up_primary(text_dict, tokens):
|
||||
answer_dict[page_number] = answer
|
||||
return answer_dict
|
||||
|
||||
def run_lesser_of_prompt(text_dict, result_dicts):
|
||||
|
||||
valid_dicts = [dict for dict in result_dicts if dict['LESSER_OF_LANGUAGE_IND'] == 'Y']
|
||||
pages_to_check = list(set([dict['page_num'] for dict in valid_dicts]))
|
||||
for page_num in pages_to_check:
|
||||
page_text = text_dict[page_num]
|
||||
dicts_on_page = [dict for dict in valid_dicts if dict['page_num'] == page_num]
|
||||
print(dicts_on_page)
|
||||
|
||||
def append_secondary(result_dicts):
|
||||
|
||||
# Helper function to create a key from dict excluding certain keys
|
||||
def create_key(d):
|
||||
return tuple((k, d[k]) for k in d if not k.startswith('REIMBURSEMENT'))
|
||||
@@ -112,22 +102,3 @@ def bottom_up_primary(file_object):
|
||||
if not os.path.exists('temp'):
|
||||
os.makedirs('temp')
|
||||
answer_df.to_csv(f"temp/{filename}_results.csv")
|
||||
|
||||
|
||||
def run_bottom_up(input_dict):
|
||||
|
||||
if not os.path.exists('results'):
|
||||
os.makedirs('results')
|
||||
|
||||
# Run prompts with multithreading
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=config.MAX_WORKERS) as executor:
|
||||
executor.map(bottom_up_primary, input_dict.items())
|
||||
|
||||
# Output
|
||||
if config.OUTPUT_MODE == '_CONSOLIDATED_':
|
||||
consolidated_df = utils.consolidate_individual() # Consolidate temp results to one file
|
||||
utils.write_consolidated(consolidated_df)
|
||||
consolidated_df.to_csv(os.path.join('results', f'consolidated_results_{config.TODAY}.csv')) # Write output
|
||||
|
||||
|
||||
|
||||
|
||||
+14
-1
@@ -1,4 +1,6 @@
|
||||
# Imports
|
||||
import os
|
||||
import concurrent.futures
|
||||
|
||||
import utils
|
||||
import config
|
||||
@@ -6,9 +8,20 @@ import bottom_up_funcs
|
||||
|
||||
|
||||
def main():
|
||||
# Read contract txt
|
||||
input_dict = utils.read_input()
|
||||
|
||||
# Set up results folder
|
||||
if not os.path.exists('results'):
|
||||
os.makedirs('results')
|
||||
|
||||
# Run bottom up primary with multithreading
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=config.MAX_WORKERS) as executor:
|
||||
executor.map(bottom_up_funcs.bottom_up_primary, input_dict.items())
|
||||
|
||||
bottom_up_funcs.run_bottom_up(input_dict)
|
||||
# Write Output
|
||||
if config.OUTPUT_MODE == '_CONSOLIDATED_':
|
||||
consolidated_df = utils.consolidate_individual() # Consolidate temp results to one file, then write output
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user