跳到正文
DEV Community· bao han·· 2 小時前AI 評分44

RigorMed 團隊:在編輯摘要時核對單位,再檢視句子

A unit audit beside an abstract edit: use Decimal, then review the sentence

AI 導讀

RigorMed 團隊示範以 Python 標準庫 Decimal 編寫窄範圍檢查,核對摘要編輯前後的質量濃度是否相符。示例將 7.5 ng/mL 與 7.5 ug/mL 換算後判定數值不相等,並指出檢查不能判斷生物學、測定方法或文字是否正確。研究者仍須核實語義、相關表格和段落,並由作者作出最終科學及稿件決定。

正文

An abstract editor can preserve a number while changing its unit. A small deterministic check can make that mismatch visible to a research developer. It cannot decide whether the biology, assay or prose is correct.

This is a self-authored teaching input: a source quantity is 7.5 ng/mL. A candidate says 7.5 ug/mL. Here ug is an explicit ASCII spelling for micrograms, not a parser guessing what the author meant. Both denominators are mL.

A deliberately narrow, runnable check

Save this as unit_audit.py and run python3 unit_audit.py. It uses Python's standard-library Decimal with decimal strings, avoiding a binary-float detour for these finite decimal examples. No service, model, patient data or scientific Run is involved.

from decimal import Decimal

# Narrow teaching checker: mass concentration, in ng/mL or ug/mL only.
TO_NG = {"ng/mL": Decimal("1"), "ug/mL": Decimal("1000")}

def compare(source_value, source_unit, candidate_value, candidate_unit):
    left = Decimal(source_value) * TO_NG[source_unit]
    right = Decimal(candidate_value) * TO_NG[candidate_unit]
    return {
        "source_ng_per_mL": str(left),
        "candidate_ng_per_mL": str(right),
        "same_amount": left == right,
    }

print(compare("7.5", "ng/mL", "7.5", "ug/mL"))
print(compare("7.5", "ng/mL", "0.0075", "ug/mL"))

Actual local output:

{'source_ng_per_mL': '7.5', 'candidate_ng_per_mL': '7500.0', 'same_amount': False}
{'source_ng_per_mL': '7.5', 'candidate_ng_per_mL': '7.5000', 'same_amount': True}

The first candidate represents 7,500 ng/mL rather than 7.5. The second represents the same quantity after an explicit conversion. Equality here covers only that mathematical statement. It does not authorize a conversion in a language-only editing task.

Bind the check to the author's material

Keep the authorized source paragraph and the candidate alongside the result. Record which occurrence each quantity belongs to, its comparator and the measurement name. In this toy checker the caller already supplies the mapping; the program does not extract values from prose or discover corresponding sentences.

For example, a source saying “below 7.5 ng/mL” must not silently become “7.5 ng/mL.” Running compare would not see the lost word below because it has no comparator input. Nor would it detect serum becoming plasma, a quantification limit becoming an observed measurement, or a different participant set. Those remain explicit author-review items.

Reject unsupported units instead of guessing. This dictionary does not handle molar concentrations, molecular weights, logarithms, normalized ratios, assay-specific conventions or the full range of Unicode spellings. A real application should start from its actual input contract and method evidence, not expand this two-entry example into a universal scientific validator.

Reviewable output for a writing workflow

Return the source occurrence, candidate occurrence, requested editing scope, this limited check and unresolved semantic questions. The researcher first confirms the measurement and the intended operation, then checks every affected table and paragraph before accepting changed wording. Preserve uncertainty instead of turning a check into a “scientifically approved” badge.

ICMJE asks authors to consult the target journal's unit requirements. That guidance is a reason to make conversion explicit, not to replace symbols without converting values. Its abstract guidance also requires consistency with the article.

We are the RigorMed team. Our research-material handoff starts with an author's existing authorized text, editing constraints and an auditable comparison. This standalone teaching script is not a claim that this exact code is integrated into the product. Model execution follows displayed credits; final scientific and manuscript decisions remain with the author.

https://rigormed.com/en?utm_source=dev&utm_medium=article&utm_campaign=d54_morning_unit_audit

Sources:

All quantities and sentences here are synthetic teaching material. The output above is from the actual local execution of the shown code.

來源:DEV Community · dev.to