pydatamax 0.1.14__py3-none-any.whl → 0.1.15.post2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. datamax/__init__.py +1 -1
  2. datamax/loader/core.py +118 -118
  3. datamax/loader/minio_handler.py +171 -171
  4. datamax/loader/oss_handler.py +191 -191
  5. datamax/parser/__init__.py +2 -4
  6. datamax/parser/base.py +76 -76
  7. datamax/parser/core.py +406 -288
  8. datamax/parser/csv_parser.py +31 -10
  9. datamax/parser/doc_parser.py +466 -10
  10. datamax/parser/docx_parser.py +449 -11
  11. datamax/parser/epub_parser.py +41 -41
  12. datamax/parser/html_parser.py +37 -37
  13. datamax/parser/image_parser.py +34 -34
  14. datamax/parser/json_parser.py +32 -10
  15. datamax/parser/md_parser.py +72 -72
  16. datamax/parser/pdf_parser.py +101 -101
  17. datamax/parser/ppt_parser.py +70 -20
  18. datamax/parser/pptx_parser.py +45 -45
  19. datamax/parser/txt_parser.py +45 -45
  20. datamax/parser/xls_parser.py +26 -26
  21. datamax/parser/xlsx_parser.py +212 -215
  22. datamax/utils/__init__.py +23 -2
  23. datamax/utils/constants.py +58 -58
  24. datamax/utils/data_cleaner.py +275 -237
  25. datamax/utils/env_setup.py +79 -79
  26. datamax/utils/gotocr_pdf.py +265 -265
  27. datamax/utils/mineru_operator.py +62 -62
  28. datamax/utils/paddleocr_pdf_operator.py +90 -90
  29. datamax/utils/ppt_extract.py +140 -140
  30. datamax/utils/qa_generator.py +369 -376
  31. datamax/utils/tokenizer.py +21 -21
  32. datamax/utils/uno_handler.py +426 -0
  33. {pydatamax-0.1.14.dist-info → pydatamax-0.1.15.post2.dist-info}/METADATA +117 -5
  34. pydatamax-0.1.15.post2.dist-info/RECORD +38 -0
  35. {pydatamax-0.1.14.dist-info → pydatamax-0.1.15.post2.dist-info}/licenses/LICENSE +21 -21
  36. {pydatamax-0.1.14.dist-info → pydatamax-0.1.15.post2.dist-info}/top_level.txt +0 -1
  37. pydatamax-0.1.14.dist-info/RECORD +0 -39
  38. tests/__init__.py +0 -0
  39. tests/test_basic.py +0 -20
  40. {pydatamax-0.1.14.dist-info → pydatamax-0.1.15.post2.dist-info}/WHEEL +0 -0
