An abstract generator may have several valid counts in the same input. They refer to different stages of a study. Store the denominator with the result that uses it so a wording edit cannot silently switch to another stage.
Constructed input
| Stage | Count |
|---|---|
| Assessed | 140 |
| Enrolled | 120 |
| Included in the follow-up analysis | 111 |
| Events in that analysis | 18 |
The source result is “18 of 111 participants in the follow-up analysis (16.2%).” In this example, “18 of 120 enrolled participants (15.0%)” computes a different quantity. The source gives no outcome for the nine enrollees outside that analysis.
A small guard before accepting a rewritten sentence
The caller supplies the reported numerator and denominator as structured fields, alongside the draft. Compare those fields against the result object before formatting them.
from decimal import Decimal, ROUND_HALF_UP source_result = {"events": 18, "analyzed": 111} def format_verified_result(source, draft_events, draft_denominator): source_events = source["events"] source_denominator = source["analyzed"] if source_denominator <= 0 or not 0 <= source_events <= source_denominator: raise ValueError("invalid source result") if (draft_events, draft_denominator) != (source_events, source_denominator): raise ValueError("draft counts differ from the source analysis") percent = (Decimal(source_events) * 100 / source_denominator).quantize( Decimal("0.1"), rounding=ROUND_HALF_UP ) return f"{source_events}/{source_denominator} ({percent}%)" print(format_verified_result(source_result, 18, 111)) try: format_verified_result(source_result, 18, 120) except ValueError as error: print(error) Output
18/111 (16.2%) draft counts differ from the source analysis Keep the table location next to the source object and ask a reviewer to confirm that the wording still names the follow-up analysis. The check above validates the two supplied fields. It takes a separate comparison with the sentence to verify that the numbers and analysis population appear together in the published text.
The STROBE cohort checklist separately asks authors to report participant counts at different study stages, including follow-up and analysis. STROBE cohort checklist
Constructed example from the RigorMed team.
