2025-01-10 14:30:35 +08:00
|
|
|
|
import time
|
|
|
|
|
import multiprocessing
|
|
|
|
|
from concurrent.futures import ThreadPoolExecutor, TimeoutError
|
|
|
|
|
from queue import Queue
|
|
|
|
|
from PyPDF2 import PdfReader # 确保已安装 PyPDF2: pip install PyPDF2
|
|
|
|
|
|
|
|
|
|
from flask_app.general.通义千问long import upload_file, qianwen_long
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def judge_zbfile_exec(file_path):
|
|
|
|
|
"""
|
|
|
|
|
判断文件是否属于招标文件,并返回结果。
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
start_time = time.time()
|
|
|
|
|
# 检查文件是否为PDF格式
|
|
|
|
|
if file_path.lower().endswith('.pdf'):
|
|
|
|
|
reader = PdfReader(file_path)
|
|
|
|
|
num_pages = len(reader.pages)
|
|
|
|
|
if num_pages <= 5:
|
|
|
|
|
return False
|
|
|
|
|
# 模拟使用大模型进行判断
|
|
|
|
|
user_query = """该文件是否属于招标文件?如果是的话,请返回'是',如果不是的话,返回'否'。请不要返回其他解释或内容。
|
|
|
|
|
以下是常见的招标文件类型:
|
|
|
|
|
公开招标文件、邀请招标文件、竞争性谈判文件、竞争性磋商文件、询价文件、问询文件、货物类招标文件、工程类招标文件、施工类招标文件、服务类招标文件、比选文件。
|
|
|
|
|
若有未涵盖的类型,但其内容明确表达了项目需求、采购或招标信息,且包含指导投标人参与的关键要素,则可视为招标文件。
|
|
|
|
|
请基于上述内容判断文件是否属于招标文件。
|
|
|
|
|
"""
|
|
|
|
|
file_id = upload_file(file_path)
|
|
|
|
|
model_res = qianwen_long(file_id, user_query)
|
|
|
|
|
end_time = time.time()
|
|
|
|
|
print(f"judge_zbfile_exec实际耗时:{end_time - start_time:.2f} 秒")
|
|
|
|
|
print(f"判断是否属于招标文件:{model_res}")
|
|
|
|
|
|
|
|
|
|
# 根据模型返回结果判断
|
|
|
|
|
if '否' in model_res:
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(f"处理文件时出错: {e}")
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
start_time = time.time()
|
2025-01-10 17:38:55 +08:00
|
|
|
|
pdf_path = r"C:\Users\Administrator\Downloads\商务标null1736476867734.docx"
|
2025-01-10 14:30:35 +08:00
|
|
|
|
res = judge_zbfile_exec(pdf_path)
|
|
|
|
|
if res:
|
|
|
|
|
print("yes")
|
|
|
|
|
else:
|
|
|
|
|
print("no")
|
|
|
|
|
end_time = time.time()
|
|
|
|
|
print(f"整个程序实际耗时:{end_time - start_time:.2f} 秒")
|