@@ -1,215 +1,212 @@
1
- import logging
2
- import multiprocessing
3
- import os
4
- import time
5
- import warnings
6
- from multiprocessing import Queue
7
-
8
- import pandas as pd
9
-
10
- from datamax.parser.base import BaseLife, MarkdownOutputVo
11
-
12
- warnings.filterwarnings("ignore")
13
-
14
- # 配置日志
15
- logger = logging.getLogger(__name__)
16
-
17
-
18
- class XlsxParser(BaseLife):
19
- """XLSX解析器 - 使用pandas读取并转换为markdown,支持多进程处理"""
20
-
21
- def __init__(self, file_path, timeout):
22
- super().__init__()
23
- self.file_path = file_path
24
- self.timeout = timeout
25
- logger.info(f"🚀 XlsxParser初始化完成 - 文件路径: {file_path}, 超时: {timeout}s")
26
-
27
- def _parse_with_pandas(self, file_path: str) -> str:
28
- """使用pandas读取Excel并转换为markdown"""
29
- logger.info(f"🐼 开始使用pandas读取Excel文件: {file_path}")
30
-
31
- try:
32
- # 验证文件存在
33
- if not os.path.exists(file_path):
34
- logger.error(f"🚫 Excel文件不存在: {file_path}")
35
- raise FileNotFoundError(f"文件不存在: {file_path}")
36
-
37
- # 验证文件大小
38
- file_size = os.path.getsize(file_path)
39
- logger.info(f"📏 文件大小: {file_size} 字节")
40
-
41
- if file_size == 0:
42
- logger.warning(f"⚠️ 文件大小为0字节: {file_path}")
43
- return "*文件为空*"
44
-
45
- # 使用pandas读取Excel文件
46
- logger.debug("📊 正在读取Excel数据...")
47
- df = pd.read_excel(file_path, sheet_name=None) # 读取所有工作表
48
-
49
- markdown_content = ""
50
-
51
- if isinstance(df, dict):
52
- # 多个工作表
53
- logger.info(f"📑 检测到多个工作表,共 {len(df)}")
54
- for sheet_name, sheet_df in df.items():
55
- logger.debug(f"📋 处理工作表: {sheet_name}, 形状: {sheet_df.shape}")
56
- markdown_content += f"## 工作表: {sheet_name}\n\n"
57
-
58
- if not sheet_df.empty:
59
- # 清理数据:移除完全为空的行和列
60
- sheet_df = sheet_df.dropna(how="all").dropna(axis=1, how="all")
61
-
62
- if not sheet_df.empty:
63
- sheet_markdown = sheet_df.to_markdown(index=False)
64
- markdown_content += sheet_markdown + "\n\n"
65
- logger.debug(
66
- f"✅ 工作表 {sheet_name} 转换完成,有效数据形状: {sheet_df.shape}"
67
- )
68
- else:
69
- markdown_content += "*该工作表无有效数据*\n\n"
70
- logger.warning(f"⚠️ 工作表 {sheet_name} 清理后无有效数据")
71
- else:
72
- markdown_content += "*该工作表为空*\n\n"
73
- logger.warning(f"⚠️ 工作表 {sheet_name} 为空")
74
- else:
75
- # 单个工作表
76
- logger.info(f"📄 单个工作表,形状: {df.shape}")
77
- if not df.empty:
78
- # 清理数据:移除完全为空的行和列
79
- df = df.dropna(how="all").dropna(axis=1, how="all")
80
-
81
- if not df.empty:
82
- markdown_content = df.to_markdown(index=False)
83
- logger.info(f" 工作表转换完成,有效数据形状: {df.shape}")
84
- else:
85
- markdown_content = "*工作表无有效数据*"
86
- logger.warning("⚠️ 工作表清理后无有效数据")
87
- else:
88
- markdown_content = "*工作表为空*"
89
- logger.warning("⚠️ 工作表为空")
90
-
91
- logger.info(f"🎊 pandas转换完成,markdown内容长度: {len(markdown_content)} 字符")
92
- logger.debug(f"👀 前200字符预览: {markdown_content[:200]}...")
93
-
94
- return markdown_content
95
-
96
- except FileNotFoundError as e:
97
- logger.error(f"🚫 文件未找到: {str(e)}")
98
- raise
99
- except PermissionError as e:
100
- logger.error(f"🔒 文件权限错误: {str(e)}")
101
- raise Exception(f"无权限访问文件: {file_path}")
102
- except pd.errors.EmptyDataError as e:
103
- logger.error(f"📭 Excel文件为空: {str(e)}")
104
- raise Exception(f"Excel文件为空或无法读取: {file_path}")
105
- except Exception as e:
106
- logger.error(f"💥 pandas读取Excel失败: {str(e)}")
107
- raise
108
-
109
- def _parse(self, file_path: str, result_queue: Queue) -> dict:
110
- """解析Excel文件的核心方法"""
111
- logger.info(f"🎬 开始解析Excel文件: {file_path}")
112
-
113
- try:
114
- # 使用pandas解析Excel
115
- logger.info("🐼 使用pandas模式解析Excel")
116
- mk_content = self._parse_with_pandas(file_path)
117
-
118
- # 检查内容是否为空
119
- if not mk_content.strip():
120
- logger.warning(f"⚠️ 解析出的内容为空: {file_path}")
121
- mk_content = "*无法解析文件内容*"
122
-
123
- logger.info(f"🎊 文件内容解析完成,最终内容长度: {len(mk_content)} 字符")
124
-
125
- # 生成lifecycle信息
126
- lifecycle = self.generate_lifecycle(
127
- source_file=file_path,
128
- domain="Technology",
129
- usage_purpose="Documentation",
130
- life_type="LLM_ORIGIN",
131
- )
132
- logger.debug("⚙️ 生成lifecycle信息完成")
133
-
134
- # 创建输出对象
135
- title = self.get_file_extension(file_path)
136
- output_vo = MarkdownOutputVo(title, mk_content)
137
- output_vo.add_lifecycle(lifecycle)
138
-
139
- result = output_vo.to_dict()
140
- result_queue.put(result)
141
- logger.info(f"🏆 Excel文件解析完成: {file_path}")
142
- logger.debug(f"🔑 返回结果键: {list(result.keys())}")
143
-
144
- time.sleep(0.5) # 给队列一点时间
145
- return result
146
-
147
- except Exception as e:
148
- logger.error(f"💀 解析Excel文件失败: {file_path}, 错误: {str(e)}")
149
- # 将错误也放入队列
150
- error_result = {"error": str(e), "file_path": file_path}
151
- result_queue.put(error_result)
152
- raise
153
-
154
- def parse(self, file_path: str) -> dict:
155
- """解析Excel文件 - 支持多进程和超时控制"""
156
- logger.info(f"🚀 启动Excel解析进程 - 文件: {file_path}, 超时: {self.timeout}s")
157
-
158
- try:
159
- # 验证文件存在
160
- if not os.path.exists(file_path):
161
- logger.error(f"🚫 文件不存在: {file_path}")
162
- raise FileNotFoundError(f"文件不存在: {file_path}")
163
-
164
- # 验证文件扩展名
165
- if not file_path.lower().endswith((".xlsx", ".xls")):
166
- logger.warning(f"⚠️ 文件扩展名不是Excel格式: {file_path}")
167
-
168
- result_queue = Queue()
169
- process = multiprocessing.Process(
170
- target=self._parse, args=(file_path, result_queue)
171
- )
172
- process.start()
173
- logger.debug(f"⚡ 启动子进程,PID: {process.pid}")
174
-
175
- start_time = time.time()
176
-
177
- # 等待解析完成或超时
178
- while time.time() - start_time < self.timeout:
179
- elapsed_time = int(time.time() - start_time)
180
- logger.debug(f"⏱️ 等待解析完成... {elapsed_time}s")
181
-
182
- if not process.is_alive():
183
- logger.debug("✅ 子进程已完成")
184
- break
185
-
186
- if not result_queue.empty():
187
- result = result_queue.get()
188
- process.join() # 等待进程正常结束
189
-
190
- # 检查是否是错误结果
191
- if "error" in result:
192
- logger.error(f"💥 子进程返回错误: {result['error']}")
193
- raise Exception(result["error"])
194
-
195
- logger.info(f"🎉 Excel解析成功完成,耗时: {elapsed_time}s")
196
- return result
197
-
198
- time.sleep(1)
199
- else:
200
- # 超时处理
201
- logger.error(f"⏰ 解析超时 ({self.timeout}s),终止进程")
202
- process.terminate()
203
- process.join(timeout=5) # 给进程5秒时间优雅退出
204
-
205
- if process.is_alive():
206
- logger.error("💀 强制杀死进程")
207
- process.kill()
208
-
209
- raise TimeoutError(f"Excel解析超时: {file_path}")
210
-
211
- except Exception as e:
212
- logger.error(
213
- f"💀 Excel解析失败: {file_path}, 错误类型: {type(e).__name__}, 错误信息: {str(e)}"
214
- )
215
- raise
1
+ from loguru import logger
2
+ import multiprocessing
3
+ import os
4
+ import time
5
+ import warnings
6
+ from multiprocessing import Queue
7
+
8
+ import pandas as pd
9
+
10
+ from datamax.parser.base import BaseLife, MarkdownOutputVo
11
+
12
+ warnings.filterwarnings("ignore")
13
+
14
+
15
+ class XlsxParser(BaseLife):
16
+ """XLSX解析器 - 使用pandas读取并转换为markdown,支持多进程处理"""
17
+
18
+ def __init__(self, file_path, timeout):
19
+ super().__init__()
20
+ self.file_path = file_path
21
+ self.timeout = timeout
22
+ logger.info(f"🚀 XlsxParser初始化完成 - 文件路径: {file_path}, 超时: {timeout}s")
23
+
24
+ def _parse_with_pandas(self, file_path: str) -> str:
25
+ """使用pandas读取Excel并转换为markdown"""
26
+ logger.info(f"🐼 开始使用pandas读取Excel文件: {file_path}")
27
+
28
+ try:
29
+ # 验证文件存在
30
+ if not os.path.exists(file_path):
31
+ logger.error(f"🚫 Excel文件不存在: {file_path}")
32
+ raise FileNotFoundError(f"文件不存在: {file_path}")
33
+
34
+ # 验证文件大小
35
+ file_size = os.path.getsize(file_path)
36
+ logger.info(f"📏 文件大小: {file_size} 字节")
37
+
38
+ if file_size == 0:
39
+ logger.warning(f"⚠️ 文件大小为0字节: {file_path}")
40
+ return "*文件为空*"
41
+
42
+ # 使用pandas读取Excel文件
43
+ logger.debug("📊 正在读取Excel数据...")
44
+ df = pd.read_excel(file_path, sheet_name=None) # 读取所有工作表
45
+
46
+ markdown_content = ""
47
+
48
+ if isinstance(df, dict):
49
+ # 多个工作表
50
+ logger.info(f"📑 检测到多个工作表,共 {len(df)} 个")
51
+ for sheet_name, sheet_df in df.items():
52
+ logger.debug(f"📋 处理工作表: {sheet_name}, 形状: {sheet_df.shape}")
53
+ markdown_content += f"## 工作表: {sheet_name}\n\n"
54
+
55
+ if not sheet_df.empty:
56
+ # 清理数据:移除完全为空的行和列
57
+ sheet_df = sheet_df.dropna(how="all").dropna(axis=1, how="all")
58
+
59
+ if not sheet_df.empty:
60
+ sheet_markdown = sheet_df.to_markdown(index=False)
61
+ markdown_content += sheet_markdown + "\n\n"
62
+ logger.debug(
63
+ f"✅ 工作表 {sheet_name} 转换完成,有效数据形状: {sheet_df.shape}"
64
+ )
65
+ else:
66
+ markdown_content += "*该工作表无有效数据*\n\n"
67
+ logger.warning(f"⚠️ 工作表 {sheet_name} 清理后无有效数据")
68
+ else:
69
+ markdown_content += "*该工作表为空*\n\n"
70
+ logger.warning(f"⚠️ 工作表 {sheet_name} 为空")
71
+ else:
72
+ # 单个工作表
73
+ logger.info(f"📄 单个工作表,形状: {df.shape}")
74
+ if not df.empty:
75
+ # 清理数据:移除完全为空的行和列
76
+ df = df.dropna(how="all").dropna(axis=1, how="all")
77
+
78
+ if not df.empty:
79
+ markdown_content = df.to_markdown(index=False)
80
+ logger.info(f"✅ 工作表转换完成,有效数据形状: {df.shape}")
81
+ else:
82
+ markdown_content = "*工作表无有效数据*"
83
+ logger.warning("⚠️ 工作表清理后无有效数据")
84
+ else:
85
+ markdown_content = "*工作表为空*"
86
+ logger.warning("⚠️ 工作表为空")
87
+
88
+ logger.info(f"🎊 pandas转换完成,markdown内容长度: {len(markdown_content)} 字符")
89
+ logger.debug(f"👀 前200字符预览: {markdown_content[:200]}...")
90
+
91
+ return markdown_content
92
+
93
+ except FileNotFoundError as e:
94
+ logger.error(f"🚫 文件未找到: {str(e)}")
95
+ raise
96
+ except PermissionError as e:
97
+ logger.error(f"🔒 文件权限错误: {str(e)}")
98
+ raise Exception(f"无权限访问文件: {file_path}")
99
+ except pd.errors.EmptyDataError as e:
100
+ logger.error(f"📭 Excel文件为空: {str(e)}")
101
+ raise Exception(f"Excel文件为空或无法读取: {file_path}")
102
+ except Exception as e:
103
+ logger.error(f"💥 pandas读取Excel失败: {str(e)}")
104
+ raise
105
+
106
+ def _parse(self, file_path: str, result_queue: Queue) -> dict:
107
+ """解析Excel文件的核心方法"""
108
+ logger.info(f"🎬 开始解析Excel文件: {file_path}")
109
+
110
+ try:
111
+ # 使用pandas解析Excel
112
+ logger.info("🐼 使用pandas模式解析Excel")
113
+ mk_content = self._parse_with_pandas(file_path)
114
+
115
+ # 检查内容是否为空
116
+ if not mk_content.strip():
117
+ logger.warning(f"⚠️ 解析出的内容为空: {file_path}")
118
+ mk_content = "*无法解析文件内容*"
119
+
120
+ logger.info(f"🎊 文件内容解析完成,最终内容长度: {len(mk_content)} 字符")
121
+
122
+ # 生成lifecycle信息
123
+ lifecycle = self.generate_lifecycle(
124
+ source_file=file_path,
125
+ domain="Technology",
126
+ usage_purpose="Documentation",
127
+ life_type="LLM_ORIGIN",
128
+ )
129
+ logger.debug("⚙️ 生成lifecycle信息完成")
130
+
131
+ # 创建输出对象
132
+ title = os.path.splitext(os.path.basename(file_path))[0]
133
+ output_vo = MarkdownOutputVo(title, mk_content)
134
+ output_vo.add_lifecycle(lifecycle)
135
+
136
+ result = output_vo.to_dict()
137
+ result_queue.put(result)
138
+ logger.info(f"🏆 Excel文件解析完成: {file_path}")
139
+ logger.debug(f"🔑 返回结果键: {list(result.keys())}")
140
+
141
+ time.sleep(0.5) # 给队列一点时间
142
+ return result
143
+
144
+ except Exception as e:
145
+ logger.error(f"💀 解析Excel文件失败: {file_path}, 错误: {str(e)}")
146
+ # 将错误也放入队列
147
+ error_result = {"error": str(e), "file_path": file_path}
148
+ result_queue.put(error_result)
149
+ raise
150
+
151
+ def parse(self, file_path: str) -> dict:
152
+ """解析Excel文件 - 支持多进程和超时控制"""
153
+ logger.info(f"🚀 启动Excel解析进程 - 文件: {file_path}, 超时: {self.timeout}s")
154
+
155
+ try:
156
+ # 验证文件存在
157
+ if not os.path.exists(file_path):
158
+ logger.error(f"🚫 文件不存在: {file_path}")
159
+ raise FileNotFoundError(f"文件不存在: {file_path}")
160
+
161
+ # 验证文件扩展名
162
+ if not file_path.lower().endswith((".xlsx", ".xls")):
163
+ logger.warning(f"⚠️ 文件扩展名不是Excel格式: {file_path}")
164
+
165
+ result_queue = Queue()
166
+ process = multiprocessing.Process(
167
+ target=self._parse, args=(file_path, result_queue)
168
+ )
169
+ process.start()
170
+ logger.debug(f"⚡ 启动子进程,PID: {process.pid}")
171
+
172
+ start_time = time.time()
173
+
174
+ # 等待解析完成或超时
175
+ while time.time() - start_time < self.timeout:
176
+ elapsed_time = int(time.time() - start_time)
177
+ logger.debug(f"⏱️ 等待解析完成... {elapsed_time}s")
178
+
179
+ if not process.is_alive():
180
+ logger.debug(" 子进程已完成")
181
+ break
182
+
183
+ if not result_queue.empty():
184
+ result = result_queue.get()
185
+ process.join() # 等待进程正常结束
186
+
187
+ # 检查是否是错误结果
188
+ if "error" in result:
189
+ logger.error(f"💥 子进程返回错误: {result['error']}")
190
+ raise Exception(result["error"])
191
+
192
+ logger.info(f"🎉 Excel解析成功完成,耗时: {elapsed_time}s")
193
+ return result
194
+
195
+ time.sleep(1)
196
+ else:
197
+ # 超时处理
198
+ logger.error(f"⏰ 解析超时 ({self.timeout}s),终止进程")
199
+ process.terminate()
200
+ process.join(timeout=5) # 给进程5秒时间优雅退出
201
+
202
+ if process.is_alive():
203
+ logger.error("💀 强制杀死进程")
204
+ process.kill()
205
+
206
+ raise TimeoutError(f"Excel解析超时: {file_path}")
207
+
208
+ except Exception as e:
209
+ logger.error(
210
+ f"💀 Excel解析失败: {file_path}, 错误类型: {type(e).__name__}, 错误信息: {str(e)}"
211
+ )
212
+ raise
datamax/utils/__init__.py CHANGED
@@ -1,6 +1,27 @@
1
- from datamax.utils.data_cleaner import AbnormalCleaner, TextFilter, PrivacyDesensitization
1
+ from datamax.utils.data_cleaner import (
2
+ AbnormalCleaner,
3
+ PrivacyDesensitization,
4
+ TextFilter,
5
+ )
2
6
  from datamax.utils.env_setup import setup_environment
