关于「节律重构:只动句读的动态规划与具身细节账本」,《机器文气与句长节律》给出的定量结论是什么?

结论:改稿的第一条约束是事实不动。p61 用手写的编辑距离把这条约束变成可检验的量:内容距离为零,才算纯节律修改;不为零,就要核对进出的字词。p62 用动态规划在这条约束下找改动最少的方案,草稿的变异系数从 0.123 升到 0.546 只需 5 处改动;同时暴露出目标函数会把对比推到极致的问题。p63 给细节建账,数字与专名必须有记录,感官词交人工确认。

数据口径:书中示例均为作者自写的合成文字或公有领域文本,参数为示意,全部计算由书中程序生成。 第一至六章依次讲句长指纹与对数正态、突发度与顺序量、检测器的贝叶斯账与偏差、套话密度的泊松检验与群体超额词汇、三元连发与压缩冗余、只动句读的动态规划与真实细节账本:合成草稿只改 5 处句读,变异系数就从 0.123 升到 0.546,而字词一个不动。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 0.123, 0.546

draftedits0n 10CV 0.123B -0.780r1 -0.455flat 0.889
lam 1.00 edits3n7CV 0.406B -0.423r1 -0.835flat 0.000 -
lam 0.50 edits3n7CV 0.406B -0.423r1 -0.835flat 0.000 -
lam 0.30 edits5n7CV 0.546B -0.294r1 -0.846flat 0.000 in band
lam 0.20 edits5n7CV 0.546B -0.294r1 -0.846flat 0.000 in band
lam 0.10 edits5n7CV 0.546B -0.294r1 -0.846flat 0.000 in band
lengths at lam 0.50: [16, 33, 19, 34, 13, 39, 16]
lengths at lam 0.10: [16, 44, 8, 34, 13, 39, 16]
查看完整验算程序
# Chapter 6. p62: re-segment clauses by dynamic programming.
# A draft is a fixed sequence of clauses (lengths in hanzi, SYNTHETIC,
# author-made); a sentence is a run of 1 to 5 consecutive clauses and
# at most 60 hanzi. Words never change, only where sentences end.
# Cost of a segmentation = lam * (sentence ends added or removed
# against the draft) + contrast deficit, summed over neighbour pairs:
# max(0, ln 2.5 - |ln(a / b)|). DP state: the last sentence, as
# (start, end). A pair is "flat" when its ratio is within 1.5. For each
# lam the optimum is reported with CV, B, r1 and the flat share; the
# target band (illustrative) is CV >= 0.45 and flat share <= 0.30.
import math

CL = [7, 9, 8, 10, 6, 9, 11, 8, 7, 10, 9, 8, 6, 7, 12, 9, 8, 10, 7, 9]
N = len(CL)
ORIG_ENDS = set(range(2, N + 1, 2))        # draft: two clauses a sentence
PRE = [0]
for c in CL:
    PRE.append(PRE[-1] + c)


def slen(i, k):
    return PRE[k] - PRE[i]


def flat(a, b):
    return abs(math.log(a / b)) < math.log(1.5)


def deficit(a, b):
    return max(0.0, math.log(2.5) - abs(math.log(a / b)))


def edits(i, k):
    e = len([b for b in range(i + 1, k) if b in ORIG_ENDS])
    return e + (0 if k in ORIG_ENDS else 1)


def ok(i, k):
    return 1 <= k - i <= 5 and slen(i, k) <= 60


def solve(lam):
    best = {}
    for k in range(1, N + 1):
        if ok(0, k):
            best[(0, k)] = (lam * edits(0, k), None)
    for i in range(1, N):
        for k in range(i + 1, N + 1):
            if not ok(i, k):
                continue
            cand = None
            for j in range(max(0, i - 5), i):
                if (j, i) not in best:
                    continue
                c = best[(j, i)][0] + lam * edits(i, k) + \
                    deficit(slen(j, i), slen(i, k))
                if cand is None or c < cand[0]:
                    cand = (c, (j, i))
            if cand is not None:
                best[(i, k)] = cand
    end = min((v[0], key) for key, v in best.items() if key[1] == N)
    segs, key = [], end[1]
    while key is not None:
        segs.append(key)
        key = best[key][1]
    return [slen(i, k) for i, k in reversed(segs)], \
        [k for _, k in reversed(segs)]


def measures(xs):
    n = len(xs)
    m = math.fsum(xs) / n
    den = math.fsum((x - m) ** 2 for x in xs)
    sd = math.sqrt(den / n)
    r1 = math.fsum((xs[i] - m) * (xs[i + 1] - m)
                   for i in range(n - 1)) / den
    fl = len([1 for i in range(n - 1) if flat(xs[i], xs[i + 1])])
    return sd / m, (sd - m) / (sd + m), r1, fl / (n - 1)


draft = [slen(k - 2, k) for k in sorted(ORIG_ENDS)]
cv, b, r1, fs = measures(draft)
print("draft    edits  0  n {:>2}  CV {:.3f}  B {:.3f}  r1 {:>6.3f}"
      "  flat {:.3f}".format(len(draft), cv, b, r1, fs))
for lam in (1.0, 0.5, 0.3, 0.2, 0.1):
    xs, ends = solve(lam)
    e = len(set(ends) ^ ORIG_ENDS)
    cv, b, r1, fs = measures(xs)
    hit = "in band" if cv >= 0.45 and fs <= 0.30 else "-"
    print("lam {:.2f} edits {:>2}  n {:>2}  CV {:.3f}  B {:.3f}"
          "  r1 {:>6.3f}  flat {:.3f} {}".format(
              lam, e, len(xs), cv, b, r1, fs, hit))
for lam in (0.5, 0.1):
    print("lengths at lam {:.2f}:".format(lam), solve(lam)[0])

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《机器生成文本统计指纹剥离、句长突发律动重构与宗师级文气呼吸感母典》第 6 章「节律重构:只动句读的动态规划与具身细节账本」(版本 1.0.0). 5D Library. DOI 待发布

DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-394 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026394,
  author    = {Fan, Yafu},
  title     = {Stripping Statistical Fingerprints of Machine Prose, Sentence-Length Burstiness Reconstruction and Master-Level Stylistic Cadence},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

本书其他章节结论