Skip to main content

Free Decimal Classification lookup library

Project description

fdc — Free Decimal Classification

A Python library for looking up Free Decimal Classification codes. Built from the FDC correspondence file.

Quick start

from fdc import Label

label = Label.parse("976.4")
label.best   # '"Texas"'

for layer in label.layers:
    print(f"{layer.code}: {layer.label}")

# 9: History & geography
# 970: "America" + "North America"
# 976: "Gulf States" + "Southwest, Old"
# 976.4: "Texas"

Use .best to get the most specific resolved label without walking layers:

label = Label.parse("999.9")
label.best   # '"Outer Space"'  (last resolved layer)
label.layers[-1].label  # None (no entry for this exact code)

Pass raise_on_error=True for strict mode:

from fdc import Label
from fdc.label import LabelError

try:
    Label.parse("999.9", raise_on_error=True)
except LabelError:
    pass  # no entry for this code

Installing from PyPI

pip install free-decimal-correspondence

The package ships with a pre-built lookup table (fdc/_table.py) so parsing is never needed at runtime. The table is loaded into memory the first time you call Label.parse() - after that, lookups take roughly two microseconds.

Contributing

The taxonomy data lives in the classification/ submodule. If you improve it, rebuild the lookup table before committing:

python -m fdc.build

This regenerates fdc/_table.py from the text file. Commit both the submodule change and the regenerated table.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

free_decimal_correspondence-0.1.2.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

free_decimal_correspondence-0.1.2-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file free_decimal_correspondence-0.1.2.tar.gz.

File metadata

File hashes

Hashes for free_decimal_correspondence-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ecf85b0c5caec779362a0f9690e36541718f52eabaeaf378427ca07a52985e76
MD5 05613ede25ff3b8d89335b522ca83e94
BLAKE2b-256 0b6fc41c1841921fd23bd7ac6da8f92ceb6dc13dfb6350273e5b255daca0cc75

See more details on using hashes here.

Provenance

The following attestation bundles were made for free_decimal_correspondence-0.1.2.tar.gz:

Publisher: publish.yml on thien/fdc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file free_decimal_correspondence-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for free_decimal_correspondence-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 029b7a59bd53a7b9b75f920badada7b1eefaa82e0cf09f8f4ef1db755b58f157
MD5 3d7df43749d6c2118adc971bd9be1b30
BLAKE2b-256 fa09e2081b2231e259d04c8c6a491304d5eb3bdb09e93c6bd0fea059b70e080a

See more details on using hashes here.

Provenance

The following attestation bundles were made for free_decimal_correspondence-0.1.2-py3-none-any.whl:

Publisher: publish.yml on thien/fdc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page