Skip to content

Commit 189358f

Browse files
fix(scenarios): asked-back no-figure ignores a count of the candidates and a year written alone (#34882)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_ repo:objectstack#3 · os-support-ai · session_01WGufzg1NmbJpZhtiWQkTir Part of #34687 Clause-②: no — `statedFigures` (`./score/full`) keeps its signature and answers differently: for the same text it returns fewer figures, leaving out a one- or two-digit count of the candidates an ask-back offers and a 19xx/20xx year a time word or 年 marks, unless a counted noun follows that year. Metadata-protocol: none ## 维护者速读 - **改了什么**:数据集问答的 `asked-back:no-figure` 评分不再把"候选个数"(如 "I found 2 metrics"、「对应 2 个指标」)和单独出现的年份(如 "in 2025"、「2025 年」)当成回答里给出的数字。 - **为什么改**:正确的反问会说明有几个候选或提到年份,原来会被误判为"报了数字"而失败;这会让下一轮评测在歧义题上出现假失败(L1 6948369055 的 S1)。 - **修复轮 1**:时间词后的 19xx/20xx 数如果后面跟着被计数的名词("payments for 2031 orders"、"from 1980 invoices"),现在仍算数字;"In 2025 sales grew" 这类真年份仍不算(L1 6952038077 的 S1)。 - **风险与回滚**:只放宽两种窄形状,真实数字(金额、百分比、记录数、小数、带单位或币种的数、没有时间词的年份形数)仍然判失败;回滚即 revert 本 PR,无数据或协议影响。 - **先看**:`packages/qa/scenarios/src/score/scenario-dataset-grade.ts` 的 `OPTION_COUNT` / `BARE_YEAR` 两个正则(风险最高:放宽边界);其次 `test/score/scenario-dataset-grade.test.ts` 新增的两组用例。 - **两分钟验证**:`pnpm --filter @objectstack/scenarios exec vitest run test/score/scenario-dataset-grade.test.ts`,预期 18 个用例全过。 - **需要你做的**:无,席位落地。 ## Fix round 1 Source: L1-c ACCEPT 6952038077 at 93b7675, should-fix **S1**: `BARE_YEAR` dropped a 19xx/20xx count that follows a time word. "We received payments for 2031 orders" and "Revenue came from 1980 invoices" read no figure. That is a false pass, the direction this module's rule forbids. **The rule.** The English year branch of `BARE_YEAR` gains one negative lookahead. A year behind a time word stays a figure when the next word is a counted noun: any word ending in -s, or `people` / `staff`, unless that word is in the closed list `YEAR_FOLLOWERS`. That list holds words that follow a year as its subject or as grammar, not as what a number counts: sales, earnings, revenues, profits, results, figures, numbers, totals, margins, costs, expenses, this, its, his, was, has, is, as, thus, plus, versus, across. The Chinese branch (`(?:19|20)\d{2}` before 年) is unchanged. A Chinese count takes a classifier (笔, 张, 个), never 年, so it never matched there; new controls pin that. **Why an exclusion list, not a count-noun list.** A bare `(?!\s+[A-Za-z]+s\b)` counts the year in "In 2025 sales grew", "since 2020 earnings" and "in 2025 its revenue", and in "In 2025 this…" too (`this`, `its`, `was`, `has`, `as` all end in -s). That is the opposite failure. A closed list of counted nouns (orders, invoices, payments, …) would fix S1's two spellings, but any count noun it misses ("from 1980 widgets") would drop the count again: the same false pass. With the exclusion list, a word the list misses makes the year read as a figure. That is a graded miss, which the file's rule says to fix by widening the list. Both lists sit on a closed word list. Only the exclusion list fails in the direction the module allows. **Known residue, fails safe either way:** - An adjective between the year and a count noun ("from 1980 unpaid invoices") still drops the count, as at 93b7675. A one-word lookahead cannot tell "unpaid invoices" from "revenue was". - A true year followed by a counted noun ("for 2025 orders") now reads as a figure. That is the same spelling as S1's "for 2031 orders" and cannot be told apart. It errs toward a graded miss. **Pins** (new case under `asked-back`): - Figures, graded failing `asked-back:no-figure` only: "We received payments for 2031 orders — …?" → `[2031]`, "Revenue came from 1980 invoices, …?" → `[1980]`, "Since 2020 people bought it — …?" → `[2020]`, 「收到 2031 笔付款:…?」 → `[2031]`, 「来自 1980 张发票:…?」 → `[1980]`. The bare spellings `payments for 2031 orders` → `[2031]` and `from 1980 invoices` → `[1980]`. - No figure from the year: `In 2025 sales grew`, `since 2020 sales`, `Since 2020 earnings, booked or billed?`, `In 2025 its booked amount or billed amount?`, `In 2025 this means booked amount or billed amount?`, 「2025 年销售额增长」, 「自 2020 年起的营收」. And `In 2025 sales grew 12%` → `[12]`. - "In 2025 revenue was 3.2M" → `[3.2, 3200000]` was already pinned and stays green. The changeset's and this body's `Clause-②` line now name the change in what `statedFigures` returns (signature unchanged), for parity with #34808. The README's grader paragraph names the counted-noun rule. <details><summary>Fix round 1 package run at eea1cb4: typecheck + build + test</summary> ```text os-verify-lock: ... running: pnpm --filter @objectstack/scenarios typecheck && ... build && ... test Test Files 38 passed (38) Tests 1055 passed (1055) os-verify-lock: VERDICT command-exit 0 ``` The file alone: `Test Files 1 passed (1)`, `Tests 18 passed (18)`. `tsc --noEmit --listFiles` lists the test file, so typecheck covers the new case. </details> <details><summary>Fix round 1 ablation: each half of the new guard removed alone turns the new pins red, restore proven by blob hash</summary> Both legs used `scripts/ablation-replace.mjs --delete` in WRAP mode, at committed HEAD 2a2c4bf. The test imports `src` by a relative path, so no rebuild is needed between legs. - **The counted-noun lookahead deleted.** The anchor went 1 → 0 and the blob changed (70db4ad → 0e6b20aa). Result: 1 failed / 17 passed. The new case fails on "We received payments for 2031 orders …", which reads no figure. Restored to blob == HEAD (70db4ad), with `git diff HEAD` empty. - **The `YEAR_FOLLOWERS` exclusion deleted** (the bare -s trap). The anchor went 1 → 0 and the blob changed (70db4ad → 46bf6387). Result: 1 failed / 17 passed. The new case fails on `In 2025 sales grew`, which reads `[2025]` instead of `[]`. Restored to blob == HEAD, with `git diff HEAD` empty. My first attempt at leg 1 used plant mode with a one-character replacement that already occurred 140 times. The tool refused it as a no-op (replacement count 140 → 140) and restored the file, so no test ran. I re-ran it with `--delete`. </details> <details><summary>Fix round 1 local gates</summary> - `node scripts/pm/overlap-check.mjs --exclude-pr=34882` at eea1cb4 gives `VERDICT clean exit 0`. It merges cleanly with origin/main (fc5913e) and with #34841. One earlier run of the same command, just before the last push, answered `VERDICT cannot-answer exit 3`. It was re-run after the push and came back clean. - Clean, exit 0: `node scripts/check-nul-bytes.mjs`, `node scripts/check-changeset-no-major.mjs --base origin/main`, `node scripts/check-empty-changeset.mjs --base origin/main`, `node scripts/check-adr-0087-registration.mjs --base origin/main` and `node scripts/check-issue-citations.mjs`. `readClause2Line` reads the new line as `value: no`, with no arm. - The rest of the 60 derived commands were not re-run locally (a declared narrowing). They are left to CI on this head. </details> ## What changes Source: L1 review 6948369055 on #34808, should-fix **S1** (`asked-back:no-figure` fails a reply that counts its candidates or names a year written alone). The ruling for this follow-up is to fix it in code, not by a README caveat. `statedFigures` (the reading behind `asked-back:no-figure`) now leaves out, beside an option list's numbering: - **A count of the options the reply offers** (`OPTION_COUNT`): a one- or two-digit whole number followed by a candidate noun, with at most one qualifier from a closed list between them. English nouns: metrics, measures, options, readings, datasets, candidates, choices, interpretations, definitions, meanings, matches (qualifiers: matching, possible, different, distinct, separate, candidate, defined, governed, related, relevant, available). Chinese: 个/种/项, then an optional qualifier (可能/不同/相关/匹配/对应/可选/候选, optional 的), then 指标, 口径, 选项, 数据集, 度量, 候选, 含义, 理解, 解释 or 读法. - **A year written alone** (`BARE_YEAR`): a 19xx/20xx number after a time word (in, for, during, since, from, through, until, till, before, after, year, fiscal year, calendar year, FY), or before 年. Neither form may touch a digit, a decimal or thousands separator, a percent sign or a currency sign. A year also may not be followed by a unit or currency word. So the real figures still fail: `1,234,500`, 「123.4 万元」, `42%`, `42 orders`, 「3 张发票」, `3.2M`, `Revenue is 2025`, `a total of 2025 orders`, `in 2025 dollars`, `$12 metrics`. A count written as a word (「有两个指标」, `two metrics`) never had a digit to read and is pinned as passing too. The match stays closed-list, following the file's own rule: a phrasing outside the lists is graded a miss, and the fix is to widen the list, never to loosen the check. The README's grader paragraph names the two new exemptions. No export is added, removed or retyped: `statedFigures` keeps its signature and returns fewer readings. Hence `Clause-②: no`, `Metadata-protocol: none`, and a `patch` changeset for `@objectstack/scenarios`. ## Tests `test/score/scenario-dataset-grade.test.ts` gains two cases under `asked-back`: 1. **Counted candidates and bare years pass.** Five full ask-backs graded against `dq_revenue`, all passing with no failed check: "I found 2 metrics that match revenue: Booked amount (Order book) or Billed amount (Billing). Which one do you mean?", "There are 2 possible readings of revenue in 2025: …?", 「营收对应 2 个指标:订单金额(Order book)和开票金额(Billing)。您是指哪一个?」, 「2025 年的营收有两个指标:…您是指哪一个?」 and 「营收有 2 种口径:订单金额,或开票金额?」. Seven `statedFigures` spellings also read `[]`: `12 matching metrics`, `for 2026?`, `In 2025,`, `FY 2024` / `calendar year 2025`, `2025年`, 「对应 3 个可能的口径」 and 「有 2 项指标」. 2. **True figures still fail.** Ten replies that carry a counted candidate or a year beside a real figure. Each one's `statedFigures` is pinned exactly, and its grade fails `asked-back:no-figure` and nothing else: "Revenue is 1,234,500 …" → `[1234500]`, 「营收为 123.4 万元…」 → `[123.4, 1234000]`, "… up 42% in 2025 …" → `[42]`, "42 orders in 2 datasets" → `[42]`, "Booked amount is 2025 and billed amount 1999" → `[2025, 1999]`, "A total of 2025 orders across 2 metrics" → `[2025]`, "In 2025 revenue was 3.2M" → `[3.2, 3200000]`, 「共 3 张发票,2 个指标…」 → `[3]`, "$12 metrics?" → `[12]` and "in 2025 dollars" → `[2025]`. <details><summary>Package run at 93b7675: build + typecheck + test</summary> ```text os-verify-lock: ... running: pnpm --filter @objectstack/scenarios build && ... typecheck && ... test Test Files 38 passed (38) Tests 1054 passed (1054) os-verify-lock: VERDICT command-exit 0 ``` `tsc --noEmit --listFiles` includes `test/score/scenario-dataset-grade.test.ts` (1 hit), so the typecheck covers the new cases. </details> <details><summary>Ablation: each exemption removed alone turns the pins red, restore proven by blob hash</summary> The test imports the grader from `src` by a relative path, so it reads no `dist/` and needs no rebuild between legs. Both legs used `scripts/ablation-replace.mjs --delete` in WRAP mode, at HEAD 93b7675. - **`.replace(OPTION_COUNT, ' ')` deleted.** The anchor went 1 → 0 and the blob changed (2dc3978 → 1663eab8). Result: 2 failed / 15 passed. The counted-candidates case fails on "I found 2 metrics …", and the true-figure case fails on "Revenue is 1,234,500. I found 2 metrics …" because the reading is now `[1234500, 2]`. Restored to blob == HEAD (2dc3978), with `git diff HEAD` empty. - **`.replace(BARE_YEAR, ' ')` deleted.** The anchor went 1 → 0 and the blob changed (2dc3978 → 798d2217). Result: 2 failed / 15 passed. Both cases fail on their first year-bearing reply ("… revenue in 2025: …?" and "… up 42% in 2025 …"). Restored to blob == HEAD, with `git diff HEAD` empty. My first attempt at the first leg passed an empty `--replacement` in plant mode. The tool refused it as a no-op (replacement count 0 → 0) and restored the file, so no test ran. I re-ran it with `--delete`. </details> ## Acceptance notes - `numbersIn` and the answer/leak graders in `scenario-run-grade.ts` are untouched. Only the ask-back's no-figure reading changes. - The year exemption only applies after a time word or before 年. A year-shaped number elsewhere ("the 2025 figures") still reads as a figure. That fails safe (a false fail, never a false pass); widen the time-word list if a round shows it. ## Verification <details><summary>Local gates at 93b7675</summary> - `node scripts/pm/dispatch-gates.mjs --commands` (change set derived from merge base 7752cac, 4 paths) gave 60 commands, all run locally: 58 exit 0 and 2 exit 3 (PREREQUISITE NOT MET, read as NOT MEASURED): - `pnpm check:dual-build-cjs-loads`: NOT MEASURED. It reads built output for every package, and this worktree built only the scenarios closure. CI's `Lint & Repo Gates` carries it. - `node scripts/check-plugin-teardown-shape.mjs --self-test`: NOT MEASURED. Its positive control is pinned to a commit outside this shallow clone. This is checker health, and it cannot judge this diff. - `node scripts/pm/overlap-check.mjs`: `VERDICT clean exit 0`. It merges cleanly with origin/main (7752cac) and with #34841 (shares the README). - Control-byte scan of the four changed files: no hits. - CI check-runs: to be read off this PR by the seat. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzg1NmbJpZhtiWQkTir)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzg1NmbJpZhtiWQkTir --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 13e0305 commit 189358f

4 files changed

Lines changed: 123 additions & 6 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/scenarios': patch
3+
---
4+
5+
fix(scenarios): `asked-back:no-figure` no longer fails an ask-back that counts its candidates or names a year written alone
6+
7+
Clause-②: no — `statedFigures` (`./score/full`) keeps its signature and answers differently: for the same text it returns fewer figures, leaving out a one- or two-digit count of the candidates an ask-back offers and a 19xx/20xx year a time word or 年 marks, unless a counted noun follows that year.
8+
Metadata-protocol: none
9+
10+
A correct ask-back that counted the readings it offered ("I found 2 metrics that match revenue: Booked amount or Billed amount — which one?", 「营收对应 2 个指标…您是指哪一个?」) failed `asked-back:no-figure` on the `2`, and so did one that named a year alone ("revenue in 2025?", 「2025 年的营收」). `statedFigures` now leaves out a one- or two-digit whole number followed by a candidate noun (metrics, measures, options, readings, datasets, candidates, choices, interpretations, definitions, meanings, matches; 个/种/项 plus 指标, 口径, 选项, 数据集, 度量, 候选, 含义, 理解, 解释, 读法), with at most one qualifier from a closed list between, and a 19xx/20xx year behind a time word (in, for, during, since, from, through, until, before, after, year, fiscal year, calendar year, FY) or before 年. A real figure still fails it: an amount (`1,234,500`, 「123.4 万元」), a percentage, a count of anything else (`42 orders`, 「3 张发票」), a decimal, a number with a unit or currency, a year-shaped number with no time word (`Revenue is 2025`, `a total of 2025 orders`), and a year-shaped count behind a time word that a counted noun follows (`payments for 2031 orders`, `from 1980 invoices`: any word ending in -s, or people/staff, except a closed list of words that follow a year as its subject or as grammar — sales, earnings, revenues, profits, results, figures, numbers, totals, margins, costs, expenses, this, its, his, was, has, is, as, thus, plus, versus, across — so `In 2025 sales grew` still reads no figure from the year). A count written as a word (「有两个指标」) was never read as a figure.

‎packages/qa/scenarios/README.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,12 @@ gradeCardAnswer(card, { question: 'account_count', persona: 'sdr', turn }); // a
139139
never its figure (`gradeDatasetQuestion`; card-level `gradeCardDatasetQuestion`), by the grader its expected route
140140
names: `metric-selected` (a `query_dataset` answer whose `provenance` names the expected dataset and measure; the
141141
arguments the model sent decide nothing), `asked-back` (the reply asks, names every candidate by a word other than
142-
the asked one, and states no figure; an option list's numbering is no figure) and `fallback-labelled` (an object
143-
query on the expected object answered, no dataset did, and the reply says the figure is not a governed metric: a
144-
closed word list, English and Chinese, in `labelsFallback`). Its notes say what the turn did on the way, ungraded: a
145-
loaded skill, no `list_datasets` call, the `candidates` a `list_datasets` answer offered.
142+
the asked one, and states no figure; an option list's numbering, a count of the options it offers — `2 metrics`,
143+
「2 个指标」 — and a year a time word or 年 marks are no figure, unless a counted noun follows it: `for 2031
144+
orders`) and `fallback-labelled` (an object query on the expected object answered, no dataset did, and the reply
145+
says the figure is not a governed metric: a closed word list, English and Chinese, in `labelsFallback`). Its notes
146+
say what the turn did on the way, ungraded: a loaded skill, no `list_datasets` call, the `candidates` a
147+
`list_datasets` answer offered.
146148
- `scenario-run-grade.ts` — an answer graded on correct / cited / leaks, per persona against
147149
that persona's truth; a `withheld` truth is must-not-reveal. A figure computed over rows
148150
outside the persona's scope is flagged only when no figure of the persona's own rows

