fair-ly accurate text synonyms for data cleaning
fairly collapses spelling and format variants of FAIR / DataCite metadata
field values onto a single canonical form — fairly accurately — so that
Univ. of California, Berkeley, University of California-Berkeley and
UC Berkeley all become one publisher/affiliation, while genuinely different
entities (University of Washington vs Washington University) stay apart.
It packages four cooperating strategies, each earning its place against a real failure mode:
| Strategy | What it does | Guards against |
|---|---|---|
| Synonym-lustre | embed distinct values (gte-large) → cluster (HDBSCAN) → map each cluster to its most-frequent member |
spelling/format/punctuation variants |
| Abbreviation holdout | keep acronyms and < 4-char tokens out of clustering |
ZHAW → Z, LUH → HU over-merges |
| ROR authority split | split a cluster that spans two real institutions using a local ROR dump | University of Washington vs Washington University |
| Identity guard | never map a variant to a canonical that drops or adds an identifying word, swaps a place name or number, or leaves only generic words (stopwords, address words, abbreviations and dropped place names don't count) | Library & Researcher Information Services -> Library, Hockaday School -> Hotchkiss School, Ohio State -> Iowa State, Columbia University -> University |
| Geocoding | for place fields, geocode and group by (country, city) → "City, Country"; a result counts only when it is a place the text names, in any country the text names |
Graz merging into Vienna ("city in Austria"), CERN geocoded to Chern, Russia |
| Controlled vocab | for fixed-vocabulary fields (licenses, codes), deterministically fold + alias-resolve to a canonical id | CC-BY-SA collapsing into CC-BY-NC — clustering can't tell them apart |
Quality is measured, not assumed: a V-measure harness tunes the clustering threshold per field against a small gold set.
Method background and per-field recommendations: docs/methods.md.
Install
pip install fair-ly-accurate # core (cleaners, ROR index, I/O, V-measure math)
pip install "fair-ly-accurate[cluster]" # + embeddings & HDBSCAN (semantic clustering)
pip install "fair-ly-accurate[geo]" # + geopy (place geocoding)
pip install "fair-ly-accurate[ror]" # + requests (faster ROR dump auto-download)
pip install "fair-ly-accurate[all]" # everything
(The distribution installs as fair-ly-accurate; the import name is fairly: from fairly import Normalizer.)
The heavy ML/geo dependencies are optional extras, so the deterministic cleaners, ROR index and field-path I/O install light.
Quickstart (CLI)
# 0. (once, for institution fields) build a ROR index.
# --latest auto-downloads the newest ROR v2 dump from Zenodo:
fairly build-ror-index --latest --out ror_index.pickle
# ...or point at a dump you already have:
fairly build-ror-index --dump v2-ror-data.json --out ror_index.pickle
# 1. tune the threshold for a field against a gold set (variant<TAB>true_canonical)
fairly validate --gold affiliation_gold.tsv --preset affiliation --field affiliation
# 2. build + apply a synonym map to a DataCite-shaped field, with review + ROR split
fairly normalize \
--input records.jsonl \
--field-path 'creators[].affiliation[].name' \
--preset affiliation \
--ror-index ror_index.pickle \
--review affiliation_review.tsv \
--output records.normalized.jsonl
The --field-path understands dotted paths through nested dicts and lists, e.g.
publisher.name, fundingReferences[].funderName, subjects[].subject,
creators[].affiliation[].name. Tabular inputs use the column name as the path.
Always eyeball the --review TSV before trusting an apply — especially for
homogeneous fields like funders, where over-merge is easy. Add --dry-run to
build the map and review without writing.
Quickstart (library)
from fairly import Normalizer, get_preset
from fairly.authorities.ror import RorIndex
from fairly.io import collect_counts, read_records, map_values
records = read_records("records.jsonl")
counts = collect_counts(records, "fundingReferences[].funderName")
norm = Normalizer(get_preset("funderName"), cache_dir=".cache")
smap = norm.build(counts, authority=RorIndex.load("ror_index.pickle"))
smap.write_review("funder_review.tsv", counts) # review gate
for rec in records:
map_values(rec, "fundingReferences[].funderName", lambda v: norm.normalize(v, smap))
Text a PDF extraction damaged can be repaired without a model, from the record's own
repository text or from a vocabulary of typed words (fairly.repair):
from fairly.repair import repair_from_reference, repair_ligatures, word_counts
repair_from_reference("Analise epidemiologica das fraturas de fragilidade",
["An\u00e1lise epidemiol\u00f3gica das fraturas de fragilidade"])
# 'Análise epidemiológica das fraturas de fragilidade'
vocab = word_counts(deposit_titles_and_descriptions)
repair_ligatures("Federa\ufffdon University", vocab) # 'Federation University'
The identity guard also works on its own, with place and generic words built from a ROR dump:
from fairly.authorities.ror import identity_words_from_dump
from fairly.identity import changes_identity
place, generic = identity_words_from_dump("v2-ror-data.json")
changes_identity("Ohio State University", "Iowa State University", place, generic) # True
changes_identity("University of Antwerp, Antwerp, Belgium", "University of Antwerp",
place, generic) # False
Field presets
Built-in FieldConfig presets for common DataCite/FAIR fields (fairly presets):
| Field | Strategy | eps | Holdout | Authority |
|---|---|---|---|---|
publisher |
semantic | 0.30 | yes | ROR |
funderName |
semantic | 0.07 | yes | ROR |
affiliation |
semantic | 0.07 | yes | ROR |
subject |
semantic | 0.10 | yes | — |
rights |
controlled | — | — | SPDX/CC vocab |
geoLocationPlace |
geocode | — | — | — |
These eps values are V-measure validated against the curated gold sets in
gold/ — each sits on its field's optimal plateau (funder/subject 1.00,
publisher 0.99, affiliation 0.96; rights 0.82, so prefer a controlled vocabulary
for licenses). Re-tune for your data with fairly validate — see
docs/methods.md for the full sweep and why
each field wants a different threshold.
Why these choices
- Most-frequent canonical gives clean, recognizable labels (the common form wins), with centroid-closeness only breaking ties.
- Holdout exists because short/all-caps tokens carry too little signal for an embedding to place; left in, they become spurious join keys.
- Authority split is what lets us cluster aggressively for coverage without paying for it in precision: the embedding proposes merges, ROR/geocoding vetoes the wrong ones.
- V-measure turns "did we over-merge?" into a number: homogeneity penalizes over-merge (the costly direction), completeness penalizes under-merge.
License
MIT — see LICENSE.
Metadata
Release files for fair-ly-accurate 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fair_ly_accurate-0.6.0.tar.gz | 77.6 kB | With provenance | Details for fair_ly_accurate-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fair_ly_accurate-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for fair_ly_accurate-0.6.0-py3-none-any.whl |
Total release size: 134.1 kB
Release files / fair_ly_accurate-0.6.0.tar.gz
| Download URL | fair_ly_accurate-0.6.0.tar.gz |
|---|---|
| Size | 77.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
38cb76f5924097af897243a21a6396aaf4619808f4598a47643cda3d148d9813
|
|
BLAKE2b-256 checksum How to use checksums |
e7c560f0af044ab81b8f307472560a23436c8c2c9f68f317fff4c0bb007d222b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logRelease files / fair_ly_accurate-0.6.0-py3-none-any.whl
| Download URL | fair_ly_accurate-0.6.0-py3-none-any.whl |
|---|---|
| Size | 56.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b950ef19be67980f646bd1cab7304eccfdfbb8bce2a08d4a7a9b48f43e23a529
|
|
BLAKE2b-256 checksum How to use checksums |
aade534dbc4b1d2dda1e129e51fc9159cbd060ee8ccb2dce8e924cfd54437362
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logSecurity for fair-ly-accurate 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for fair_ly_accurate-0.6.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.