Add the data annotation body (spec 18.8)
A data body says what kind of data a table, figure panel or passage presents: one of fifteen kinds, the dataset that holds the values, what each field measures (with the dataset's own unit) and the molecules and sequences it is about, by the identities of structure and sequence bodies. Where the values came from stays the dataset's origin. - spec/18 section 18.8, the body in annotation.schema.json, 'data' in the store's body_kind CHECK, five terms in the JSON-LD context. - paperspec.data.problems and the rules layer.data.type, layer.data.quantity, layer.data.subject and layer.data.dataset. Units are compared as strings with the dataset's; no unit library is needed. - fixtures/records/data/ (three annotations on the main example) and vectors/data.jsonl (35 cases); paperspec check covers both, and the determinism rebuild matches. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B8cL4zN4XpaQF5cBtASzfq
This commit is contained in:
25 files changed
+670
-33
No files matched your search
@@ -280,6 +280,51 @@ The identity finds the same thing however it was written: the name a model propo
|
||||
The last line is the rule that lets a term cite atoms without a chemistry toolkit: `O([H])[H]` writes three atoms, numbered from 0 as it writes them, and the oxygen (0) is bonded to each hydrogen (1 and 2) and the hydrogens are not bonded to each other, so a bond term on atoms 1 and 2, or an angle on atoms 0, 1 and 2, is refused.
|
||||
[vectors/structures.jsonl](../vectors/structures.jsonl) and [vectors/sequences.jsonl](../vectors/sequences.jsonl) show every rule broken.
|
||||
|
||||
## Find data by its kind and by what it is about
|
||||
|
||||
This shows how a table or a figure panel is tagged with the kind of data it presents, and how that tag is checked against the dataset and found by a molecule.
|
||||
A `data` annotation names the dataset that holds the values, the quantities its fields measure, and the molecules and sequences it is about by the identities that `structure` and `sequence` annotations carry ([chapter 18](../spec/18-layers.md#188-data)).
|
||||
`paperspec.data` checks an annotation against the rules, and against the dataset's descriptor when it is given one, with the standard library alone:
|
||||
|
||||
```python
|
||||
import json
|
||||
from paperspec import data
|
||||
|
||||
descriptors = {}
|
||||
for folder in ("fixtures/packages/hale2026harmonic-damb/datasets/ds-hale-bond-params",
|
||||
"fixtures/records/datasets/ds-hale-ctct-scan"):
|
||||
with open(folder + "/datapackage.json", encoding="utf-8") as f:
|
||||
d = json.load(f)
|
||||
descriptors[d["id"]] = d
|
||||
|
||||
annotations = [json.loads(line) for line in open("fixtures/records/data/annotations.jsonl", encoding="utf-8")]
|
||||
for a in annotations:
|
||||
b = a["body"]
|
||||
quote = a["target"]["selector"][1]["exact"]
|
||||
about = [s["label"] for s in b.get("subjects", [])]
|
||||
print(a["status"], b["role"], b["data_type"], b.get("dataset"), repr(quote), about,
|
||||
data.problems(a, descriptors.get(b.get("dataset"))))
|
||||
|
||||
ethane = "OTMSDBZUPAUEDD-UHFFFAOYSA-N"
|
||||
for a in annotations:
|
||||
b = a["body"]
|
||||
if b["data_type"] == "force-field-parameters" and any(s["identity"] == ethane for s in b.get("subjects", [])):
|
||||
print([(q["name"], q["unit"]) for q in b["quantities"]])
|
||||
```
|
||||
|
||||
```text
|
||||
confirmed reports force-field-parameters ds-hale-bond-params 'Fitted harmonic bond parameters.' ['ethane', 'water', 'CT–CT'] []
|
||||
confirmed reports energy-profile ds-hale-ctct-scan '(a) The scan.' ['ethane'] []
|
||||
proposed uses force-field-parameters ds-hale-bond-params 'Table 1 lists the fitted constants for both parameter sets.' [] []
|
||||
[('harmonic bond force constant', 'kcal / mol / angstrom ** 2'), ('equilibrium bond length', 'angstrom')]
|
||||
```
|
||||
|
||||
Each of the first three lines gives the annotation's status, what its span does with the data, the kind, the dataset, the words, the subjects and the rules it breaks, none here.
|
||||
The caption of Table 1 and the sentence that introduces it lead to one dataset: the caption `reports` it, and the sentence `uses` it and is a model's proposal that a person has not yet confirmed.
|
||||
The subjects are the identities of the chemistry layer, so a search for force-field parameters about ethane, the last line, finds the table by the molecule and not by the word, and gives the units as the dataset spells them.
|
||||
The unit is compared as a string and never parsed, so a checker that wants to know that `kcal / mol / angstrom ** 2` is a force constant needs a unit library of its own.
|
||||
[vectors/data.jsonl](../vectors/data.jsonl) shows every rule broken, among them a quantity whose unit is not its dataset's.
|
||||
|
||||
## Test your implementation against a vector
|
||||
|
||||
A test vector is a recorded input together with the output every correct implementation must produce.
|
||||
|
||||
Reference in new issue
Block a user