Skip to main content

Offline typed reference for the Kazakhstan OKED classifier (NK RK 03-2019)

Project description

metrix-oked

Typed offline reference for the Kazakhstan OKED classifier — НК РК 03-2019 (amendments № 1–3).

The full classifier (2097 entries) is bundled as package data: no external APIs, no network calls at runtime. Data is loaded lazily once per process, loading is thread-safe, all objects are immutable.

Installation

pip install metrix-oked-sdk

Quick start

from metrix_oked import Oked

oked = Oked()

entry = oked.get("01.19.9")  # dots are normalized: same as oked.get("01199")
print(entry.name)   # Выращивание прочих одно- или двухлетних культур, ...
print(entry.label)  # 01199 - Выращивание прочих одно- или двухлетних культур, ...

# Autocomplete
for entry in oked.search("разработка", limit=5):
    print(entry.label)

# Code prefix search
oked.search("01")  # subclasses 01111, 01112, ... in code order

Code levels

Level Level member Code format Example Count
Секция Level.SECTION letter A 21
Раздел Level.DIVISION 2 digits 01 88
Группа Level.GROUP 3 digits 011 272
Класс Level.CLASS 4 digits 0111 614
Подкласс Level.SUBCLASS 5 digits 01111 1102

API

oked.get(code) -> OkedEntry

Exact lookup by a code of any level. Dots and case are normalized ("01.19.9""01199", "a""A"). Raises OkedNotFoundError for unknown codes.

oked.get("A")        # OkedEntry(code="A", level=Level.SECTION, ...)
oked.get("01.19.9")  # OkedEntry(code="01199", level=Level.SUBCLASS, ...)

oked.get_or_none(code) -> OkedEntry | None

Same as get, but returns None instead of raising.

oked.get_name(code) -> str / oked.get_label(code) -> str

Shortcuts for the entry name / the "code - name" string.

oked.get_name("01111")   # "Выращивание зерновых и зернобобовых культур, ..."
oked.get_label("01111")  # "01111 - Выращивание зерновых и зернобобовых культур, ..."

oked.search(query, *, limit=20, levels=(Level.SUBCLASS,)) -> list[OkedEntry]

Autocomplete search:

  • a query of digits/dots is a code prefix search ("01", "01.19"), results in code order;
  • anything else is a case-insensitive substring search over names (cyrillic-aware); matches at a word boundary rank first, ties are ordered by code.
oked.search("разработка")                          # 08121, 41100, ...
oked.search("01", limit=5)                         # first five 01xxx subclasses
oked.search("сельское", levels=(Level.SECTION,))   # search sections only

oked.parents(code) -> list[OkedEntry]

Ancestors chain, from the immediate parent up to the section.

[e.code for e in oked.parents("01111")]  # ["0111", "011", "01", "A"]

oked.children(code) -> list[OkedEntry]

Direct descendants, in code order.

[e.code for e in oked.children("011")]  # ["0111", "0112", ...]

oked.is_valid(code) -> bool

oked.is_valid("01.19.9")  # True
oked.is_valid("99999")    # False

Error handling

from metrix_oked import OkedError, OkedNotFoundError

try:
    oked.get("99999")
except OkedNotFoundError as e:
    print(e.code)  # "99999"

Requirements

  • Python 3.12+
  • No runtime dependencies

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

metrix_oked_sdk-0.1.0.tar.gz (287.3 kB view details)

Uploaded Source

Built Distribution

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

metrix_oked_sdk-0.1.0-py3-none-any.whl (276.5 kB view details)

Uploaded Python 3

File details

Details for the file metrix_oked_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: metrix_oked_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 287.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for metrix_oked_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6fbfe719cc751ebaa9971ed1099ea88d16e83fcc33e66e295549e58b8cf9fd6f
MD5 fb9e7def62c507cd60c5a1034901219c
BLAKE2b-256 e8ace1ec3fd2f9915e19dc4f3d5257fecadd3f5df5abb2b69999f702a38b637b

See more details on using hashes here.

File details

Details for the file metrix_oked_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: metrix_oked_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 276.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for metrix_oked_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1185f36810072dca08e0a7c3020d2e7c9d29633ac2be1e6bc4abcc2d7536b0a
MD5 a4767ac5f3f55bd4d37a3c3590c587e6
BLAKE2b-256 db29fc951e4cf16c76a38fc8913bd000817dc21ccfa08c59e7fe7341e4ec370c

See more details on using hashes here.

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