diff --git a/.idea/encodings.xml b/.idea/encodings.xml index dce1f12..5eac8bc 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -4,6 +4,8 @@ + + diff --git a/flask_app/main/table_content_extraction.py b/flask_app/main/table_content_extraction.py index 82dfe48..75af5d0 100644 --- a/flask_app/main/table_content_extraction.py +++ b/flask_app/main/table_content_extraction.py @@ -107,6 +107,6 @@ def extract_tables_main(path, output_folder): if __name__ == "__main__": - path = '' - output_filename = "C:\\Users\\Administrator\\Desktop\\招标文件\\招标test文件夹\\zbtest20\\truncate_output.json" # 前附表json文件 - extract_tables_main(path, output_filename) + path = 'C:\\Users\\Administrator\\Desktop\\招标文件\\招标test文件夹\\tmp\\ztbfile_tobidders_notice_table.docx' + output_folder = "C:\\Users\\Administrator\\Desktop\\招标文件\\招标test文件夹\\tmp" # 前附表json文件 + extract_tables_main(path, output_folder) diff --git a/flask_app/main/商务标技术标整合.py b/flask_app/main/商务标技术标整合.py index c979c66..3dd8439 100644 --- a/flask_app/main/商务标技术标整合.py +++ b/flask_app/main/商务标技术标整合.py @@ -105,10 +105,10 @@ def combine_evaluation_standards(truncate2): # target_values2=['投标报价','商务标','商务部分','报价部分','业绩','信誉','分值','计算公式','信用','人员','资格','奖项','认证','荣誉'] # update_json=combine_technical_and_business(clean_json_string(evaluation_res),target_values1,target_values2) update_json = combine_technical_and_business(clean_json_string(evaluation_res), target_values1) - evaluation_combined_res = json.dumps(update_json,ensure_ascii=False,indent=4) + # evaluation_combined_res = json.dumps(update_json,ensure_ascii=False,indent=4) # return evaluation_combined_res return update_json #商务标技术标整合 if __name__ == "__main__": - truncate2="C:\\Users\\Administrator\\Desktop\\招标文件\\招标test文件夹\\zbtest20_evaluation_method.pdf" + truncate2="D:\\flask_project\\flask_app\\static\\output\\c02a12c2-6f7b-49dc-b97f-c3d740c96c21\\ztbfile_evaluation_method.pdf" res=combine_evaluation_standards(truncate2) - print(res) \ No newline at end of file + print(json.dumps(res,ensure_ascii=False,indent=4)) \ No newline at end of file diff --git a/flask_app/main/截取pdf.py b/flask_app/main/截取pdf.py index 56dc3e7..dcf4fa8 100644 --- a/flask_app/main/截取pdf.py +++ b/flask_app/main/截取pdf.py @@ -265,8 +265,8 @@ def truncate_pdf_multiple(input_path, output_folder): if __name__ == "__main__": # input_path = "C:\\Users\\Administrator\\Desktop\\fsdownload\\4bda9fde-89fc-4e5e-94a4-ce6c43010f74\\ztbfile.pdf" # output_folder = "C:\\Users\\Administrator\\Desktop\\fsdownload\\4bda9fde-89fc-4e5e-94a4-ce6c43010f74" - input_path="C:\\Users\\Administrator\\Desktop\\招标文件\\招标test文件夹\\zbtest2.pdf" - output_folder="C:\\Users\\Administrator\\Desktop\\招标文件\\招标test文件夹" + input_path="D:\\flask_project\\flask_app\\static\\output\\c02a12c2-6f7b-49dc-b97f-c3d740c96c21\\ztbfile.pdf" + output_folder="C:\\Users\\Administrator\\Desktop\\招标文件\\招标test文件夹\\tmp" truncate_pdf_multiple(input_path,output_folder) # selection = 3 # 例如:1 - 投标人须知前附表, 2 - 评标办法, 3 - 投标人须知正文 4-资格审查条件 5-招标公告 6-无效标 # generated_files = truncate_pdf_main(input_path, output_folder, selection) diff --git a/flask_app/main/根据条款号整合json.py b/flask_app/main/根据条款号整合json.py index b99d671..e1d8224 100644 --- a/flask_app/main/根据条款号整合json.py +++ b/flask_app/main/根据条款号整合json.py @@ -83,10 +83,10 @@ def extract_content_after_special_chars(content): def get_values_only(content): if isinstance(content, dict): - # 如果内容是字典,首先将字典的值转换为字符串 - content = " / ".join(content.values()) - # 检查并处理特殊字符 + # 递归处理字典中的每个值,并确保转换为字符串后再连接 + content = " / ".join(get_values_only(value) for value in content.values()) return extract_content_after_special_chars(content) + def standardize_brackets(value): """ 将输入中的所有半角括号转换为全角括号。 @@ -145,9 +145,11 @@ def process_and_merge2(entries_with_numbers,json_path): if __name__ == "__main__": # Hypothetical entries and file paths for testing # entries_with_numbers = [{'形式评审标准.投标文件签字盖章': '3.7.3(3)'}, {'形式评审标准.多标段投标': '10.1'}, {'形式评审标准.“技术暗标”': '3.7.4(5)'}, {'响应性评审标准.投标内容': '1.3.1'}, {'响应性评审标准.工期': '1.3.2'}, {'响应性评审标准.工程质量': '1.3.3'}, {'响应性评审标准.投标有效期': '3.3.1'}, {'响应性评审标准.投标保证金': '3.4.1'}, {'响应性评审标准.分包计划': '1.11'}] - entries_with_numbers=[{'xxx': '4.2.3'}] - primary_json_path = 'C:\\Users\\Administrator\\Desktop\\招标文件\\招标test文件夹\\truncate_output.json' - secondary_json_path = 'C:\\Users\\Administrator\\Desktop\\招标文件\\招标test文件夹\\clause.json' + # entries_with_numbers=[{'xxx': '3.7.3(3)'},{'xxssx': '10.1'},{'xsssxx': '3.7.4(5)'},{'a': '1.3.1'},{'b': '1.3.2'},{'c': '1.3.3'},{'d': '3.3.1'}] + entries_with_numbers = [ {'xxssx': '1.3.1'} + ] + primary_json_path = 'D:\\flask_project\\flask_app\\static\\output\\c02a12c2-6f7b-49dc-b97f-c3d740c96c21\\truncate_output.json' + secondary_json_path = 'D:\\flask_project\\flask_app\\static\\output\\c02a12c2-6f7b-49dc-b97f-c3d740c96c21\\clause1.json' # Since this is just a test block, make sure these paths point to actual JSON files with the appropriate structure try: diff --git a/flask_app/main/资格审查模块.py b/flask_app/main/资格审查模块.py index 53f801c..9eabdce 100644 --- a/flask_app/main/资格审查模块.py +++ b/flask_app/main/资格审查模块.py @@ -29,8 +29,8 @@ def combine_review_standards(truncate1,truncate3,knowledge_name,truncate0_jsonpa if __name__ == "__main__": - input_file="C:\\Users\\Administrator\\Desktop\\fsdownload\\4a611a66-0dac-4daf-b365-c6167c5b8c8d\\ztbfile.pdf" - output_folder = "C:\\Users\\Administrator\\Desktop\\fsdownload\\4a611a66-0dac-4daf-b365-c6167c5b8c8d" + input_file="D:\\flask_project\\flask_app\\static\\output\\c02a12c2-6f7b-49dc-b97f-c3d740c96c21\\ztbfile.pdf" + output_folder = "D:\\flask_project\\flask_app\\static\\output\\c02a12c2-6f7b-49dc-b97f-c3d740c96c21" # truncate0 = os.path.join(output_folder, "zbtest20_tobidders_notice_table.pdf") truncate2=os.path.join(output_folder,"ztbfile_tobidders_notice.pdf") knowledge_name="zbtest20" diff --git a/flask_app/货物标/提示词/prompt1.txt b/flask_app/货物标/提示词/prompt1.txt index da69670..ad1f4fa 100644 --- a/flask_app/货物标/提示词/prompt1.txt +++ b/flask_app/货物标/提示词/prompt1.txt @@ -14,6 +14,7 @@ "该招标文件中规定的资格性审查标准是怎样的?请以json格式给出,外层为'资格性审查',对于原文中的序号,你需要捕获它们之间的层级关系并生成嵌套键值对,你的回答无需包含序号,但其余内容要与原文一致,不可擅自总结删减,也不要回答符合性审查的内容。" +"该招标文件中规定的资格性审查标准是怎样的?请以json格式给出,外层为'资格性审查',对于原文中的序号,你仅需要捕获它们之间的层级关系并根据序号后的内容生成嵌套键值对,若多个内容位于同一层级,你应用字符串列表作为键值保存这些内容,你的回答需删去这些序号,但其余内容要与原文一致,不可擅自总结删减,也不要回答符合性审查的内容。" "根据该文档中的评标办法前附表,请你列出该文件的技术标,商务标,投标报价评审标准以及它们对应的具体评分要求,若对应内容中存在其他信息,在键名如'技术标'中新增子键名'备注'存放该信息。如果评分内容不是这3个,则返回文档中给定的评分内容以及它的评分要求,都以json的格式返回结果。请不要回答有关形式、资格、响应性评审标准的内容") diff --git a/flask_app/货物标/资格审查main.py b/flask_app/货物标/资格审查main.py index 6fafa57..2bb488c 100644 --- a/flask_app/货物标/资格审查main.py +++ b/flask_app/货物标/资格审查main.py @@ -68,29 +68,39 @@ def process_dict(data): else: non_numeric_keys[key] = value - # 处理数字键,不再要求数量>1 if numeric_keys: result['items'] = [process_dict(item[1]) for item in sorted(numeric_keys)] - # 处理非数字键 for key, value in non_numeric_keys.items(): - if isinstance(value, list) and len(value) > 1 and all(isinstance(item, dict) and len(item) == 1 for item in value): - common_key = next(iter(value[0].keys())) - if all(common_key in item and len(item) == 1 for item in value): - result[key] = [process_dict(item[common_key]) for item in value] - else: - result[key] = [process_dict(item) for item in value] + if isinstance(value, list): + processed_list = [] + for item in value: + if isinstance(item, dict): + # 处理字典中只有一个键值对的情况 + if len(item) == 1: + processed_item = process_dict(list(item.values())[0]) + else: + processed_item = process_dict(item) + else: + processed_item = process_dict(item) + + # 如果处理后的项是只包含一个元素的列表,则展平它 + if isinstance(processed_item, list) and len(processed_item) == 1: + processed_item = processed_item[0] + + processed_list.append(processed_item) + + result[key] = processed_list else: result[key] = process_dict(value) - # 如果结果只包含'items'键,直接返回其值 if len(result) == 1 and 'items' in result: return result['items'] return result def qualification_review(truncate_file): file_id=upload_file(truncate_file) - user_query=["该招标文件中规定的资格性审查标准是怎样的?请以json格式给出,外层为'资格性审查',对于原文中的序号,你仅需要捕获它们之间的层级关系并根据序号后的内容生成嵌套键值对,若多个内容位于同一层级,你应用字符串列表作为键值保存这些内容,你的回答需删去这些序号,但其余内容要与原文一致,不可擅自总结删减,也不要回答符合性审查的内容。","该招标文件中规定的符合性审查标准是怎样的?请以json格式给出,外层为'符合性审查',你的回答要与原文一致,不可擅自总结删减,也不要回答资格性审查的内容。"] + user_query=["该招标文件中规定的资格性审查标准是怎样的?请以json格式给出,外层为'资格性审查',你的回答要与原文一致,不可擅自总结删减,也不要回答资格性审查的内容。","该招标文件中规定的符合性审查标准是怎样的?请以json格式给出,外层为'符合性审查',你的回答要与原文一致,不可擅自总结删减,也不要回答资格性审查的内容。"] results=multi_threading(user_query,"",file_id,2) combined_res = {} for question, response in results: