pi-maestro-flow 0.2.0
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.
- package/README.md +124 -0
- package/agents/aggregator.md +27 -0
- package/agents/cli-explore-agent.md +188 -0
- package/agents/cross-role-reviewer.md +171 -0
- package/agents/delegate.md +19 -0
- package/agents/explorer.md +23 -0
- package/agents/impeccable-agent.md +99 -0
- package/agents/ralph-executor.md +81 -0
- package/agents/reference.md +24 -0
- package/agents/role-design-author.md +220 -0
- package/agents/team-supervisor.md +143 -0
- package/agents/team-worker.md +237 -0
- package/agents/ui-design-agent.md +270 -0
- package/agents/workflow-analyzer.md +116 -0
- package/agents/workflow-codebase-mapper.md +77 -0
- package/agents/workflow-collab-planner.md +147 -0
- package/agents/workflow-debugger.md +104 -0
- package/agents/workflow-executor.md +133 -0
- package/agents/workflow-external-researcher.md +86 -0
- package/agents/workflow-integration-checker.md +83 -0
- package/agents/workflow-nyquist-auditor.md +85 -0
- package/agents/workflow-phase-researcher.md +85 -0
- package/agents/workflow-plan-checker.md +100 -0
- package/agents/workflow-planner.md +200 -0
- package/agents/workflow-project-researcher.md +74 -0
- package/agents/workflow-research-synthesizer.md +70 -0
- package/agents/workflow-reviewer.md +82 -0
- package/agents/workflow-roadmapper.md +81 -0
- package/agents/workflow-verifier.md +120 -0
- package/package.json +58 -0
- package/skills/codify-to-knowhow/SKILL.md +167 -0
- package/skills/delegation-check/SKILL.md +297 -0
- package/skills/domain-add/SKILL.md +75 -0
- package/skills/insight-challenge/SKILL.md +226 -0
- package/skills/learn-decompose/SKILL.md +124 -0
- package/skills/learn-follow/SKILL.md +163 -0
- package/skills/learn-investigate/SKILL.md +160 -0
- package/skills/learn-second-opinion/SKILL.md +128 -0
- package/skills/maestro/SKILL.md +239 -0
- package/skills/maestro-amend/SKILL.md +169 -0
- package/skills/maestro-analyze/SKILL.md +173 -0
- package/skills/maestro-blueprint/SKILL.md +159 -0
- package/skills/maestro-brainstorm/SKILL.md +193 -0
- package/skills/maestro-collab/SKILL.md +181 -0
- package/skills/maestro-companion/SKILL.md +536 -0
- package/skills/maestro-composer/SKILL.md +192 -0
- package/skills/maestro-execute/SKILL.md +193 -0
- package/skills/maestro-fork/SKILL.md +104 -0
- package/skills/maestro-grill/SKILL.md +151 -0
- package/skills/maestro-guard/SKILL.md +124 -0
- package/skills/maestro-help/SKILL.md +328 -0
- package/skills/maestro-impeccable/SKILL.md +302 -0
- package/skills/maestro-init/SKILL.md +151 -0
- package/skills/maestro-merge/SKILL.md +90 -0
- package/skills/maestro-milestone-audit/SKILL.md +117 -0
- package/skills/maestro-milestone-complete/SKILL.md +133 -0
- package/skills/maestro-milestone-release/SKILL.md +131 -0
- package/skills/maestro-next/SKILL.md +269 -0
- package/skills/maestro-overlay/SKILL.md +203 -0
- package/skills/maestro-plan/SKILL.md +194 -0
- package/skills/maestro-player/SKILL.md +184 -0
- package/skills/maestro-quick/SKILL.md +117 -0
- package/skills/maestro-ralph/SKILL.md +905 -0
- package/skills/maestro-ralph-cli/SKILL.md +976 -0
- package/skills/maestro-ralph-cli-execute/SKILL.md +229 -0
- package/skills/maestro-ralph-execute/SKILL.md +409 -0
- package/skills/maestro-ralph-v2/SKILL.md +1198 -0
- package/skills/maestro-roadmap/SKILL.md +157 -0
- package/skills/maestro-swarm-workflow/SKILL.md +272 -0
- package/skills/maestro-tools-execute/SKILL.md +143 -0
- package/skills/maestro-tools-register/SKILL.md +192 -0
- package/skills/maestro-ui-codify/SKILL.md +127 -0
- package/skills/maestro-universal-workflow/SKILL.md +622 -0
- package/skills/maestro-update/SKILL.md +156 -0
- package/skills/manage-codebase-rebuild/SKILL.md +111 -0
- package/skills/manage-drift-realign/SKILL.md +159 -0
- package/skills/manage-harvest/SKILL.md +121 -0
- package/skills/manage-issue/SKILL.md +88 -0
- package/skills/manage-issue-discover/SKILL.md +104 -0
- package/skills/manage-kg-extractors/SKILL.md +147 -0
- package/skills/manage-knowhow/SKILL.md +102 -0
- package/skills/manage-knowhow-capture/SKILL.md +109 -0
- package/skills/manage-knowledge-audit/SKILL.md +147 -0
- package/skills/manage-status/SKILL.md +80 -0
- package/skills/manage-wiki/SKILL.md +104 -0
- package/skills/odyssey-debug/SKILL.md +344 -0
- package/skills/odyssey-improve/SKILL.md +423 -0
- package/skills/odyssey-planex/SKILL.md +542 -0
- package/skills/odyssey-review-test-fix/SKILL.md +392 -0
- package/skills/odyssey-ui/SKILL.md +388 -0
- package/skills/prompt-generator/SKILL.md +470 -0
- package/skills/quality-auto-test/SKILL.md +168 -0
- package/skills/quality-debug/SKILL.md +176 -0
- package/skills/quality-refactor/SKILL.md +108 -0
- package/skills/quality-retrospective/SKILL.md +134 -0
- package/skills/quality-review/SKILL.md +169 -0
- package/skills/quality-sync/SKILL.md +90 -0
- package/skills/quality-test/SKILL.md +183 -0
- package/skills/scholar-anti-ai-writing/SKILL.md +173 -0
- package/skills/scholar-anti-ai-writing/references/patterns-chinese.md +242 -0
- package/skills/scholar-anti-ai-writing/references/patterns-english.md +242 -0
- package/skills/scholar-citation-verify/SKILL.md +166 -0
- package/skills/scholar-citation-verify/references/api-usage.md +372 -0
- package/skills/scholar-citation-verify/references/common-errors.md +384 -0
- package/skills/scholar-citation-verify/references/verification-rules.md +399 -0
- package/skills/scholar-experiment/SKILL.md +321 -0
- package/skills/scholar-ideation/SKILL.md +288 -0
- package/skills/scholar-latex-organizer/SKILL.md +186 -0
- package/skills/scholar-publish/SKILL.md +220 -0
- package/skills/scholar-rebuttal-pro/README.md +313 -0
- package/skills/scholar-rebuttal-pro/SKILL.md +511 -0
- package/skills/scholar-review/SKILL.md +227 -0
- package/skills/scholar-thesis-docx/README.md +111 -0
- package/skills/scholar-thesis-docx/README_EN.md +108 -0
- package/skills/scholar-thesis-docx/SKILL.md +212 -0
- package/skills/scholar-thesis-docx/references/failure-patterns-and-quality-gates.md +178 -0
- package/skills/scholar-thesis-docx/references/figure-and-code-rules.md +33 -0
- package/skills/scholar-thesis-docx/references/paper-format-workflow.md +68 -0
- package/skills/scholar-thesis-docx/references/script-usage.md +157 -0
- package/skills/scholar-thesis-docx/scripts/audit_docx_ooxml.py +429 -0
- package/skills/scholar-thesis-docx/scripts/check_word_com.ps1 +50 -0
- package/skills/scholar-thesis-docx/scripts/export_word_pdf.ps1 +62 -0
- package/skills/scholar-thesis-docx/scripts/normalize_word_styles.ps1 +498 -0
- package/skills/scholar-thesis-docx/scripts/render_mermaid_figure.ps1 +148 -0
- package/skills/scholar-writing/SKILL.md +296 -0
- package/skills/security-audit/SKILL.md +244 -0
- package/skills/skill-generator/SKILL.md +472 -0
- package/skills/skill-iter-tune/SKILL.md +382 -0
- package/skills/skill-simplify/SKILL.md +63 -0
- package/skills/skill-tuning/SKILL.md +174 -0
- package/skills/spec-add/SKILL.md +105 -0
- package/skills/spec-load/SKILL.md +98 -0
- package/skills/spec-remove/SKILL.md +74 -0
- package/skills/spec-setup/SKILL.md +75 -0
- package/skills/team-adversarial-swarm/SKILL.md +233 -0
- package/skills/team-adversarial-swarm/scripts/__pycache__/pheromone.cpython-313.pyc +0 -0
- package/skills/team-adversarial-swarm/scripts/__pycache__/scoring.cpython-313.pyc +0 -0
- package/skills/team-adversarial-swarm/scripts/aco.py +473 -0
- package/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
- package/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
- package/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
- package/skills/team-arch-opt/SKILL.md +158 -0
- package/skills/team-brainstorm/SKILL.md +171 -0
- package/skills/team-coordinate/SKILL.md +266 -0
- package/skills/team-designer/SKILL.md +160 -0
- package/skills/team-executor/SKILL.md +189 -0
- package/skills/team-frontend/SKILL.md +136 -0
- package/skills/team-frontend-debug/SKILL.md +198 -0
- package/skills/team-interactive-craft/SKILL.md +141 -0
- package/skills/team-issue/SKILL.md +171 -0
- package/skills/team-lifecycle-v4/SKILL.md +209 -0
- package/skills/team-motion-design/SKILL.md +142 -0
- package/skills/team-perf-opt/SKILL.md +175 -0
- package/skills/team-planex/SKILL.md +137 -0
- package/skills/team-quality-assurance/SKILL.md +147 -0
- package/skills/team-review/SKILL.md +147 -0
- package/skills/team-roadmap-dev/SKILL.md +169 -0
- package/skills/team-swarm/SKILL.md +178 -0
- package/skills/team-swarm/scripts/aco.py +473 -0
- package/skills/team-swarm/scripts/pheromone.py +144 -0
- package/skills/team-swarm/scripts/scoring.py +92 -0
- package/skills/team-swarm/scripts/test_aco.py +475 -0
- package/skills/team-tech-debt/SKILL.md +128 -0
- package/skills/team-testing/SKILL.md +143 -0
- package/skills/team-ui-polish/SKILL.md +141 -0
- package/skills/team-uidesign/SKILL.md +144 -0
- package/skills/team-ultra-analyze/SKILL.md +173 -0
- package/skills/team-ux-improve/SKILL.md +151 -0
- package/skills/team-visual-a11y/SKILL.md +156 -0
- package/skills/workflow-skill-designer/SKILL.md +496 -0
- package/src/extension/index.ts +222 -0
- package/src/extension/schemas.ts +131 -0
- package/src/providers/cli-tools-loader.ts +74 -0
- package/src/providers/provider-registry.ts +130 -0
- package/src/tools/delegate.ts +85 -0
- package/src/tools/explore.ts +134 -0
- package/src/tools/moa.ts +213 -0
- package/src/tools/status.ts +99 -0
- package/src/tools/wait.ts +166 -0
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
# 验证规则
|
|
2
|
+
|
|
3
|
+
本文档详细说明四层验证机制的具体规则和匹配算法。
|
|
4
|
+
|
|
5
|
+
## Layer 1: Format Validation (格式验证)
|
|
6
|
+
|
|
7
|
+
### BibTeX 格式检查
|
|
8
|
+
|
|
9
|
+
**必填字段验证:**
|
|
10
|
+
|
|
11
|
+
不同类型的 BibTeX 条目有不同的必填字段要求:
|
|
12
|
+
|
|
13
|
+
**@article (期刊论文):**
|
|
14
|
+
- 必填: `author`, `title`, `journal`, `year`
|
|
15
|
+
- 可选: `volume`, `number`, `pages`, `doi`
|
|
16
|
+
|
|
17
|
+
**@inproceedings (会议论文):**
|
|
18
|
+
- 必填: `author`, `title`, `booktitle`, `year`
|
|
19
|
+
- 可选: `pages`, `organization`, `doi`
|
|
20
|
+
|
|
21
|
+
**@book (书籍):**
|
|
22
|
+
- 必填: `author` 或 `editor`, `title`, `publisher`, `year`
|
|
23
|
+
- 可选: `volume`, `series`, `address`
|
|
24
|
+
|
|
25
|
+
**@misc (其他):**
|
|
26
|
+
- 必填: `title`
|
|
27
|
+
- 可选: `author`, `howpublished`, `year`, `note`
|
|
28
|
+
|
|
29
|
+
### 格式检查规则
|
|
30
|
+
|
|
31
|
+
**1. 条目结构检查**
|
|
32
|
+
```python
|
|
33
|
+
def check_bibtex_structure(entry):
|
|
34
|
+
"""检查 BibTeX 条目结构"""
|
|
35
|
+
errors = []
|
|
36
|
+
|
|
37
|
+
# 检查是否有类型
|
|
38
|
+
if not entry.get('ENTRYTYPE'):
|
|
39
|
+
errors.append("Missing entry type")
|
|
40
|
+
|
|
41
|
+
# 检查是否有 ID
|
|
42
|
+
if not entry.get('ID'):
|
|
43
|
+
errors.append("Missing citation key")
|
|
44
|
+
|
|
45
|
+
# 检查必填字段
|
|
46
|
+
required = get_required_fields(entry.get('ENTRYTYPE'))
|
|
47
|
+
for field in required:
|
|
48
|
+
if not entry.get(field):
|
|
49
|
+
errors.append(f"Missing required field: {field}")
|
|
50
|
+
|
|
51
|
+
return errors
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**2. 字段格式检查**
|
|
55
|
+
```python
|
|
56
|
+
def check_field_format(entry):
|
|
57
|
+
"""检查字段格式"""
|
|
58
|
+
errors = []
|
|
59
|
+
|
|
60
|
+
# 年份格式检查
|
|
61
|
+
if 'year' in entry:
|
|
62
|
+
year = entry['year']
|
|
63
|
+
if not year.isdigit() or len(year) != 4:
|
|
64
|
+
errors.append(f"Invalid year format: {year}")
|
|
65
|
+
if int(year) < 1900 or int(year) > 2030:
|
|
66
|
+
errors.append(f"Year out of reasonable range: {year}")
|
|
67
|
+
|
|
68
|
+
# DOI 格式检查
|
|
69
|
+
if 'doi' in entry:
|
|
70
|
+
doi = entry['doi']
|
|
71
|
+
if not doi.startswith('10.'):
|
|
72
|
+
errors.append(f"Invalid DOI format: {doi}")
|
|
73
|
+
|
|
74
|
+
return errors
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### LaTeX 引用检查
|
|
78
|
+
|
|
79
|
+
**1. 引用命令检查**
|
|
80
|
+
```python
|
|
81
|
+
def check_latex_citations(tex_content):
|
|
82
|
+
"""检查 LaTeX 引用命令"""
|
|
83
|
+
import re
|
|
84
|
+
|
|
85
|
+
# 查找所有引用命令
|
|
86
|
+
cite_pattern = r'\\cite(?:\[[^\]]*\])?\{([^}]+)\}'
|
|
87
|
+
citations = re.findall(cite_pattern, tex_content)
|
|
88
|
+
|
|
89
|
+
# 展开多个引用
|
|
90
|
+
all_keys = []
|
|
91
|
+
for cite in citations:
|
|
92
|
+
keys = [k.strip() for k in cite.split(',')]
|
|
93
|
+
all_keys.extend(keys)
|
|
94
|
+
|
|
95
|
+
return all_keys
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**2. 引用一致性检查**
|
|
99
|
+
```python
|
|
100
|
+
def check_citation_consistency(tex_keys, bib_keys):
|
|
101
|
+
"""检查引用一致性"""
|
|
102
|
+
tex_set = set(tex_keys)
|
|
103
|
+
bib_set = set(bib_keys)
|
|
104
|
+
|
|
105
|
+
# 未定义的引用
|
|
106
|
+
undefined = tex_set - bib_set
|
|
107
|
+
|
|
108
|
+
# 未使用的引用
|
|
109
|
+
unused = bib_set - tex_set
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
'undefined': list(undefined),
|
|
113
|
+
'unused': list(unused)
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Layer 2: Existence Verification (存在性验证)
|
|
118
|
+
|
|
119
|
+
### API 验证流程
|
|
120
|
+
|
|
121
|
+
**验证步骤:**
|
|
122
|
+
1. 根据引用信息选择 API (DOI -> CrossRef, arXiv ID -> arXiv, 其他 -> Semantic Scholar)
|
|
123
|
+
2. 调用 API 获取论文信息
|
|
124
|
+
3. 判断论文是否存在
|
|
125
|
+
|
|
126
|
+
**验证结果:**
|
|
127
|
+
- `exists` - 论文存在
|
|
128
|
+
- `not_found` - 论文不存在
|
|
129
|
+
- `api_error` - API 调用失败,需要人工验证
|
|
130
|
+
|
|
131
|
+
### 验证代码示例
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
def verify_existence(citation_info):
|
|
135
|
+
"""验证论文存在性"""
|
|
136
|
+
# DOI 优先
|
|
137
|
+
if citation_info.get('doi'):
|
|
138
|
+
result = verify_with_crossref(citation_info['doi'])
|
|
139
|
+
if result['status'] == 'success':
|
|
140
|
+
return {'exists': True, 'source': 'crossref', 'data': result['data']}
|
|
141
|
+
|
|
142
|
+
# arXiv ID
|
|
143
|
+
if citation_info.get('arxiv_id'):
|
|
144
|
+
result = verify_with_arxiv(citation_info['arxiv_id'])
|
|
145
|
+
if result['status'] == 'success':
|
|
146
|
+
return {'exists': True, 'source': 'arxiv', 'data': result['data']}
|
|
147
|
+
|
|
148
|
+
# 通用搜索
|
|
149
|
+
if citation_info.get('title'):
|
|
150
|
+
result = verify_with_semantic_scholar(citation_info['title'])
|
|
151
|
+
if result['status'] == 'success' and result['data']:
|
|
152
|
+
return {'exists': True, 'source': 'semantic_scholar', 'data': result['data']}
|
|
153
|
+
|
|
154
|
+
return {'exists': False, 'source': None}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Layer 3: Information Matching (信息匹配)
|
|
158
|
+
|
|
159
|
+
### 匹配算法
|
|
160
|
+
|
|
161
|
+
**1. 标题匹配**
|
|
162
|
+
|
|
163
|
+
使用模糊匹配算法,允许轻微差异:
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
from difflib import SequenceMatcher
|
|
167
|
+
|
|
168
|
+
def match_title(title1, title2, threshold=0.85):
|
|
169
|
+
"""标题匹配"""
|
|
170
|
+
# 标准化:小写、去除标点
|
|
171
|
+
def normalize(text):
|
|
172
|
+
import re
|
|
173
|
+
text = text.lower()
|
|
174
|
+
text = re.sub(r'[^\w\s]', '', text)
|
|
175
|
+
return ' '.join(text.split())
|
|
176
|
+
|
|
177
|
+
t1 = normalize(title1)
|
|
178
|
+
t2 = normalize(title2)
|
|
179
|
+
|
|
180
|
+
# 计算相似度
|
|
181
|
+
ratio = SequenceMatcher(None, t1, t2).ratio()
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
'match': ratio >= threshold,
|
|
185
|
+
'similarity': ratio
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**2. 作者匹配**
|
|
190
|
+
|
|
191
|
+
考虑作者顺序和名字格式差异:
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
def match_authors(authors1, authors2, threshold=0.7):
|
|
195
|
+
"""作者匹配"""
|
|
196
|
+
def normalize_name(name):
|
|
197
|
+
# 处理 "Last, First" 和 "First Last" 格式
|
|
198
|
+
parts = name.replace(',', '').split()
|
|
199
|
+
return ' '.join(sorted(parts)).lower()
|
|
200
|
+
|
|
201
|
+
names1 = [normalize_name(a) for a in authors1]
|
|
202
|
+
names2 = [normalize_name(a) for a in authors2]
|
|
203
|
+
|
|
204
|
+
# 计算交集比例
|
|
205
|
+
set1 = set(names1)
|
|
206
|
+
set2 = set(names2)
|
|
207
|
+
intersection = len(set1 & set2)
|
|
208
|
+
union = len(set1 | set2)
|
|
209
|
+
|
|
210
|
+
if union == 0:
|
|
211
|
+
return {'match': False, 'similarity': 0}
|
|
212
|
+
|
|
213
|
+
ratio = intersection / union
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
'match': ratio >= threshold,
|
|
217
|
+
'similarity': ratio
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**3. 年份匹配**
|
|
222
|
+
|
|
223
|
+
允许 +/-1 年的差异(考虑预印本和正式发表的时间差):
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
def match_year(year1, year2, tolerance=1):
|
|
227
|
+
"""年份匹配"""
|
|
228
|
+
try:
|
|
229
|
+
y1 = int(year1)
|
|
230
|
+
y2 = int(year2)
|
|
231
|
+
diff = abs(y1 - y2)
|
|
232
|
+
return {
|
|
233
|
+
'match': diff <= tolerance,
|
|
234
|
+
'difference': diff
|
|
235
|
+
}
|
|
236
|
+
except (ValueError, TypeError):
|
|
237
|
+
return {'match': False, 'difference': None}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Layer 4: Content Validation (内容验证)
|
|
241
|
+
|
|
242
|
+
### 综合匹配评分
|
|
243
|
+
|
|
244
|
+
综合所有匹配结果,计算总体匹配分数:
|
|
245
|
+
|
|
246
|
+
```python
|
|
247
|
+
def calculate_match_score(citation, api_data):
|
|
248
|
+
"""计算综合匹配分数"""
|
|
249
|
+
scores = {}
|
|
250
|
+
weights = {
|
|
251
|
+
'title': 0.4,
|
|
252
|
+
'authors': 0.3,
|
|
253
|
+
'year': 0.2,
|
|
254
|
+
'venue': 0.1
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
# 标题匹配
|
|
258
|
+
if citation.get('title') and api_data.get('title'):
|
|
259
|
+
result = match_title(citation['title'], api_data['title'])
|
|
260
|
+
scores['title'] = result['similarity']
|
|
261
|
+
|
|
262
|
+
# 作者匹配
|
|
263
|
+
if citation.get('authors') and api_data.get('authors'):
|
|
264
|
+
result = match_authors(citation['authors'], api_data['authors'])
|
|
265
|
+
scores['authors'] = result['similarity']
|
|
266
|
+
|
|
267
|
+
# 年份匹配
|
|
268
|
+
if citation.get('year') and api_data.get('year'):
|
|
269
|
+
result = match_year(citation['year'], api_data['year'])
|
|
270
|
+
scores['year'] = 1.0 if result['match'] else 0.0
|
|
271
|
+
|
|
272
|
+
# 计算加权总分
|
|
273
|
+
total_score = 0
|
|
274
|
+
total_weight = 0
|
|
275
|
+
for key, weight in weights.items():
|
|
276
|
+
if key in scores:
|
|
277
|
+
total_score += scores[key] * weight
|
|
278
|
+
total_weight += weight
|
|
279
|
+
|
|
280
|
+
if total_weight == 0:
|
|
281
|
+
return 0
|
|
282
|
+
|
|
283
|
+
return total_score / total_weight
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### 验证结果判定
|
|
287
|
+
|
|
288
|
+
根据匹配分数判定验证结果:
|
|
289
|
+
|
|
290
|
+
```python
|
|
291
|
+
def judge_verification_result(match_score):
|
|
292
|
+
"""判定验证结果"""
|
|
293
|
+
if match_score >= 0.9:
|
|
294
|
+
return {
|
|
295
|
+
'status': 'verified',
|
|
296
|
+
'level': 'high_confidence',
|
|
297
|
+
'message': 'Verified - information fully matches'
|
|
298
|
+
}
|
|
299
|
+
elif match_score >= 0.7:
|
|
300
|
+
return {
|
|
301
|
+
'status': 'partial_match',
|
|
302
|
+
'level': 'medium_confidence',
|
|
303
|
+
'message': 'Partial match - minor discrepancies, suggest manual review'
|
|
304
|
+
}
|
|
305
|
+
elif match_score >= 0.5:
|
|
306
|
+
return {
|
|
307
|
+
'status': 'low_match',
|
|
308
|
+
'level': 'low_confidence',
|
|
309
|
+
'message': 'Low match - significant discrepancies, needs manual verification'
|
|
310
|
+
}
|
|
311
|
+
else:
|
|
312
|
+
return {
|
|
313
|
+
'status': 'failed',
|
|
314
|
+
'level': 'no_confidence',
|
|
315
|
+
'message': 'Failed - severe mismatch or paper does not exist'
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## 完整验证流程
|
|
320
|
+
|
|
321
|
+
### 主验证函数
|
|
322
|
+
|
|
323
|
+
```python
|
|
324
|
+
def verify_citation_complete(citation):
|
|
325
|
+
"""完整的引用验证流程"""
|
|
326
|
+
result = {
|
|
327
|
+
'citation_key': citation.get('ID'),
|
|
328
|
+
'layers': {}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
# Layer 1: 格式验证
|
|
332
|
+
format_errors = check_bibtex_structure(citation)
|
|
333
|
+
format_errors.extend(check_field_format(citation))
|
|
334
|
+
result['layers']['format'] = {
|
|
335
|
+
'passed': len(format_errors) == 0,
|
|
336
|
+
'errors': format_errors
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
# Layer 2: 存在性验证
|
|
340
|
+
existence = verify_existence(citation)
|
|
341
|
+
result['layers']['existence'] = existence
|
|
342
|
+
|
|
343
|
+
if not existence['exists']:
|
|
344
|
+
result['final_status'] = 'not_found'
|
|
345
|
+
return result
|
|
346
|
+
|
|
347
|
+
# Layer 3 & 4: 信息匹配和内容验证
|
|
348
|
+
api_data = existence['data']
|
|
349
|
+
match_score = calculate_match_score(citation, api_data)
|
|
350
|
+
judgment = judge_verification_result(match_score)
|
|
351
|
+
|
|
352
|
+
result['layers']['matching'] = {
|
|
353
|
+
'score': match_score,
|
|
354
|
+
'judgment': judgment
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
result['final_status'] = judgment['status']
|
|
358
|
+
result['confidence'] = judgment['level']
|
|
359
|
+
|
|
360
|
+
return result
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
## 验证阈值配置
|
|
364
|
+
|
|
365
|
+
### 可调整的阈值参数
|
|
366
|
+
|
|
367
|
+
```python
|
|
368
|
+
VERIFICATION_THRESHOLDS = {
|
|
369
|
+
# 匹配阈值
|
|
370
|
+
'title_similarity': 0.85, # 标题相似度阈值
|
|
371
|
+
'author_similarity': 0.70, # 作者相似度阈值
|
|
372
|
+
'year_tolerance': 1, # 年份容差
|
|
373
|
+
|
|
374
|
+
# 判定阈值
|
|
375
|
+
'high_confidence': 0.90, # 高置信度阈值
|
|
376
|
+
'medium_confidence': 0.70, # 中等置信度阈值
|
|
377
|
+
'low_confidence': 0.50, # 低置信度阈值
|
|
378
|
+
|
|
379
|
+
# 权重配置
|
|
380
|
+
'weights': {
|
|
381
|
+
'title': 0.4,
|
|
382
|
+
'authors': 0.3,
|
|
383
|
+
'year': 0.2,
|
|
384
|
+
'venue': 0.1
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### 阈值调整建议
|
|
390
|
+
|
|
391
|
+
**严格模式** (用于正式发表):
|
|
392
|
+
- title_similarity: 0.90
|
|
393
|
+
- author_similarity: 0.80
|
|
394
|
+
- high_confidence: 0.95
|
|
395
|
+
|
|
396
|
+
**宽松模式** (用于初稿):
|
|
397
|
+
- title_similarity: 0.80
|
|
398
|
+
- author_similarity: 0.60
|
|
399
|
+
- high_confidence: 0.85
|