Skip to main content

Python API for the Turkish Language Foundation

Project description

tdk-py

Python API for the Turkish Language Foundation

Latest version on PyPI Supported Python versions

Codacy Grade Badge Codacy Coverage Badge checks/master docs


tdk-py is a Python package allowing access to Turkish dictionaries of the TDK, the Turkish Language Association.

tdk-py provides both synchronous and asynchronous interfaces to the TDK's APIs and parses their responses into Python class objects based on Pydantic, so you can do things like .model_dump_json() them, or use them in your API endpoints and generate beautiful schemas.

Quick start

tdk-py is supported on Python 3.10+. First, make sure you have a Python environment set up.

# in the shell
poetry add tdk-py      # if using python-poetry.org (recommended)
pipenv install tdk-py  # if using pipenv.pypa.io
pip install tdk-py     # straight pip.pypa.io
# in Python
import tdk

Examples

import tdk

results = tdk.search_gts_sync("merkeziyetçilik")
print(results[0].meanings[0].meaning)
Otoritenin ve işin tek bir merkezde toplanmasını amaçlayan görüş; merkeziyet, merkezcilik

You can query suggestions for misspelt words or for other similar words.

from difflib import get_close_matches
import tdk

# Calculate suggestions locally using the index:
words = get_close_matches("feldispat", tdk.get_gts_index_sync())
assert words == ['feldspat', 'ispat', 'fesat']

# Use the TDK API: (sometimes errors out)
words = tdk.get_gts_suggestions_sync("feldispat")
assert words == ['feldspat', 'felekiyat', 'ispat']

You can perform complex analyses very easily. Let's see the distribution of entries by the number of maximum consecutive consonants.

import tdk

annotated_dict = {}
for entry in tdk.get_gts_index_sync():
    streaks = tdk.tools.max_streak(entry)
    if streaks not in annotated_dict:
        annotated_dict[streaks] = [entry]
    else:
        annotated_dict[streaks].append(entry)
for i in set(annotated_dict):
    print(i, len(annotated_dict[i]))
0 19
1 15199
2 73511
3 3605
4 68
5 5

License

tdk-py's source code is provided under the MIT License

Copyright © 2021-2025 Emre Özcan

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

tdk_py-2.0.0.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

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

tdk_py-2.0.0-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

Details for the file tdk_py-2.0.0.tar.gz.

File metadata

  • Download URL: tdk_py-2.0.0.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tdk_py-2.0.0.tar.gz
Algorithm Hash digest
SHA256 85686fe3e15b967c99841987d7685c09139591ffe5f8d9b247c87cbb920773fb
MD5 d751acda211bbccf9cde899466810e40
BLAKE2b-256 1fae6dac29ce773dacede9f832d5f7c9c11e8a12abfefd51206e6aaadb31e4ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for tdk_py-2.0.0.tar.gz:

Publisher: publish.yml on emreozcan/tdk-py

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

File details

Details for the file tdk_py-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: tdk_py-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 30.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tdk_py-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e5db030729fc1e103b2ad2e51a4ec1f68a1b95c26c52a9d411b76508ed1dbef
MD5 cdb18487cb9ee4fa33c926bf11748a5a
BLAKE2b-256 f4d29a2331580e4dbc1ce2b0b1b384f99d09405a6964767b003a0a7ae055f8e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for tdk_py-2.0.0-py3-none-any.whl:

Publisher: publish.yml on emreozcan/tdk-py

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