Extract shared parsing utilities from DissociationConstantData #10

Open
opened 2026-04-12 16:38:27 -04:00 by aalexmmaldonado · 0 comments
aalexmmaldonado commented 2026-04-12 16:38:27 -04:00 (Migrated from github.com)

Every annotation processor needs to do the same handful of things: pull CID and SID out of an AnnotationEntry, extract the PCLID from a datum, get the string value from StringWithMarkup, parse a temperature like "at 25 °C" or "(25 °C)", and build a DataFrame from a list of TypedDict rows while handling the empty case. Right now, all of that lives as static methods on DissociationConstantData. Adding a second processor means copying them. Adding a third means copying them again.

Scope

Create pcdigitizer/data/base.py (or utils.py) and move these functions into it: extract_ids, extract_pclid, extract_string_value, parse_temperature, and optionally a build_dataframe helper. Refactor DissociationConstantData to import and use them.

This is a pure refactor. No behavior changes, no new features. All existing tests must stay green.

Definition of done

Shared utilities extracted. DissociationConstantData refactored to use them. All tests pass.

Every annotation processor needs to do the same handful of things: pull CID and SID out of an `AnnotationEntry`, extract the PCLID from a datum, get the string value from `StringWithMarkup`, parse a temperature like `"at 25 °C"` or `"(25 °C)"`, and build a DataFrame from a list of `TypedDict` rows while handling the empty case. Right now, all of that lives as static methods on `DissociationConstantData`. Adding a second processor means copying them. Adding a third means copying them again. ### Scope Create `pcdigitizer/data/base.py` (or `utils.py`) and move these functions into it: `extract_ids`, `extract_pclid`, `extract_string_value`, `parse_temperature`, and optionally a `build_dataframe` helper. Refactor `DissociationConstantData` to import and use them. This is a pure refactor. No behavior changes, no new features. All existing tests must stay green. ### Definition of done Shared utilities extracted. `DissociationConstantData` refactored to use them. All tests pass.
Sign in to join this conversation.