tz / kkndme /frontend /src /lib /kkText.ts
Ethscriptions's picture
Add kkndme 论房价 project source (in kkndme/)
95ab2cb verified
Raw History Blame Contribute Delete
5.87 kB
/* 文字版:把 kkndme 的理论框架与预测核对整理成可直接阅读 / 复制 / 下载的纯文本 */
import { predictions } from '../data/predictions'
import { theories } from '../data/theories'
import type { Prediction, Status, Theory } from '../data/types'
import { outlookText } from '../data/outlook'
export const CHECK_DATE = '2026年10月29日'
export const STATUS_TEXT: Record<Status, string> = {
correct: '预测正确',
wrong: '预测错误',
disputed: '存疑 / 一半对一半错',
pending_lean: '未到期 · 目前偏向 kkndme',
pending_against: '未到期 · 目前不偏向 kkndme',
pending_neutral: '未到期 · 暂无倾向',
}
const uniq = (xs: string[]) => xs.filter((x, i) => xs.indexOf(x) === i)
export const theoryGroups = uniq(theories.map((t) => t.group)).map((g) => ({
name: g,
items: theories.filter((t) => t.group === g),
}))
export const predTopics = uniq(predictions.map((p) => p.topic)).map((g) => ({
name: g,
items: predictions.filter((p) => p.topic === g),
}))
export function stats() {
const n = predictions.length
const c = (f: (p: Prediction) => boolean) => predictions.filter(f).length
const correct = c((p) => p.status === 'correct')
const wrong = c((p) => p.status === 'wrong')
const disputed = c((p) => p.status === 'disputed')
const pending = c((p) => p.status.startsWith('pending'))
const due = correct + wrong + disputed
const pct = (a: number, b: number) => (b ? Math.round((a / b) * 100) : 0)
return {
n, correct, wrong, disputed, pending, due,
hit: pct(correct, correct + wrong), // 只算能分对错的
half: pct(correct + disputed / 2, due), // 存疑算半分
strict: pct(correct, due), // 存疑一律当错
}
}
/** 去掉引号外多余空白,统一成单行 */
const one = (s: string) => s.replace(/\s+/g, ' ').trim()
export function theoryText(t: Theory, md: boolean): string {
const L: string[] = []
L.push(md ? `### ${t.id} ${t.title}` : `【${t.id}】${t.title}`)
L.push(`${md ? '- **观点**:' : ' 观点:'}${one(t.summary)}`)
L.push(`${md ? '- **原话**:' : ' 原话:'}${one(t.quote)}(${t.ref})`)
if (t.hindsight) L.push(`${md ? '- **15 年后回头看**:' : ' 15 年后回头看:'}${one(t.hindsight)}`)
return L.join('\n')
}
export function predText(p: Prediction, md: boolean): string {
const L: string[] = []
L.push(md ? `### ${p.id} ${p.title}【${STATUS_TEXT[p.status]}】` : `【${p.id}】${p.title} —— ${STATUS_TEXT[p.status]}`)
const k = (s: string) => (md ? `- **${s}**:` : ` ${s}:`)
L.push(`${k('原话')}${one(p.quote)}`)
L.push(`${k('意思')}${one(p.claim)}`)
L.push(`${k('出处')}${p.ref};发帖 ${p.posted};预测期限 ${p.horizon}`)
L.push(`${k('核对结论')}${one(p.verdict)}`)
if (p.evidence.length) {
L.push(`${k('依据')}`)
p.evidence.forEach((e, i) => L.push(md ? ` ${i + 1}. ${one(e.text)}(${e.source})` : ` ${i + 1}. ${one(e.text)}(${e.source})`))
}
return L.join('\n')
}
export function buildText(md: boolean): string {
const s = stats()
const H1 = (x: string) => (md ? `# ${x}` : `${x}\n${'='.repeat(32)}`)
const H2 = (x: string) => (md ? `## ${x}` : `\n${x}\n${'-'.repeat(32)}`)
const out: string[] = []
out.push(H1('kkndme《论房价》理论与预测 · 文字版'))
out.push(
[
`2010–2011 年,网友 kkndme 在论坛房产版连载长帖《把脉中国房价的那些事》,从收入结构、城市化、货币与土地讲中国房价。`,
`本文通读原帖(480 页)和网友整理的合集(506 页),整理出 kkndme 本人的 ${theories.length} 条核心理论、${s.n} 条可核对的预测,并逐条用公开新闻和官方数据核对,核对截至 ${CHECK_DATE};最后附 AI 按他的理论框架对未来房价的推演。`,
``,
`总账:${s.n} 条预测中,已到期 ${s.due} 条——说中 ${s.correct} 条、没说中 ${s.wrong} 条、存疑 ${s.disputed} 条;还没到时间 ${s.pending} 条。`,
`命中率:只算能分对错的 ${s.correct + s.wrong} 条是 ${s.hit}%;存疑算半分约 ${s.half}%;存疑一律当错(最严格)约 ${s.strict}%。`,
`说明:前两部分仅做历史言论的事实核对;第三部分为 AI 推演。全部内容均不构成任何买房或投资建议。`,
].join('\n'),
)
out.push(H2(`第一部分 · 理论框架(${theories.length} 条)`))
theoryGroups.forEach((g, gi) => {
out.push(md ? `\n#### ${gi + 1}. ${g.name}(${g.items.length} 条)\n` : `\n〔${gi + 1}. ${g.name} · ${g.items.length} 条〕\n`)
g.items.forEach((t) => out.push(theoryText(t, md) + '\n'))
})
out.push(H2(`第二部分 · 预测与核对(${s.n} 条)`))
predTopics.forEach((g, gi) => {
const ok = g.items.filter((p) => p.status === 'correct').length
const no = g.items.filter((p) => p.status === 'wrong').length
out.push(md ? `\n#### ${gi + 1}. ${g.name}(${g.items.length} 条 · 说中 ${ok} · 没说中 ${no})\n` : `\n〔${gi + 1}. ${g.name} · ${g.items.length} 条 · 说中 ${ok} · 没说中 ${no}〕\n`)
g.items.forEach((p) => out.push(predText(p, md) + '\n'))
})
out.push(H2('第三部分 · AI 推演:按理论框架看未来房价(不构成投资建议)'))
out.push(outlookText(md))
out.push(H2('判定标准'))
out.push(
[
'预测正确:时间已到,结果和 kkndme 说的一致。',
'预测错误:时间已到,结果和 kkndme 说的相反或明显不符。',
'存疑:说法太模糊、口径不同,或一半对一半错。',
'未到期:预测期限还没到,按目前走势标注“偏向 / 不偏向 / 暂无倾向”。',
]
.map((x) => (md ? `- ${x}` : ` · ${x}`))
.join('\n'),
)
return out.join('\n\n').replace(/\n{3,}/g, '\n\n') + '\n'
}