Skip to main content

Python API for the Turkish Language Foundation

Project description

Python API for the Turkish Language Foundation

tdk-py is a Python package that allows for simple access to Turkish dictionaries made available by the TDK, the Turkish Language Society. tdk-py aims to be easy to use and internally queries the TDK and parses its response into easy to use Python class objects.

Installation

tdk-py is supported on Python 3.6+. The recommended way to install is via pip which comes with Python.

pip install tdk-py

If your machine doesn’t have Python and pip installed you can download it from The Python Software Foundation’s website.

Sample usage

tdk.gts is used to access TDK’s GTS, the up-to-date Turkish dictionary (Güncel Türkçe Sözlük).

>>> import tdk.gts
>>> tdk.gts.search("merkeziyetçilik")
[<Entry 41635 (merkeziyetçilik)>]

tsk.gts.search returns a list because it is possible for there to be more than one word with the exact same spelling.

>>> for number, entry in enumerate(tdk.gts.search("bar")):
...     for meaning in entry.meanings:
...         print(number+1, entry.entry, meaning.meaning)
...
1 bar Anadolu'nun doğu ve kuzey bölgesinde, en çok Artvin ve Erzurum yörelerinde el ele tutuşularak oynanan, ağır ritimli bir halk oyunu
2 bar Danslı, içkili eğlence yeri
2 bar Ayaküstü içki içilen eğlence yeri
2 bar Amerikan bar
3 bar Hava basıncı birimi
4 bar Ateşten, mide bozukluğundan, ağızda, dil ve dişlerde meydana gelen acılık, pas
5 bar Halter sporunda ağırlığı oluşturan kiloları birbirine bağlayan metal çubuk
>>> # 5 different words! One of them (#2) has multiple meanings!

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

>>> tdk.gts.suggest("feldispat")
['feldspat', 'felekiyat', 'ispat']
>>> tdk.gts.suggest("feldspat")
['espas', 'felah', 'felaket', 'felekiyat', 'fellah', 'felsefe', 'felsefi']

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

>>> from tdk.tools import max_streak
>>> from tdk.alphabet import CONSONANTS
>>> annotated_list = [max_streak(word=x, targets=CONSONANTS) for x in tdk.gts.index()]
>>> for i in set(annotated_list):
...     print(i, annotated_list.count(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 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-1.0.0.post1.tar.gz (13.0 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-1.0.0.post1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file tdk-py-1.0.0.post1.tar.gz.

File metadata

  • Download URL: tdk-py-1.0.0.post1.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for tdk-py-1.0.0.post1.tar.gz
Algorithm Hash digest
SHA256 b11331764f34e90770cef52c8d7e72eab27468e977ee65903d1e7ffdbb796d56
MD5 f6bb1f9ec1dc1b59c04fd571233a32f8
BLAKE2b-256 c7f4b6ba5caf17b6d5ea78c4b799feaf284228de394f688e96e695be34e70c3c

See more details on using hashes here.

File details

Details for the file tdk_py-1.0.0.post1-py3-none-any.whl.

File metadata

  • Download URL: tdk_py-1.0.0.post1-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for tdk_py-1.0.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 d5df446122544ba3ef6a828f294e1a7badf83a07fe1b587eb9258c4b58c269d4
MD5 a5db7592248e40215f95deee83928e9f
BLAKE2b-256 5d1f1c187c0ab3cae09681f941e3ffc03516c268afa80feab4d66f1b14eb770a

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