What does A Screenshot Is Not a Payment conclude, in numbers, about “A Finite Automaton for Spoken and Written Chinese Amounts, Simplified and Traditional”?

Answer: Spoken amounts do not need an ever-growing pile of rules. A finite-state transducer with 15 states, 9 token classes and 45 transitions covers simplified and traditional script, banker's capitals, spoken cut-offs and mixed Arabic digits, and fails nowhere in an exhaustive round trip over 509,498 texts; whatever the table does not license is refused. Against misheard sound-alike digits, the automaton first removes illegal readings and the pending pool then removes amounts nobody owes, which takes misreadings in the dense pool from 0.0092 down to zero. Yet reading the amount correctly and matching the last five digits only shows that a screenshot appears to belong to an order. The screenshot itself is only a claim. The next chapter sets the floor of write-off: what evidence may make an order "paid", and how a write-off automaton guarantees that no sequence of events can get round that floor.

Scope of the numbers: Orders, account tails, amounts, screenshots and hashes are synthesised from fixed seeds, parameters are illustrative, and every calculation is generated by the book's programs. Marked boxes separate published evidence, runnable Python calculations (20 programs), classical sources and the author's hypotheses.

中文版

Data table

The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 15, 45

caseexpected yuanparsed yuanverdict
13200.003200.00ok
215000.0015000.00ok
3250.00250.00ok
41002.001002.00ok
515.0015.00ok
6110.00110.00ok
710.5010.50ok
83.523.52ok
91.051.05ok
100.500.50ok
110.080.08ok
121200.001200.00ok
1337.5037.50ok
142340.002340.00ok
1510010.0010010.00ok
1615000.0015000.00ok
173.503.50ok
181280.001280.00ok
19299.00299.00ok
20200800.00200800.00ok
21150000000.00150000000.00ok
22456.78456.78ok
23REJECTREJECTok
24REJECTREJECTok
25REJECTREJECTok
26REJECTREJECTok
27REJECTREJECTok
Show the full program
# Chapter 3. p31: a finite-state transducer for spoken and written
# Chinese amounts (simplified, traditional and banker's capitals)
# Model: each character is mapped to a token class (digit, zero,
# small unit, section unit, yuan, jiao, fen, close mark, Arabic
# number); a transition table over 15 states says which class may
# follow which. Registers hold the running sums; the result is in
# fen (1/100 yuan). Colloquial cut-offs are a rule of the table: a
# digit right after a unit u that ends the integer part counts as
# digit * u/10, so the spoken forms of 3,200, 15,000 and 250 parse as
# people mean them. What the table does not license is rejected,
# never guessed. Chinese characters are written as escapes so the
# code stays ASCII; each line's comment shows them. Test phrases are
# illustrative; only their index and parsed value are printed.
from decimal import Decimal
import re

DIG = {}
for chars, v in (("\u4e00\u58f9\u5e7a", 1),          # yi, capital, yao
                 ("\u4e8c\u8d30\u8cb3\u4e24\u5169", 2),  # er, liang
                 ("\u4e09\u53c1\u53c3", 3), ("\u56db\u8086", 4),
                 ("\u4e94\u4f0d", 5), ("\u516d\u9646\u9678", 6),
                 ("\u4e03\u67d2", 7), ("\u516b\u634c", 8),
                 ("\u4e5d\u7396", 9)):
    for c in chars:
        DIG[c] = v
CLS = {c: ("D", v) for c, v in DIG.items()}
for c in "\u96f6\u3007":                              # ling, circle zero
    CLS[c] = ("Z", 0)
for chars, v in (("\u5341\u62fe", 10), ("\u767e\u4f70", 100),
                 ("\u5343\u4edf", 1000)):            # shi, bai, qian
    for c in chars:
        CLS[c] = ("U", v)
