10.14货物标解析
This commit is contained in:
parent
93751f7e74
commit
9a2141c3a9
@ -1,3 +1,5 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import mimetypes
|
import mimetypes
|
||||||
|
|
||||||
|
@ -119,7 +119,11 @@ def validate_request(default_zb_type=1):
|
|||||||
zb_type = request.json.get('zb_type', default_zb_type)
|
zb_type = request.json.get('zb_type', default_zb_type)
|
||||||
if not file_url:
|
if not file_url:
|
||||||
return jsonify({'error': 'No file URL provided'}), 400
|
return jsonify({'error': 'No file URL provided'}), 400
|
||||||
return file_url,zb_type
|
try:
|
||||||
|
zb_type = int(zb_type)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
return jsonify({'error': 'Invalid zb_type provided'}), 400
|
||||||
|
return file_url, zb_type
|
||||||
|
|
||||||
# 流式
|
# 流式
|
||||||
@app.route('/upload', methods=['POST'])
|
@app.route('/upload', methods=['POST'])
|
||||||
|
@ -1,2 +1,30 @@
|
|||||||
def combine_basic_info():
|
def combine_basic_info(knowledge_name,output_folder,clause_path):
|
||||||
return True
|
baseinfo_combined_res={
|
||||||
|
"招标人/代理信息": {
|
||||||
|
"招标人": "黄石临空建设管理有限公司",
|
||||||
|
"招标人联系方式": {
|
||||||
|
"名称": "黄石临空建设管理有限公司",
|
||||||
|
"地址": "大冶市还地桥镇",
|
||||||
|
"联系人": "王先生",
|
||||||
|
"电话": "13545510946",
|
||||||
|
"传真": "未知",
|
||||||
|
"电子邮件": "未知",
|
||||||
|
"网址": "未知",
|
||||||
|
"开户银行": "未知",
|
||||||
|
"账号": "未知"
|
||||||
|
},
|
||||||
|
"招标代理机构": "湖北民成工程项目管理有限公司",
|
||||||
|
"招标代理机构联系方式": {
|
||||||
|
"名称": "湖北民成工程项目管理有限公司",
|
||||||
|
"地址": "大冶市港湖还建楼 20栋二单元 102室",
|
||||||
|
"联系人": "尹工",
|
||||||
|
"电话": "18327823905",
|
||||||
|
"传真": "未知",
|
||||||
|
"电子邮件": "未知",
|
||||||
|
"网址": "未知",
|
||||||
|
"开户银行": "未知",
|
||||||
|
"账号": "未知"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {"基础信息":baseinfo_combined_res}
|
@ -356,14 +356,14 @@ def handle_query(file_path, user_query, output_file, result_key, keywords):
|
|||||||
with open(output_file, 'w', encoding='utf-8') as file:
|
with open(output_file, 'w', encoding='utf-8') as file:
|
||||||
counter = 1
|
counter = 1
|
||||||
for content in qianwen_txt:
|
for content in qianwen_txt:
|
||||||
file.write("..............." + '\n')
|
|
||||||
file.write(f"{counter}. {content}\n")
|
file.write(f"{counter}. {content}\n")
|
||||||
|
file.write("..............." + '\n')
|
||||||
counter += 1
|
counter += 1
|
||||||
|
|
||||||
file_id = upload_file(output_file)
|
file_id = upload_file(output_file)
|
||||||
qianwen_ans = qianwen_long(file_id, user_query)
|
qianwen_ans = qianwen_long(file_id, user_query)
|
||||||
num_list = process_string_list(qianwen_ans)
|
num_list = process_string_list(qianwen_ans)
|
||||||
print(num_list)
|
print(result_key+"选中的序号:"+str(num_list))
|
||||||
|
|
||||||
for index in num_list:
|
for index in num_list:
|
||||||
if index - 1 < len(qianwen_txt):
|
if index - 1 < len(qianwen_txt):
|
||||||
@ -423,10 +423,10 @@ if __name__ == '__main__':
|
|||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
# truncate_json_path = "C:\\Users\\Administrator\\Desktop\\货物标\\output4\\tmp2\\竞争性谈判文件(3)_tobidders_notice_part1\\truncate_output.json"
|
# truncate_json_path = "C:\\Users\\Administrator\\Desktop\\货物标\\output4\\tmp2\\竞争性谈判文件(3)_tobidders_notice_part1\\truncate_output.json"
|
||||||
# truncate_file="C:\\Users\\Administrator\\Desktop\\货物标\\output4\\招标文件(实高电子显示屏)_tobidders_notice_part1.docx"
|
# truncate_file="C:\\Users\\Administrator\\Desktop\\货物标\\output4\\招标文件(实高电子显示屏)_tobidders_notice_part1.docx"
|
||||||
clause_path="C:\\Users\\Administrator\\Desktop\\货物标\\output4\\tmp1\\clause招标文件(广水市教育局封闭管理项目二次)_tobidders_notice_part2.json"
|
clause_path="D:\\flask_project\\flask_app\\static\\output\\015d997e-c32c-49d1-a611-a2e817ace6a1\\clause1.json"
|
||||||
output_dir = "C:\\Users\\Administrator\\Desktop\\货物标\\output4\\invalid"
|
output_dir = "D:\\flask_project\\flask_app\\static\\output\\015d997e-c32c-49d1-a611-a2e817ace6a1"
|
||||||
# doc_path = 'C:\\Users\\Administrator\\Desktop\\fsdownload\\temp7\\3abb6e16-19db-42ad-9504-53bf1072dfe7\\ztbfile_invalid.docx'
|
# doc_path = 'C:\\Users\\Administrator\\Desktop\\fsdownload\\temp7\\3abb6e16-19db-42ad-9504-53bf1072dfe7\\ztbfile_invalid.docx'
|
||||||
doc_path = 'C:\\Users\\Administrator\\Desktop\\货物标\\zbfilesdocx\\招标文件(广水市教育局封闭管理项目二次).docx'
|
doc_path = 'D:\\flask_project\\flask_app\\static\\output\\015d997e-c32c-49d1-a611-a2e817ace6a1\\ztbfile.docx'
|
||||||
results = combine_find_invalid(doc_path, output_dir)
|
results = combine_find_invalid(doc_path, output_dir)
|
||||||
end_time = time.time()
|
end_time = time.time()
|
||||||
print("Elapsed time:", str(end_time - start_time))
|
print("Elapsed time:", str(end_time - start_time))
|
@ -26,9 +26,9 @@ def combine_technical_and_business(data, target_values):
|
|||||||
# 默认其他所有内容都归为商务标
|
# 默认其他所有内容都归为商务标
|
||||||
else:
|
else:
|
||||||
if not is_business:
|
if not is_business:
|
||||||
if '商务标' not in extracted_data:
|
if '商务评分' not in extracted_data:
|
||||||
extracted_data['商务标'] = {}
|
extracted_data['商务评分'] = {}
|
||||||
extracted_data['商务标'][key] = value
|
extracted_data['商务评分'][key] = value
|
||||||
business_found = True
|
business_found = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -42,9 +42,9 @@ def combine_technical_and_business(data, target_values):
|
|||||||
extract_nested(data)
|
extract_nested(data)
|
||||||
|
|
||||||
if not technical_found:
|
if not technical_found:
|
||||||
extracted_data['技术标'] = ''
|
extracted_data['技术评分'] = ''
|
||||||
if not business_found:
|
if not business_found:
|
||||||
extracted_data['商务标'] = ''
|
extracted_data['商务评分'] = ''
|
||||||
|
|
||||||
return extracted_data
|
return extracted_data
|
||||||
|
|
||||||
@ -165,7 +165,8 @@ def combine_evaluation_standards(truncate_file):
|
|||||||
"主要监理岗位的职责": {
|
"主要监理岗位的职责": {
|
||||||
"评分": "4分",
|
"评分": "4分",
|
||||||
"要求": "1、总监理工程师的职责全面、清晰、合理得 1.2-2分;一般的1.2分。2、其他主要监理人员及岗位的职责全面、清晰、合理得 1.2-2分;一般的 1.2分。"
|
"要求": "1、总监理工程师的职责全面、清晰、合理得 1.2-2分;一般的1.2分。2、其他主要监理人员及岗位的职责全面、清晰、合理得 1.2-2分;一般的 1.2分。"
|
||||||
}
|
},
|
||||||
|
"备注": "注:若不满足“与公安部、省公安厅、随州市公安局高清视频会议系统无缝对接互联互通”的要求,则本项技术部分(50分)不得分。"
|
||||||
},
|
},
|
||||||
"商务评分": {
|
"商务评分": {
|
||||||
"控制系统内主板": {
|
"控制系统内主板": {
|
||||||
@ -215,8 +216,8 @@ def combine_evaluation_standards(truncate_file):
|
|||||||
else:
|
else:
|
||||||
# 如果 judge 是 False,直接返回默认的技术标和商务标的结构
|
# 如果 judge 是 False,直接返回默认的技术标和商务标的结构
|
||||||
result_data = {}
|
result_data = {}
|
||||||
result_data['技术标'] = ''
|
result_data['技术评分'] = ''
|
||||||
result_data['商务标'] = ''
|
result_data['商务评分'] = ''
|
||||||
return result_data
|
return result_data
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#竞磋 竞谈 磋商 询价 邀请 单一来源
|
#竞磋 竞谈 磋商 询价 邀请 单一来源
|
||||||
import json
|
import json
|
||||||
|
import time
|
||||||
|
|
||||||
from flask_app.main.format_change import docx2pdf, pdf2docx
|
from flask_app.main.format_change import docx2pdf, pdf2docx
|
||||||
from flask_app.main.json_utils import transform_json_values
|
from flask_app.main.json_utils import transform_json_values
|
||||||
@ -10,7 +11,7 @@ from concurrent.futures import ThreadPoolExecutor
|
|||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
from flask_app.main.知识库操作 import addfileToKnowledge, deleteKnowledge
|
from flask_app.main.知识库操作 import addfileToKnowledge, deleteKnowledge
|
||||||
from flask_app.货物标.投标人须知正文条款提取成json文件货物标版 import convert_clause_to_json
|
from flask_app.货物标.投标人须知正文条款提取成json文件货物标版 import convert_clause_to_json
|
||||||
from flask_app.货物标.无效标和废标和禁止投标整合货物标版 import combine_find_invalid
|
from flask_app.货物标.无效标和废标和禁止投标整合main import combine_find_invalid
|
||||||
from flask_app.货物标.资格审查main import combine_qualification_review
|
from flask_app.货物标.资格审查main import combine_qualification_review
|
||||||
from flask_app.货物标.评分标准提取main import combine_evaluation_standards
|
from flask_app.货物标.评分标准提取main import combine_evaluation_standards
|
||||||
import logging
|
import logging
|
||||||
@ -67,9 +68,9 @@ def preprocess_files(output_folder, file_path, file_type, unique_id):
|
|||||||
'clause_path': clause_path,
|
'clause_path': clause_path,
|
||||||
'invalid_docpath': invalid_docpath
|
'invalid_docpath': invalid_docpath
|
||||||
}
|
}
|
||||||
def fetch_project_basic_info(knowledge_name, truncate0, output_folder, clause_path): # 投标人须知前附表
|
def fetch_project_basic_info(knowledge_name, output_folder, clause_path): # 投标人须知前附表
|
||||||
logger.info("starting基础信息...")
|
logger.info("starting基础信息...")
|
||||||
basic_res = combine_basic_info()
|
basic_res = combine_basic_info(knowledge_name,output_folder,clause_path)
|
||||||
logger.info("基础信息done")
|
logger.info("基础信息done")
|
||||||
return basic_res
|
return basic_res
|
||||||
|
|
||||||
@ -160,7 +161,7 @@ def goods_bid_main(output_folder,file_path, file_type, unique_id):
|
|||||||
|
|
||||||
# 提交依赖 knowledge_name 和 index 的任务
|
# 提交依赖 knowledge_name 和 index 的任务
|
||||||
future_dependencies = {
|
future_dependencies = {
|
||||||
'base_info': executor.submit(fetch_project_basic_info, knowledge_name, processed_data['truncate0'],
|
'base_info': executor.submit(fetch_project_basic_info, knowledge_name,
|
||||||
output_folder, processed_data['clause_path']),
|
output_folder, processed_data['clause_path']),
|
||||||
'qualification_review': executor.submit(fetch_qualification_review,output_folder, processed_data['qualification_path'],processed_data['notice_path'],knowledge_name),
|
'qualification_review': executor.submit(fetch_qualification_review,output_folder, processed_data['qualification_path'],processed_data['notice_path'],knowledge_name),
|
||||||
}
|
}
|
||||||
@ -179,4 +180,15 @@ def goods_bid_main(output_folder,file_path, file_type, unique_id):
|
|||||||
yield json.dumps({'error': f'Knowledge upload failed: {str(e)}'}, ensure_ascii=False)
|
yield json.dumps({'error': f'Knowledge upload failed: {str(e)}'}, ensure_ascii=False)
|
||||||
|
|
||||||
# 删除知识索引
|
# 删除知识索引
|
||||||
deleteKnowledge(index)
|
deleteKnowledge(index)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
output_folder = "flask_app/static/output/zytest1"
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
|
file_type = 1 #1:docx 2:pdf 3:其他
|
||||||
|
input_file = "C:\\Users\\Administrator\\Desktop\\货物标\\zbfiles\\6.2定版视频会议磋商文件.pdf"
|
||||||
|
goods_bid_main(output_folder, input_file, file_type, "uuidzyzy11")
|
||||||
|
end_time = time.time()
|
||||||
|
elapsed_time = end_time - start_time # 计算耗时
|
||||||
|
print(f"Function execution took {elapsed_time} seconds.")
|
@ -319,40 +319,44 @@ def process_match_keys(match_keys, clause_path_file):
|
|||||||
|
|
||||||
|
|
||||||
#处理如'符合本采购文件第一章第二款要求'的情况,跳转到指定地方摘取内容
|
#处理如'符合本采购文件第一章第二款要求'的情况,跳转到指定地方摘取内容
|
||||||
def process_additional_queries(combined_res, match_keys,output_folder, notice_path,knowledge_name):
|
def process_additional_queries(combined_res, match_keys, output_folder, notice_path, knowledge_name):
|
||||||
"""
|
"""
|
||||||
处理额外的查询并更新结果。
|
处理额外的查询并更新结果。
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
combined_res: 初始的组合结果。
|
combined_res: 初始的组合结果。
|
||||||
match_keys: 匹配的章节或条款引用。 [{'资格性审查.资格要求': '符合本采购文件第一章第二款要求,并提供合格有效的证明材料。'}]
|
match_keys: 匹配的章节或条款引用。 [{'资格性审查.资格要求': '符合本采购文件第一章第二款要求,并提供合格有效的证明材料。'}]
|
||||||
|
output_folder: 输出文件夹路径。
|
||||||
|
notice_path: 通知文件路径。
|
||||||
knowledge_name: 知识库的名称。
|
knowledge_name: 知识库的名称。
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict: 更新后的最终结果。
|
dict: 更新后的最终结果。
|
||||||
"""
|
"""
|
||||||
clause2_path=convert_clause_to_json(notice_path,output_folder,2)
|
clause2_path = convert_clause_to_json(notice_path, output_folder, 2)
|
||||||
# 处理match_keys,匹配并附加条款内容
|
|
||||||
original_keys = copy.deepcopy(match_keys)
|
|
||||||
updated_match_keys = process_match_keys(match_keys, clause2_path)
|
updated_match_keys = process_match_keys(match_keys, clause2_path)
|
||||||
#正则匹配到指定内容后就直接返回
|
|
||||||
if updated_match_keys != original_keys:
|
|
||||||
return update_json_data(combined_res, updated_match_keys)
|
|
||||||
# 生成进一步的问题
|
|
||||||
ques = generate_questions(original_keys)
|
|
||||||
results = multi_threading(ques, knowledge_name)
|
|
||||||
|
|
||||||
for _, response in results:
|
if updated_match_keys != match_keys:
|
||||||
if response and len(response) > 1:
|
form_response_dict = update_json_data(combined_res, updated_match_keys)
|
||||||
try:
|
else:
|
||||||
temp = extract_content_from_json(response[1])
|
ques = generate_questions(match_keys)
|
||||||
updated_match_keys.append(temp)
|
results = multi_threading(ques, knowledge_name)
|
||||||
except Exception as e:
|
|
||||||
print(f"形式响应评审:Error processing response: {e}")
|
|
||||||
else:
|
|
||||||
print(f"形式响应评审:Warning: Missing or incomplete response data.")
|
|
||||||
|
|
||||||
return update_json_data(combined_res, updated_match_keys)
|
for _, response in results:
|
||||||
|
if response and len(response) > 1:
|
||||||
|
try:
|
||||||
|
temp = extract_content_from_json(response[1])
|
||||||
|
updated_match_keys.append(temp)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"形式响应评审:Error processing response: {e}")
|
||||||
|
else:
|
||||||
|
print(f"形式响应评审:Warning: Missing or incomplete response data.")
|
||||||
|
|
||||||
|
form_response_dict = update_json_data(combined_res, updated_match_keys)
|
||||||
|
|
||||||
|
# 添加额外的处理步骤
|
||||||
|
final_result = {"资格审查": form_response_dict}
|
||||||
|
return final_result
|
||||||
|
|
||||||
|
|
||||||
def combine_qualification_review(output_folder,qualification_path, notice_path,knowledge_name):
|
def combine_qualification_review(output_folder,qualification_path, notice_path,knowledge_name):
|
||||||
@ -391,7 +395,7 @@ def combine_qualification_review(output_folder,qualification_path, notice_path,k
|
|||||||
|
|
||||||
# 如果没有匹配的章节或条款,直接返回 combined_res
|
# 如果没有匹配的章节或条款,直接返回 combined_res
|
||||||
if not match_keys:
|
if not match_keys:
|
||||||
return combined_res
|
return {"资格审查":combined_res}
|
||||||
# 调用新的函数处理后续逻辑
|
# 调用新的函数处理后续逻辑
|
||||||
return process_additional_queries(combined_res, match_keys, output_folder,notice_path,knowledge_name)
|
return process_additional_queries(combined_res, match_keys, output_folder,notice_path,knowledge_name)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user