返回 oh-my-ppt
content-credibility.ts
根目录 / src / main / thinking / content-credibility.ts
1 export interface CredibilityIssue {
2 line: number
3 text: string
4 reason: string
5 }
6
7 const BENCHMARK_PATTERN = /\b(MMLU|HumanEval|MT-Bench|SWE-bench|GSM8K|GPQA|BIG-bench)\b/i
8 const METRIC_WORD_PATTERN =
9 /成本|价格|准确率|召回率|错误率|幻觉|提升|下降|降低|缩短|节省|突破|达到|保持|超过|优化|损失|参数|token|fps|benchmark|score|accuracy|cost|latency|throughput/i
10 const EXACT_VALUE_PATTERN =
11 /(?:[$¥]\s*\d|\d+(?:\.\d+)?\s*(?:%|美元|元|倍|fps|K|M|B|T|万|亿|千亿|万亿|token|tokens?)|\b\d+(?:\.\d+)?\s*(?:->|→|至|-)\s*\d+(?:\.\d+)?)/i
12
13 export function findUnsupportedPrecisionClaims(args: {
14 markdown: string
15 hasSources: boolean
16 }): CredibilityIssue[] {
17 if (args.hasSources) return []
18
19 const issues: CredibilityIssue[] = []
20 const lines = args.markdown.split('\n')
21
22 lines.forEach((line, index) => {
23 const text = line.trim()
24 if (!text || isAllowedStructuralNumber(text)) return
25
26 const hasExactValue = EXACT_VALUE_PATTERN.test(text)
27 const hasBenchmark = BENCHMARK_PATTERN.test(text) && /\d/.test(text)
28 const hasMetricWord = METRIC_WORD_PATTERN.test(text)
29
30 if ((hasExactValue && hasMetricWord) || hasBenchmark) {
31 issues.push({
32 line: index + 1,
33 text,
34 reason: hasBenchmark
35 ? 'benchmark score without source support'
36 : 'exact metric without source support'
37 })
38 }
39 })
40
41 return issues
42 }
43
44 function isAllowedStructuralNumber(text: string): boolean {
45 return (
46 /^##\s*Page\s+\d+\s*:/.test(text) ||
47 /^##\s*Page Count$/i.test(text) ||
48 /^\d+$/.test(text) ||
49 /时长|分钟|页|页面数|Page Count/i.test(text)
50 )
51 }
52
52 lines TYPESCRIPT