for chars, v in (("\u4e07\u842c", 10 ** 4), ("\u4ebf\u5104", 10 ** 8)):
    for c in chars:                                  # wan, yi (1e8)
        CLS[c] = ("W", v)
for c in "\u5143\u5706\u5713\u5757\u584a":           # yuan, kuai
    CLS[c] = ("Y", 0)
for c in "\u89d2\u6bdb":                              # jiao, mao
    CLS[c] = ("J", 0)
CLS["\u5206"] = ("F", 0)                             # fen
for c in "\u6574\u6b63":                              # zheng (close)
    CLS[c] = ("E", 0)
# spaces, commas, currency signs, "renminbi" and "qian" are dropped
FILLER = re.compile("[\\s,\u00a5\uffe5]|\u4eba\u6c11\u5e01|\u94b1")

# state -> token classes it licenses ("$" is the end of input)
TABLE = {
    "S": "DZUA", "D": "UWYJF$", "U": "DZWY$", "Z": "DU$", "W": "DZY$",
    "A": "UWY$", "AU": "Y$", "Y": "DZE$", "YD": "J$", "YZ": "D",
    "YZD": "F$", "J": "DE$", "JD": "F$", "F": "E$", "E": "$",
}


def tokens(text):
    text = FILLER.sub("", text)
    out, i = [], 0
    while i < len(text):
        m = re.match(r"[0-9]+(\.[0-9]+)?", text[i:])
        if m:
            out.append(("A", Decimal(m.group(0))))
            i += len(m.group(0))
        elif text[i] in CLS:
            out.append(CLS[text[i]])
            i += 1
        else:
            return None
    return out


def parse(text):
    """Return the amount in fen, or None if the table rejects it."""
    toks = tokens(text)
    if not toks:
        return None
    st, big, sec, pend, cut, last = "S", 0, 0, None, 0, 10 ** 9
    yuan, jiao, fen = None, 0, 0
    for cls, v in toks + [("$", 0)]:
        if cls == "A" and st in ("Y", "YZ", "J") and v in range(10):
            cls, v = "D", int(v)          # an Arabic jiao or fen digit
        if cls not in TABLE[st]:
            return None
        if cls in "YJF$" and yuan is None and st in "DUWZ":
            if st == "D" and cls in "JF":
                if big or sec:
                    return None           # "11 mao" is ambiguous
                yuan = 0                  # a bare "5 mao" or "8 fen"
            else:
                if st == "D":
                    sec += pend * cut if cut else pend
                yuan, pend = big + sec, None
        if cls == "D":
            if st in ("S", "Z"):
                cut = 0
            pend = v
            st = {"Y": "YD", "YZ": "YZD", "J": "JD"}.get(st, "D")
        elif cls == "Z":
            st, cut = ("YZ" if st == "Y" else "Z"), 0
        elif cls == "U" and st == "A":
            val = pend * v
            if val != int(val):
                return None
            yuan, st = int(val), "AU"
        elif cls == "U":
            if st in ("S", "Z"):
                if v != 10:
                    return None
                pend = 1                  # a leading "shi" means 10
            if v >= last:
                return None
            sec += pend * v
            pend, last, cut, st = None, v, v // 10, "U"
        elif cls == "W" and st == "A":
            val = pend * v
            if val != int(val):
                return None
            yuan, st = int(val), "AU"
        elif cls == "W":
            if st == "D":
                sec += pend
            if sec == 0 and big == 0:
                return None
            big = (big + sec) * v if v > 10 ** 4 else big + sec * v
            sec, pend, last, cut, st = 0, None, 10 ** 9, v // 10, "W"
        elif cls == "A":
            pend, st = v, "A"
        elif cls == "Y":
            if st == "A":
                yuan = pend
            st = "Y"
        elif cls == "J":
            jiao, st = pend, "J"
        elif cls == "F":
            fen, st = pend, "F"
        elif cls == "E":
            st = "E"
        elif st == "YD":
            jiao = pend
        elif st in ("JD", "YZD"):
            fen = pend
        elif st == "A":
            yuan = pend
    total = Decimal(yuan or 0) * 100 + jiao * 10 + fen
    return int(total) if total == int(total) else None


