Metadata-Version: 2.1
Name: fitrat
Version: 0.0.9
Summary: An NLP library for Uzbek. It includes morphological analysis, language identification, transliterators and tokenizers.
Project-URL: Homepage, https://github.com/tahrirchi/fitrat
Project-URL: Bug Tracker, https://github.com/tahrirchi/fitrat/issues
Author-email: Muhammadsaid Mamasaidov <mukhammadsaid.mamasaidov@gmail.com>, Jasur Yusupov <jasuryusupov14@gmail.com>
Maintainer-email: Muhammadsaid Mamasaidov <mukhammadsaid.mamasaidov@gmail.com>, Jasur Yusupov <jasuryusupov14@gmail.com>
License: MIT License
        
        Copyright (c) Tahrirchi
        
        Authors: Mukhammadsaid Mamasaidov, Jasur Yusupov
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: language,morphology,nlp,tahrirchi,transliteration,uzbek
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Text Processing :: Linguistic
Requires-Python: >=3.7
Requires-Dist: fasttext==0.9.2
Requires-Dist: hfstol==1.2.11
Description-Content-Type: text/markdown

# fitrat

<img src="https://github.com/tahrirchi/fitrat/blob/main/fitrat.png" alt="Abdurauf Fitrat" style="width:125px;" align="left"/>

An NLP library for Uzbek. It includes morphological analysis, transliterators, language identifiers, tokenizers and many more.

It is named after historian and linguist Abdurauf Fitrat, who was one of the creators of Modern Uzbek as well as the first Uzbek professor.

<br />

## Usage

### Installation

```shell
pip install fitrat
```

### Transliteration

We used `hfst` library for creating transliterators. This library provides finite-state transducers, a finite-state machines that come very handy for efficient mapping one text to another.

```python
from fitrat import Transliterator, WritingType

t = Transliterator(to=WritingType.LAT)
result = t.convert("Кеча циркка бордим.")
print(result)
# Kecha sirkka bordim.

t2 = Transliterator(to=WritingType.CYR)
result = t2.convert("Kecha sirkka bordim.")
print(result)
# Кеча циркка бордим.
```

While Cyrillic-Latin conversion is rule-based and simple, the converse is not true. We included special pre-compiled exceptions transducer for Latin-Cyrillic that handles all (to our knowledge) exceptions. We'll continue working on improving on our exceptions list.

If you want to compile the transliterators from source, you have to use `hfst-dev` or `hfst` library. The package uses only pre-compiled binaries and `hfstol` library for efficient lookup.

### Language Identification

We can recognize Uzbek text, both Latin or Cyrillic. Additionally, we can recognize other major languages, such as Russian, English, Arabic and etc.

```python
from fitrat import LanguageDetector

lang_detector = LanguageDetector()

print(lang_detector.is_uzbek("bu o'zbekchada yozilgan matn"))
# True

print(lang_detector.is_uzbek("бу нотугри йозилган булсаям, лекин узбекча матн"))
# True

print(lang_detector.is_uzbek("Текст на русском языке"))
# False
```

## Tokenization

```python
from fitrat import word_tokenize

s = "Bugun o'zbekchada gapirishga qaror qildim!"
print(word_tokenize(s))
# ['Bugun', "o'zbekchada", 'gapirishga', 'qaror', 'qildim', '!']
```

## Authors

- Mukhammadsaid Mamasaidov
- Jasur Yusupov
