Skip to main content

A package for working with Kazakh language text processing.

Project description

QazNLTK

A Python library for Kazakh language text processing.

PyPI Downloads

pip install qaznltk

Features

# Feature Method
1 Tokenization by frequency tokenize(text)
2 Sentence segmentation sent_tokenize(text)
3 Text similarity score calc_similarity(a, b)
4 Cyrillic → Latin (ISO-9) convert2latin_iso9(text)
5 Latin → Cyrillic (ISO-9) convert2cyrillic_iso9(text)
6 Sentiment analysis sentimize(text)-1 / 0 / 1
7 Number to words num2word(n)
8 IIN parser get_info_from_iin(iin)
9 Stop words list get_stop_words()
10 Kazakh alphabet get_kaz_alphabet()
11 TF-IDF + KNN search QazNLTKVectorizer + KNN
12 Kazakh LLM (QazPerry) via HuggingFace

Usage

from qaznltk import QazNLTK
qn = QazNLTK()

Tokenize

qn.tokenize("Біздің өміріміз үлкен өзен іспетті.")
# [('өміріміз', 1), ('үлкен', 1), ('өзен', 1), ('іспетті', 1)]

Sentence split

qn.sent_tokenize("Сәлем. Қалайсың?")
# ['Сәлем.', 'Қалайсың?']

Similarity

qn.calc_similarity("Еңбегіне қарай — құрмет.", "Еңбегіне қарай табысы.")
# 0.368

Transliteration

qn.convert2latin_iso9("Бүгін керемет күн!")   # Bùgìn keremet kùn!
qn.convert2cyrillic_iso9("Bùgìn keremet kùn!")  # Бүгін керемет күн!

Sentiment (-1 negative, 0 neutral, 1 positive)

qn.sentimize("Бұл мақала өте нашар жазылған.")  # -1.0

Number to words

qn.num2word(1465)  # 'бір мың төрт жүз алпыс бес'

IIN parser

qn.get_info_from_iin("990408482390")
# {'status': 'success', 'date_of_birth': '08.04.1999', 'gender': 'female', ...}

Stop words

qn.get_stop_words()
# ['біздің', 'бұл', 'және', 'мен', 'не', ...]

Kazakh alphabet

qn.get_kaz_alphabet()
# ['а', 'ә', 'б', 'в', 'г', 'ғ', 'д', 'е', 'ё', 'ж', 'з', 'и', 'й',
#  'к', 'қ', 'л', 'м', 'н', 'ң', 'о', 'ө', 'п', 'р', 'с', 'т', 'у',
#  'ү', 'ұ', 'ф', 'х', 'һ', 'ц', 'ч', 'ш', 'щ', 'ъ', 'ы', 'і', 'ь', 'э', 'ю', 'я']

TF-IDF + KNN

from qaznltk import QazNLTKVectorizer
 
vectorizer = QazNLTKVectorizer()
matrix = vectorizer.fit_transform(documents)
knn = vectorizer.KNN(matrix)
 
query_vector = vectorizer.transform(["Еліміздің алтын күні жарық күн."])[0]
results = knn.search(query_vector, k=3)
# [(idx, distance), ...]

QazPerry (Kazakh LLM)

pip install keras-nlp huggingface_hub
from huggingface_hub import hf_hub_download
import keras, keras_nlp
 
model_path = hf_hub_download("silvermete0r/Gemma2_2B_QazPerry", "Gemma2_2B_QazPerry.keras")
model = keras.models.load_model(model_path, custom_objects={"GemmaCausalLM": keras_nlp.models.GemmaCausalLM})
 
print(model.generate("Instruction:\nҚазақша бірдеңе айтшы?\n\nResponse:\n"))

HuggingFace: silvermete0r/Gemma2_2B_QazPerry


License

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

qaznltk-1.3.0.1.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

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

qaznltk-1.3.0.1-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file qaznltk-1.3.0.1.tar.gz.

File metadata

  • Download URL: qaznltk-1.3.0.1.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for qaznltk-1.3.0.1.tar.gz
Algorithm Hash digest
SHA256 2d89ba9a3e30f2df3f6ef1a53a9f677589f3cbc921924a6baec048fe806fd52c
MD5 fa3e9e0401fd2ac0924e681b3cdd99bb
BLAKE2b-256 3055cf971a40317437aeacfbe9a63b1dd81c597ccfc3b400ff08ce3ddc792de1

See more details on using hashes here.

File details

Details for the file qaznltk-1.3.0.1-py3-none-any.whl.

File metadata

  • Download URL: qaznltk-1.3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for qaznltk-1.3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 98c6222024605eeca4d4c114a99f94450f09edab10c89e22988ec8ee62b49305
MD5 185ade1f34755f29b8e505f782137ee6
BLAKE2b-256 9af0397fcb2deab19da8510b4cdb43e5bb3b1026e5f8090cca14ed0945a8783b

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