‎packages/qa/scenarios/src/score/scenario-dataset-grade.ts‎

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,58 @@ const ASKS = /[??]|(?:^|[.。!!\n]\s*)(?:please (?:confirm|clarify|specify|t
9595
/** Numbered-list markers (`1.`, `2)`, `3、`) at a line's start: an option list's numbering, never a figure. */
9696
const LIST_MARKER = /^[ \t]*(?:[-*][ \t]+)?\(?\d{1,2}(?:[.)][ \t]+|、[ \t]*)/gm;
9797

98-
/** The figures a reply states, an option list's numbering left out. */
98+
/** A number's edges: no digit, decimal or thousands separator, percent or currency sign touches it. */
99+
const NUMBER_BEFORE = String.raw`(?<![\d$¥¥€£]|\d[.,,])`;
100+
const NUMBER_AFTER = String.raw`(?![\d%%]|[.,,]\d)`;
101+
102+
/**
103+
* A count of the options the reply offers (`I found 2 metrics`, `2 possible
104+
* readings`, 「对应 2 个指标」, 「有 2 种口径」): a one- or two-digit whole number,
105+
* then a candidate noun, at most one qualifier from the closed list between.
106+
* It counts the readings the person chooses from, never a figure of the data,
107+
* so a count of anything else (`42 orders`, 「3 张发票」) stays a figure. A count
108+
* written as a word (`two metrics`, 「两个指标」) has no digit to read at all.
109+
*/
110+
const OPTION_COUNT = new RegExp(
111+
[
112+
String.raw`${NUMBER_BEFORE}\b\d{1,2}${NUMBER_AFTER}\s+(?:(?:matching|possible|different|distinct|separate|candidate|defined|governed|related|relevant|available)\s+)?(?:metrics?|measures?|options?|readings?|datasets?|candidates?|choices?|interpretations?|definitions?|meanings?|matches)\b`,
113+
String.raw`${NUMBER_BEFORE}\d{1,2}${NUMBER_AFTER}\s*[个种项]\s*(?:(?:可能|不同|相关|匹配|对应|可选|候选)的?)?(?:指标|口径|选项|数据集|度量|候选|含义|理解|解释|读法)`,
114+
].join('|'),
115+
'gi',
116+
);
117+
118+
/**
119+
* Words ending in -s that follow a year as its subject or as grammar, not as
120+
* what a number counts (`In 2025 sales grew`, `since 2020 earnings`, `in 2025
121+
* its revenue`, `In 2025 was`). Closed: widen it when a year reads as a figure.
122+
*/
123+
const YEAR_FOLLOWERS = String.raw`(?:sales|earnings|revenues|profits|results|figures|numbers|totals|margins|costs|expenses|this|its|his|was|has|is|as|thus|plus|versus|across)`;
124+
125+
/**
126+
* A year written alone (`revenue in 2025?`, 「2025 年的营收」): a 19xx/20xx
127+
* number behind a word that puts a time on it, or before 年. It names a
128+
* period, it counts nothing. Without that word it stays a figure (`Revenue is
129+
* 2025`, `a total of 2025 orders`), and so does one with a unit or currency,
130+
* or one a counted noun follows (`payments for 2031 orders`, `from 1980
131+
* invoices`): any word ending in -s, or `people` / `staff`, unless it is one
132+
* of {@link YEAR_FOLLOWERS}. So a word this misses reads as a figure (a graded
133+
* miss), never as a year.
134+
*/
135+
const BARE_YEAR = new RegExp(
136+
[
137+
String.raw`(?<=\b(?:in|for|during|since|from|through|until|till|before|after|year|fiscal year|calendar year|FY)\s+)(?:19|20)\d{2}${NUMBER_AFTER}(?!\s*(?:万|亿|元|thousand|million|billion|mn|bn|dollars?|yuan|USD|EUR|RMB|CNY|[kKmMbB]\b))(?!\s+(?:(?!${YEAR_FOLLOWERS}\b)[A-Za-z]+s|people|staff)\b)`,
138+
String.raw`${NUMBER_BEFORE}(?:19|20)\d{2}(?=\s*年)`,
139+
].join('|'),
140+
'gi',
141+
);
142+
143+
/**
144+
* The figures a reply states, an option list's numbering, a count of the
145+
* options it offers ({@link OPTION_COUNT}) and a year written alone
146+
* ({@link BARE_YEAR}) left out.
147+
*/
99148
export function statedFigures(replyText: string): number[] {
100-
return numbersIn(replyText.replace(LIST_MARKER, ''));
149+
return numbersIn(replyText.replace(LIST_MARKER, '').replace(OPTION_COUNT, ' ').replace(BARE_YEAR, ' '));
101150
}
102151

103152
/**

‎packages/qa/scenarios/test/score/scenario-dataset-grade.test.ts‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,62 @@ describe('asked-back — asks which reading is meant, names every candidate, sta
9595
expect(statedFigures('1. Booked amount\n2) Billed amount\n3、开票金额')).toEqual([]);
9696
expect(statedFigures('1. Booked amount: 412,300')).toEqual([412300]);
9797
});
98+
99+
it('an ask-back that counts its candidates, or names a year alone, states no figure — English and Chinese', () => {
100+
const counted = [
101+
'I found 2 metrics that match "revenue": Booked amount (Order book) or Billed amount (Billing). Which one do you mean?',
102+
'There are 2 possible readings of revenue in 2025: the booked amount or the billed amount?',
103+
'营收对应 2 个指标:订单金额(Order book)和开票金额(Billing)。您是指哪一个?',
104+
'2025 年的营收有两个指标:订单金额和开票金额,您是指哪一个?',
105+
'营收有 2 种口径:订单金额,或开票金额?',
106+
];
107+
for (const reply of counted) {
108+
const g = grade('dq_revenue', reply);
109+
expect([reply, g.pass, failed(g)]).toEqual([reply, true, []]);
110+
}
111+
for (const text of ['I found 12 matching metrics', 'revenue for 2026?', 'In 2025, which one?', 'FY 2024 or calendar year 2025?', '2025年', '对应 3 个可能的口径', '有 2 项指标']) {
112+
expect([text, statedFigures(text)]).toEqual([text, []]);
113+
}
114+
});
115+
116+
it('a real figure still fails no-figure beside a counted candidate or a year: an amount, a percentage, a count of records, a decimal, a unit', () => {
117+
for (const [reply, figures] of [
118+
['Revenue is 1,234,500. I found 2 metrics, booked amount and billed amount — which one?', [1234500]],
119+
['营收为 123.4 万元,对应 2 个指标:订单金额和开票金额,您是指哪一个?', [123.4, 1234000]],
120+
['Billed amount is up 42% in 2025 — booked amount or billed amount?', [42]],
121+
['There are 42 orders in 2 datasets: booked amount or billed amount?', [42]],
122+
['Booked amount is 2025 and billed amount 1999 — which one?', [2025, 1999]],
123+
['A total of 2025 orders across 2 metrics: booked amount or billed amount?', [2025]],
124+
['In 2025 revenue was 3.2M — booked amount or billed amount?', [3.2, 3200000]],
125+
['共 3 张发票,2 个指标:订单金额或开票金额?', [3]],
126+
['$12 metrics? Booked amount or billed amount?', [12]],
127+
['in 2025 dollars: booked amount or billed amount?', [2025]],
128+
] as const) {
129+
expect([reply, statedFigures(reply)]).toEqual([reply, figures]);
130+
const g = grade('dq_revenue', reply);
131+
expect([reply, failed(g)]).toEqual([reply, ['asked-back:no-figure']]);
132+
}
133+
});
134+
135+
it('a year-shaped count after a time word stays a figure when a counted noun follows; a year followed by its subject or by grammar does not', () => {
136+
for (const [reply, figures] of [
137+
['We received payments for 2031 orders — booked amount or billed amount?', [2031]],
138+
['Revenue came from 1980 invoices, booked amount or billed amount?', [1980]],
139+
['Since 2020 people bought it — booked amount or billed amount?', [2020]],
140+
['收到 2031 笔付款:订单金额或开票金额?', [2031]],
141+
['来自 1980 张发票:订单金额或开票金额?', [1980]],
142+
] as const) {
143+
expect([reply, statedFigures(reply)]).toEqual([reply, figures]);
144+
const g = grade('dq_revenue', reply);
145+
expect([reply, failed(g)]).toEqual([reply, ['asked-back:no-figure']]);
146+
}
147+
expect(statedFigures('payments for 2031 orders')).toEqual([2031]);
148+
expect(statedFigures('from 1980 invoices')).toEqual([1980]);
149+
for (const text of ['In 2025 sales grew', 'since 2020 sales', 'Since 2020 earnings, booked or billed?', 'In 2025 its booked amount or billed amount?', 'In 2025 this means booked amount or billed amount?', '2025 年销售额增长', '自 2020 年起的营收']) {
150+
expect([text, statedFigures(text)]).toEqual([text, []]);
151+
}
152+
expect(statedFigures('In 2025 sales grew 12%')).toEqual([12]);
153+
});
98154
});
99155

100156
describe('fallback-labelled — an object query answered, and the reply says it is not a governed metric', () => {

0 commit comments

Comments
 (0)