CASES = [
    ("\u4e09\u5343\u4e8c", 320000),                  # san qian er
    ("\u4e00\u4e07\u4e94", 1500000),                 # yi wan wu
    ("\u4e24\u767e\u4e94", 25000),                   # liang bai wu
    ("\u4e00\u5343\u96f6\u4e8c", 100200),            # yi qian ling er
    ("\u5341\u4e94\u5757", 1500),                    # shi wu kuai
    ("\u4e00\u767e\u4e00", 11000),                   # yi bai yi
    ("\u5341\u5757\u4e94", 1050),                    # shi kuai wu
    ("\u4e09\u5757\u4e94\u6bdb\u4e8c", 352),         # 3 kuai 5 mao 2
    ("\u4e00\u5757\u96f6\u4e94", 105),               # 1 kuai ling 5
    ("\u4e94\u6bdb", 50),                            # wu mao
    ("\u516b\u5206", 8),                             # ba fen
    ("\u58f9\u4edf\u8d30\u4f70\u5706\u6574", 120000),  # capitals
    ("\u53c1\u62fe\u67d2\u5713\u4f0d\u89d2", 3750),  # traditional
    ("\u5169\u5343\u4e09\u767e\u56db\u5341\u5143", 234000),
    ("\u4e00\u4e07\u96f6\u4e00\u5341\u5757", 1001000),
    ("1.5\u4e07", 1500000), ("3\u57575", 350),        # mixed digits
    ("\uffe51,280", 128000), ("299\u5143", 29900),
    ("\u4e8c\u5341\u4e07\u96f6\u516b\u767e", 20080000),
    ("\u4e00\u4ebf\u4e94", 15000000000),             # yi yi wu
    ("\u4eba\u6c11\u5e01\u8086\u4f70\u4f0d\u62fe\u9646"
     "\u5143\u67d2\u89d2\u634c\u5206", 45678),       # full capitals
    ("\u4e09\u5757\u4e94\u5757", None),              # two yuan marks
    ("\u4e94\u6bdb\u4e09\u6bdb", None),              # two mao marks
    ("\u767e\u4e94", None),                          # bai without digit
    ("\u4e00\u5341\u767e", None),                    # units rising
    ("\u4e09\u4e94\u767e", None),                    # "300 to 500"
    ("12.345\u5143", None),                          # beyond the fen
]
ok = 0
print("case  expected yuan    parsed yuan  verdict")
for i, (text, want) in enumerate(CASES, 1):
    got = parse(text)
    ok += got == want
    w = "REJECT" if want is None else "%.2f" % (want / 100)
    g = "REJECT" if got is None else "%.2f" % (got / 100)
    print("%4d  %13s  %13s  %s" % (i, w, g,
                                   "ok" if got == want else "FAIL"))
print("states %d, token classes 9, licensed transitions %d"
      % (len(TABLE), len("".join(TABLE.values()))))
print("cases passed: %d of %d" % (ok, len(CASES)))

Single source and citation

Fan, Y. (2026). Fault-Tolerant Parsing of Payment Receipts and Spoken Orders: Last-Five-Digit Write-Off Automata and Blocking Duplicate-Screenshot Fraud (Version 1.0.0), Chapter 3: A Finite Automaton for Spoken and Written Chinese Amounts, Simplified and Traditional. 5D Library. DOI pending

DOI pending · monograph page goes live after publication · 5DL-B-267 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026267,
  author    = {Fan, Yafu},
  title     = {Fault-Tolerant Parsing of Payment Receipts and Spoken Orders: Last-Five-Digit Write-Off Automata and Blocking Duplicate-Screenshot Fraud},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

Other chapter answers in this book