1.24 废标项
This commit is contained in:
parent
9117c4117b
commit
39069d18c2
@ -254,6 +254,7 @@ def extract_text_with_keywords(processed_paragraphs, keywords, follow_up_keyword
|
|||||||
# 新增的条件:检查是否匹配 pattern_numbered 或 pattern_parentheses
|
# 新增的条件:检查是否匹配 pattern_numbered 或 pattern_parentheses
|
||||||
pattern_numbered = re.compile(r'^\s*([一二三四五六七八九十]{1,2})\s*、\s*')
|
pattern_numbered = re.compile(r'^\s*([一二三四五六七八九十]{1,2})\s*、\s*')
|
||||||
pattern_parentheses = re.compile(r'^\s*[((]\s*([一二三四五六七八九十]{1,2})\s*[))]\s*')
|
pattern_parentheses = re.compile(r'^\s*[((]\s*([一二三四五六七八九十]{1,2})\s*[))]\s*')
|
||||||
|
pattern_letter_initial = re.compile(r'^([A-Z])\s*[..、]?\s*(.*)$')
|
||||||
def match_keywords(text, patterns):
|
def match_keywords(text, patterns):
|
||||||
# 首先检查关键词是否匹配
|
# 首先检查关键词是否匹配
|
||||||
for pattern in patterns:
|
for pattern in patterns:
|
||||||
@ -287,22 +288,33 @@ def extract_text_with_keywords(processed_paragraphs, keywords, follow_up_keyword
|
|||||||
if not found_next_number:
|
if not found_next_number:
|
||||||
# Modify the regular expression to support the required format
|
# Modify the regular expression to support the required format
|
||||||
number_pattern = (
|
number_pattern = (
|
||||||
r'^([A-Za-z0-9]+(?:[..][A-Za-z0-9]+)*)|'
|
r'^([A-Za-z]+(?:[..][A-Za-z]+)*)|' # 仅字母模式
|
||||||
r'([((]\s*(?:[一二三四五六七八九十]{1,2}|\d+)\s*[))])|'
|
r'^([0-9]+(?:[..][0-9]+)*)|' # 仅数字模式
|
||||||
r'((?:[一二三四五六七八九十]{1,2}|\d+)\s*、)'
|
r'([((]\s*(?:[一二三四五六七八九十]{1,2}|\d+)\s*[))])|' # 括号内的中文数字或阿拉伯数字
|
||||||
|
r'((?:[一二三四五六七八九十]{1,2}|\d+)\s*、)' # 中文数字或阿拉伯数字加顿号
|
||||||
)
|
)
|
||||||
next_section_number = re.match(number_pattern, next_text)
|
next_section_number = re.match(number_pattern, next_text)
|
||||||
|
|
||||||
if next_section_number:
|
if next_section_number:
|
||||||
found_next_number = True
|
found_next_number = True
|
||||||
# Determine dynamic pattern based on section number format
|
|
||||||
if next_section_number.group(1):
|
if next_section_number.group(1):
|
||||||
|
# 仅字母模式
|
||||||
section_parts = next_section_number.group(1).split('.')
|
section_parts = next_section_number.group(1).split('.')
|
||||||
dynamic_pattern = r'^' + r'[..]'.join([r'[A-Za-z0-9]+' for _ in section_parts]) + r'\b'
|
dynamic_pattern = r'^' + r'[A-Za-z]+' + r'(?:[..][A-Za-z]+)*' + r'\b'
|
||||||
elif next_section_number.group(2):
|
elif next_section_number.group(2):
|
||||||
dynamic_pattern = r'^[\(\(]\s*(?:[一二三四五六七八九十]{1,2}|\d+)\s*[\)\)]'
|
# 仅数字模式
|
||||||
|
section_parts = next_section_number.group(2).split('.')
|
||||||
|
dynamic_pattern = r'^' + r'[0-9]+' + r'(?:[..][0-9]+)*' + r'\b'
|
||||||
elif next_section_number.group(3):
|
elif next_section_number.group(3):
|
||||||
|
# 括号内的中文数字或阿拉伯数字
|
||||||
|
dynamic_pattern = r'^[((]\s*(?:[一二三四五六七八九十]{1,2}|\d+)\s*[))]'
|
||||||
|
elif next_section_number.group(4):
|
||||||
|
# 中文数字或阿拉伯数字加顿号
|
||||||
dynamic_pattern = r'^(?:[一二三四五六七八九十]{1,2}|\d+)\s*、'
|
dynamic_pattern = r'^(?:[一二三四五六七八九十]{1,2}|\d+)\s*、'
|
||||||
|
else:
|
||||||
|
dynamic_pattern = None
|
||||||
|
|
||||||
|
if dynamic_pattern:
|
||||||
current_section_pattern = re.compile(dynamic_pattern)
|
current_section_pattern = re.compile(dynamic_pattern)
|
||||||
|
|
||||||
if current_section_pattern and re.match(current_section_pattern, next_text):
|
if current_section_pattern and re.match(current_section_pattern, next_text):
|
||||||
@ -353,7 +365,7 @@ def extract_text_with_keywords(processed_paragraphs, keywords, follow_up_keyword
|
|||||||
active_key = text
|
active_key = text
|
||||||
extracted_paragraphs[active_key] = [text]
|
extracted_paragraphs[active_key] = [text]
|
||||||
|
|
||||||
if (re.match(pattern_numbered, text) or re.match(pattern_parentheses, text)) and len(text) < 10:
|
if (re.match(pattern_numbered, text) or re.match(pattern_parentheses, text)) and len(text.replace(' ','')) < 10:
|
||||||
continue_collecting = True
|
continue_collecting = True
|
||||||
process_matching_section()
|
process_matching_section()
|
||||||
elif match_keywords(text, follow_up_keywords):
|
elif match_keywords(text, follow_up_keywords):
|
||||||
@ -381,7 +393,7 @@ def extract_text_with_keywords(processed_paragraphs, keywords, follow_up_keyword
|
|||||||
current_top_level_num = int(current_section_number.split('.')[0])
|
current_top_level_num = int(current_section_number.split('.')[0])
|
||||||
for i in range(1, 6):
|
for i in range(1, 6):
|
||||||
next_top_level_num = current_top_level_num + i
|
next_top_level_num = current_top_level_num + i
|
||||||
next_top_level_pattern = r'^' + str(next_top_level_num) + r'\s*[..、]'
|
next_top_level_pattern = r'^' + str(next_top_level_num) + r'\s*[..、](?!\d)'
|
||||||
if next_top_level_pattern not in matched_patterns:
|
if next_top_level_pattern not in matched_patterns:
|
||||||
matched_patterns.append(next_top_level_pattern)
|
matched_patterns.append(next_top_level_pattern)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@ -528,7 +540,7 @@ def handle_query(file_path, user_query, output_file, result_key, keywords):
|
|||||||
r'情\s*形\s*之\s*一',
|
r'情\s*形\s*之\s*一',
|
||||||
r'情\s*况\s*之\s*一',
|
r'情\s*况\s*之\s*一',
|
||||||
r'下\s*列(?!\s*公式)', # 增加负向前瞻,排除“下列公式”
|
r'下\s*列(?!\s*公式)', # 增加负向前瞻,排除“下列公式”
|
||||||
r'以\s*下(?!\s*公式)', # 增加负向前瞻,排除“以下公式”
|
r'以\s*下(?!\s*(?:公式|简称))', # 增加负向前瞻,排除“以下公式”
|
||||||
r'其\s*他.*?情\s*形\s*[::]',
|
r'其\s*他.*?情\s*形\s*[::]',
|
||||||
r'包\s*括'
|
r'包\s*括'
|
||||||
]
|
]
|
||||||
@ -628,54 +640,54 @@ def combine_find_invalid(invalid_docpath, output_dir):
|
|||||||
os.path.join(output_dir, "temp1.txt"),
|
os.path.join(output_dir, "temp1.txt"),
|
||||||
"否决和无效投标情形"
|
"否决和无效投标情形"
|
||||||
),
|
),
|
||||||
(
|
# (
|
||||||
r'废\s*标',
|
# r'废\s*标',
|
||||||
"""以下是从招标文件中摘取的内容,文本中序号分明,文本内之间的信息以'...............'分割。
|
# """以下是从招标文件中摘取的内容,文本中序号分明,文本内之间的信息以'...............'分割。
|
||||||
任务目标:
|
# 任务目标:
|
||||||
请根据以下内容,筛选出 废标项的情况 (明确描述导致 废标 的情况)并返回对应的序号。
|
# 请根据以下内容,筛选出 废标项的情况 (明确描述导致 废标 的情况)并返回对应的序号。
|
||||||
要求与指南:
|
# 要求与指南:
|
||||||
文本中可能存在无关的信息,请准确筛选符合条件的信息,并将符合条件的信息的序号返回。
|
# 文本中可能存在无关的信息,请准确筛选符合条件的信息,并将符合条件的信息的序号返回。
|
||||||
输出格式:
|
# 输出格式:
|
||||||
返回结果以 [x, x, x] 的形式,其中 x 为符合条件的信息的序号,为自然数。无需额外返回解释与说明。
|
# 返回结果以 [x, x, x] 的形式,其中 x 为符合条件的信息的序号,为自然数。无需额外返回解释与说明。
|
||||||
如果文本中没有任何符合条件的废标情况,请返回 []。
|
# 如果文本中没有任何符合条件的废标情况,请返回 []。
|
||||||
示例输出,仅供格式参考:
|
# 示例输出,仅供格式参考:
|
||||||
[1,3,4,6]
|
# [1,3,4,6]
|
||||||
文本内容:{full_text}
|
# 文本内容:{full_text}
|
||||||
""",
|
# """,
|
||||||
os.path.join(output_dir, "temp2.txt"),
|
# os.path.join(output_dir, "temp2.txt"),
|
||||||
"废标项"
|
# "废标项"
|
||||||
),
|
# ),
|
||||||
(
|
# (
|
||||||
r'不\s*得(?!\s*(分|力))|禁\s*止\s*投\s*标',
|
# r'不\s*得(?!\s*(分|力))|禁\s*止\s*投\s*标',
|
||||||
"""以下是从招标文件中摘取的内容,文本中序号分明,文本内的条款以'...............'分割。条款规定了各方不得存在的情形。请根据以下要求进行筛选:
|
# """以下是从招标文件中摘取的内容,文本中序号分明,文本内的条款以'...............'分割。条款规定了各方不得存在的情形。请根据以下要求进行筛选:
|
||||||
**投标相关主体与非投标相关主体的定义**:
|
# **投标相关主体与非投标相关主体的定义**:
|
||||||
投标相关主体:包括但不限于“投标人”、“中标人”、“供应商”、“联合体投标各方”、“响应人”、“应答人”或其他描述投标方的词语。
|
# 投标相关主体:包括但不限于“投标人”、“中标人”、“供应商”、“联合体投标各方”、“响应人”、“应答人”或其他描述投标方的词语。
|
||||||
非投标相关主体:包括但不限于“招标人”、“采购人”、“评标委员会”或其他描述非投标方的词语。
|
# 非投标相关主体:包括但不限于“招标人”、“采购人”、“评标委员会”或其他描述非投标方的词语。
|
||||||
**筛选要求**:
|
# **筛选要求**:
|
||||||
1. **仅筛选**明确描述投标相关主体禁止情形或不得存在的情形的条款,不包含笼统或未具体说明情形的条款。例如:
|
# 1. **仅筛选**明确描述投标相关主体禁止情形或不得存在的情形的条款,不包含笼统或未具体说明情形的条款。例如:
|
||||||
若条款内容包含'投标人不得存在的其他关联情形'这样的笼统描述,而未说明具体的情形,则无需添加该条款。
|
# 若条款内容包含'投标人不得存在的其他关联情形'这样的笼统描述,而未说明具体的情形,则无需添加该条款。
|
||||||
2. **排除**仅描述非投标相关主体行为限制或禁止情形的条款,例如“招标人不得泄露信息”或“评标委员会不得收受贿赂”,则无需返回。
|
# 2. **排除**仅描述非投标相关主体行为限制或禁止情形的条款,例如“招标人不得泄露信息”或“评标委员会不得收受贿赂”,则无需返回。
|
||||||
3. 若条款同时描述了对投标相关主体与非投标相关主体的行为限制、禁止情形,也需返回。
|
# 3. 若条款同时描述了对投标相关主体与非投标相关主体的行为限制、禁止情形,也需返回。
|
||||||
4. **特殊情况**:如果条款中包含“磋商小组”、”各方“等既能指代投标相关主体又能指代非投标相关主体的词汇:
|
# 4. **特殊情况**:如果条款中包含“磋商小组”、”各方“等既能指代投标相关主体又能指代非投标相关主体的词汇:
|
||||||
若在语境中其指代或包含投标相关主体,则应将其考虑在内;否则,排除该条款。
|
# 若在语境中其指代或包含投标相关主体,则应将其考虑在内;否则,排除该条款。
|
||||||
|
#
|
||||||
**输出格式**:
|
# **输出格式**:
|
||||||
返回结果以 [x, x, x] 的形式,其中 x 为符合条件的条款的序号,为自然数。无需额外返回解释与说明。
|
# 返回结果以 [x, x, x] 的形式,其中 x 为符合条件的条款的序号,为自然数。无需额外返回解释与说明。
|
||||||
如果没有符合条件的条款,返回 `[]`。
|
# 如果没有符合条件的条款,返回 `[]`。
|
||||||
**示例**:
|
# **示例**:
|
||||||
- **符合条件**:
|
# - **符合条件**:
|
||||||
- `1. 投标人不得...` → 包含,返回序号 1。
|
# - `1. 投标人不得...` → 包含,返回序号 1。
|
||||||
- `3. 联合体投标各方不得...` → 包含,返回序号 3。
|
# - `3. 联合体投标各方不得...` → 包含,返回序号 3。
|
||||||
- **不符合条件**:
|
# - **不符合条件**:
|
||||||
- `2. 采购人不得...` → 主语为“采购人”,排除。
|
# - `2. 采购人不得...` → 主语为“采购人”,排除。
|
||||||
-示例输出: [1,3]
|
# -示例输出: [1,3]
|
||||||
请根据上述筛选要求,阅读以下文本内容,并返回符合条件的条款序号,
|
# 请根据上述筛选要求,阅读以下文本内容,并返回符合条件的条款序号,
|
||||||
|
#
|
||||||
文本内容:{full_text}
|
# 文本内容:{full_text}
|
||||||
""",
|
# """,
|
||||||
os.path.join(output_dir, "temp3.txt"),
|
# os.path.join(output_dir, "temp3.txt"),
|
||||||
"不得存在的情形"
|
# "不得存在的情形"
|
||||||
)
|
# )
|
||||||
]
|
]
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
@ -713,7 +725,7 @@ if __name__ == '__main__':
|
|||||||
output_dir = r"C:\Users\Administrator\Desktop\货物标\zbfiles\output6"
|
output_dir = r"C:\Users\Administrator\Desktop\货物标\zbfiles\output6"
|
||||||
# invalid_added = insert_mark(pdf_path)
|
# invalid_added = insert_mark(pdf_path)
|
||||||
# invalid_added_docx = pdf2docx(invalid_added)
|
# invalid_added_docx = pdf2docx(invalid_added)
|
||||||
invalid_added_docx=r'C:\Users\Administrator\Desktop\fsdownload\a3b259fd-5ade-4c66-9117-eb44796682ad\invalid_added.docx'
|
invalid_added_docx=r'C:\Users\Administrator\Desktop\fsdownload\355fbb20-e439-48dd-abdd-7645d424af36\invalid_added.docx'
|
||||||
results = combine_find_invalid(invalid_added_docx, output_dir)
|
results = combine_find_invalid(invalid_added_docx, output_dir)
|
||||||
end_time = time.time()
|
end_time = time.time()
|
||||||
print("Results:", json.dumps(results, ensure_ascii=False, indent=4))
|
print("Results:", json.dumps(results, ensure_ascii=False, indent=4))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user