3
7
 
8
+ # 条件导入UNO处理器
9
+ try:
10
+ from datamax.utils.uno_handler import (
11
+ HAS_UNO,
12
+ UnoManager,
13
+ cleanup_uno_manager,
14
+ convert_with_uno,
15
+ get_uno_manager,
16
+ uno_manager_context,
17
+ )
18
+ except ImportError:
19
+ HAS_UNO = False
20
+ UnoManager = None
21
+ get_uno_manager = None
22
+ convert_with_uno = None
23
+ cleanup_uno_manager = None
24
+ uno_manager_context = None
4
25
 
5
26
  def clean_original_text(text):
6
27
  """
@@ -29,4 +50,4 @@ def clean_original_privacy_text(text):
29
50
  text = text_filter.to_filter()
30
51
  privacy_desensitization = PrivacyDesensitization(parsed_data={"text": text})
31
52
  text = privacy_desensitization.to_private()
32
- return text
53
+ return text
@@ -1,58 +1,58 @@
1
- def get_system_prompt(knowledge):
2
- system_prompt = f"""
3
- 你是一个精确并高效的航运问答对生成助手,你的职责是基于用户提供的特定航运知识为用户生成关于每个航运知识的问题和答案也被称为问答对,达到考察该知识点的效果。
4
- 你需要完全按照标注要求以及注意事项来生成问答,请完整读取该格式的航运知识:{knowledge}
5
-
6
- 目标 (Objective):
7
- 你的目标是根据已知信息生成出正确和精准的问答对,并且确保包括原文里提及的所有正确选项以及保证所有的专业术语拼写正确。
8
-
9
- 风格 (Style):
10
- 你的回答风格应该是官方航运问题专家的风格。
11
-
12
- 语气 (Tone):
13
- 你的语气应该是正式的
14
-
15
- 受众 (Audience):
16
- 你的受众是数据标注人员,他们需要根据你的标注进行修改
17
-
18
- 响应 (Response):
19
- 你的响应格式应该是以json的格式返回如下:
20
- ```json
21
- {{
22
- "instruction": "<生成的相关问题>",
23
- "input": "",
24
- "output": "<根据知识生成的答案>"
25
- }}
26
-
27
- # 标注要求
28
- 1. 对于可能存在歧义的名词,需要给出完整的定语,以消除歧义。
29
- a.《水面智能搜救机器人技术指南》
30
- i.搜救机器人的连续工作时间要求不小于30分钟。-> 错误
31
- ii.水面智能搜救机器人的连续工作时间要求不小于30分钟。-> 正确
32
- 2. QA对答案的字符长度有要求,不能少于50字。仅要求下限为50字,不做字数上限要求。
33
- 3. 可以引用规则或规定的章节号,但必须同时引用章节的原文相关内容。
34
- a.可继续按照原适用的CCS《钢质海船入级规范》第8篇第8章的要求维护CLEAN附加标志。X
35
- b.可继续按照原适用的CCS《钢质海船入级规范》第8篇第8章【原文】的要求维护CLEAN附加标志。√
36
- 4. 请使用标准的markdown格式来表示多层级结构,例如使用"xxx\n1.1. xxx\n1.1.1. xxx"。
37
- 5. 请勿使用序号标识,如(1),一、①、Ⅰ、壹等,以保持格式的统一性。
38
- 6. 对于需要强调的专有名词或关键词,请使用** **来代替单引号或双引号。
39
- 7. 在数据中,如果存在明显的错误,如语法错误或逻辑错误,需要自行进行剔除。
40
- 8. 数据需要按照markdown格式进行格式化,并保留\n换行符标识。
41
- 9. 对于具有明确意义的数字,要求准确率达到100%。
42
- 10. 问答对的答案不能为①,A,等选项引用。
43
- 11. 问答对的问题不能出现“以下错误的是”,“这几项哪个是正确的”等形式。
44
- 12. 文本数据要具备专业性,减少出现“因为” “因此” “此外” “首先”等冗余的连词或副词。
45
- 13. 大段文字内容,有并列逻辑的,需要存在换行符\n与有序列表1. 2. 3. 标识。
46
- 14. 大段文字内容,有层级逻辑的,需要将原文层级合理编排。不能直接把第1章第2节1.1.2xxxxx内容堆叠在一起,要通过中文语言将层级合理编排为通顺的语句。
47
-
48
- # 注意事项
49
- 1. 请选择最有价值的五个知识点, 最终返回一个jsonlist.
50
- 2. 每个json内容需要保持格式一致, 且output中生成的答案不少于50字
51
- , 请以完整航运知识为主进行专业且不偏题的扩写
52
- 3. 所有的专业术语拼写必须要完全正确
53
- 4. 问答对的问题应该是提供的知识点的重点
54
- 5. 你的信息来源只能是提供的航运知识
55
- 6. jsonlist长度不超过5
56
- 7. 最终仅返回结果,不要有其他代表格式的markdown文本例如 ```python ```json
57
- """
58
- return system_prompt
1
+ def get_system_prompt(knowledge):
2
+ system_prompt = f"""
3
+ 你是一个精确并高效的航运问答对生成助手,你的职责是基于用户提供的特定航运知识为用户生成关于每个航运知识的问题和答案也被称为问答对,达到考察该知识点的效果。
4
+ 你需要完全按照标注要求以及注意事项来生成问答,请完整读取该格式的航运知识:{knowledge}
5
+
6
+ 目标 (Objective):
7
+ 你的目标是根据已知信息生成出正确和精准的问答对,并且确保包括原文里提及的所有正确选项以及保证所有的专业术语拼写正确。
8
+
9
+ 风格 (Style):
10
+ 你的回答风格应该是官方航运问题专家的风格。
11
+
12
+ 语气 (Tone):
13
+ 你的语气应该是正式的
14
+
15
+ 受众 (Audience):
16
+ 你的受众是数据标注人员,他们需要根据你的标注进行修改
17
+
18
+ 响应 (Response):
19
+ 你的响应格式应该是以json的格式返回如下:
20
+ ```json
21
+ {{
22
+ "instruction": "<生成的相关问题>",
23
+ "input": "",
24
+ "output": "<根据知识生成的答案>"
25
+ }}
26
+
27
+ # 标注要求
28
+ 1. 对于可能存在歧义的名词,需要给出完整的定语,以消除歧义。
29
+ a.《水面智能搜救机器人技术指南》
30
+ i.搜救机器人的连续工作时间要求不小于30分钟。-> 错误
31
+ ii.水面智能搜救机器人的连续工作时间要求不小于30分钟。-> 正确
32
+ 2. QA对答案的字符长度有要求,不能少于50字。仅要求下限为50字,不做字数上限要求。
33
+ 3. 可以引用规则或规定的章节号,但必须同时引用章节的原文相关内容。
34
+ a.可继续按照原适用的CCS《钢质海船入级规范》第8篇第8章的要求维护CLEAN附加标志。X
35
+ b.可继续按照原适用的CCS《钢质海船入级规范》第8篇第8章【原文】的要求维护CLEAN附加标志。√
36
+ 4. 请使用标准的markdown格式来表示多层级结构,例如使用"xxx\n1.1. xxx\n1.1.1. xxx"。
37
+ 5. 请勿使用序号标识,如(1),一、①、Ⅰ、壹等,以保持格式的统一性。
38
+ 6. 对于需要强调的专有名词或关键词,请使用** **来代替单引号或双引号。
39
+ 7. 在数据中,如果存在明显的错误,如语法错误或逻辑错误,需要自行进行剔除。
40
+ 8. 数据需要按照markdown格式进行格式化,并保留\n换行符标识。
41
+ 9. 对于具有明确意义的数字,要求准确率达到100%。
42
+ 10. 问答对的答案不能为①,A,等选项引用。
43
+ 11. 问答对的问题不能出现“以下错误的是”,“这几项哪个是正确的”等形式。
44
+ 12. 文本数据要具备专业性,减少出现“因为” “因此” “此外” “首先”等冗余的连词或副词。
45
+ 13. 大段文字内容,有并列逻辑的,需要存在换行符\n与有序列表1. 2. 3. 标识。
46
+ 14. 大段文字内容,有层级逻辑的,需要将原文层级合理编排。不能直接把第1章第2节1.1.2xxxxx内容堆叠在一起,要通过中文语言将层级合理编排为通顺的语句。
47
+
48
+ # 注意事项
49
+ 1. 请选择最有价值的五个知识点, 最终返回一个jsonlist.
50
+ 2. 每个json内容需要保持格式一致, 且output中生成的答案不少于50字
51
+ , 请以完整航运知识为主进行专业且不偏题的扩写
52
+ 3. 所有的专业术语拼写必须要完全正确
53
+ 4. 问答对的问题应该是提供的知识点的重点
54
+ 5. 你的信息来源只能是提供的航运知识
55
+ 6. jsonlist长度不超过5
56
+ 7. 最终仅返回结果,不要有其他代表格式的markdown文本例如 ```python ```json
57
+ """
58
+ return system_prompt