Metadata-Version: 2.4
Name: zeyrek
Version: 0.2.0
Summary: Python morphological analyzer and lemmatizer for Turkish
Keywords: turkish,nlp,morphology,lemmatizer,morphological-analysis,zemberek
Author: Olga Bulat
Author-email: Olga Bulat <obulat@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Natural Language :: Turkish
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Text Processing :: Linguistic
Requires-Dist: nltk>=3.9
Requires-Python: >=3.10
Project-URL: Homepage, https://github.com/obulat/zeyrek
Project-URL: Documentation, https://zeyrek.readthedocs.io
Project-URL: Source, https://github.com/obulat/zeyrek
Project-URL: Issues, https://github.com/obulat/zeyrek/issues
Project-URL: Changelog, https://github.com/obulat/zeyrek/releases
Description-Content-Type: text/markdown

# Zeyrek: Morphological Analyzer and Lemmatizer

![PyPI - Version](https://img.shields.io/pypi/v/zeyrek)

Zeyrek is a partial port of the [Zemberek library](https://github.com/ahmetaa/zemberek-nlp) to Python for lemmatizing
and analyzing Turkish language words. It is in alpha stage, and the API
will probably change.


* Free software: MIT license
* Documentation: https://zeyrek.readthedocs.io.


## Basic Usage

Install Zeyrek and the NLTK tokenizer data it uses:

```shell
pip install zeyrek
python -m nltk.downloader punkt_tab
```

To use Zeyrek, first create an instance of `MorphAnalyzer` class:

```pycon
>>> import zeyrek
>>> analyzer = zeyrek.MorphAnalyzer()
```

Then, you can call its `analyze` method on words or texts to get all possible analyses:

```pycon
>>> for parse in analyzer.analyze("benim")[0]:
...     print(parse)
Parse(word='benim', lemma='ben', pos='Noun', morphemes=['Noun', 'A3sg', 'P1sg'], formatted='[ben:Noun] ben:Noun+A3sg+im:P1sg')
Parse(word='benim', lemma='ben', pos='Pron', morphemes=['Pron', 'A1sg', 'Gen'], formatted='[ben:Pron,Pers] ben:Pron+A1sg+im:Gen')
Parse(word='benim', lemma='ben', pos='Verb', morphemes=['Noun', 'A3sg', 'Zero', 'Verb', 'Pres', 'A1sg'], formatted='[ben:Noun] ben:Noun+A3sg|Zero→Verb+Pres+im:A1sg')
Parse(word='benim', lemma='ben', pos='Verb', morphemes=['Pron', 'A1sg', 'Zero', 'Verb', 'Pres', 'A1sg'], formatted='[ben:Pron,Pers] ben:Pron+A1sg|Zero→Verb+Pres+im:A1sg')
```

If you only need the base form of words, or lemmas, you can call `lemmatize`. It returns
the most likely lemma for each word of the text:

```pycon
>>> analyzer.lemmatize("benim evim")
['ben', 'ev']
```

To get every possible lemma, create the analyzer with `return_all_lemmas=True`. `lemmatize`
then returns a list of tuples, with each word and a list of its possible lemmas:

```pycon
>>> zeyrek.MorphAnalyzer(return_all_lemmas=True).lemmatize("benim")
[('benim', ['ben'])]
```

A lemma is the root of the word, and derivational suffixes can change its meaning a lot. `derived_lemmas`
returns, for each analysis of a word, the lemmas from the root to the stem after the last derivational
suffix. The last one is the word without its inflectional suffixes:

```pycon
>>> analyzer.derived_lemmas("çekilişle")
[['çekiliş'], ['çekil', 'çekiliş'], ['çek', 'çekil', 'çekiliş']]
```


## Credits

This package is a Python port of part of the [Zemberek](https://github.com/ahmetaa/zemberek-nlp) package by [Ahmet A. Akın](https://github.com/ahmetaa)


This package was created with
[Cookiecutter](https://github.com/audreyr/cookiecutter) and the
[audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage)
project template.

