Skip to main content

Python library for digesting Persian text.

  • Text cleaning

  • Sentence and word tokenizer

  • Word lemmatizer

  • POS tagger

  • Dependency parser

  • Corpus readers for Hamshahri and Bijankhan

  • NLTK compatible

  • Python 3.3 and 2.7 support

  • |Build Status|

Usage

>>> from hazm import Normalizer
>>> normalizer = Normalizer()
>>> normalizer.normalize('اصلاح نويسه ها و استفاده از نیم‌فاصله پردازش را آسان مي كند')
'اصلاح نویسه‌ها و استفاده از نیم‌فاصله پردازش را آسان می‌کند'

>>> from hazm import sent_tokenize, word_tokenize
>>> sent_tokenize('ما هم برای وصل کردن آمدیم! ولی برای پردازش، جدا بهتر نیست؟')
['ما هم برای وصل کردن آمدیم!', 'ولی برای پردازش، جدا بهتر نیست؟']
>>> word_tokenize('ولی برای پردازش، جدا بهتر نیست؟')
['ولی', 'برای', 'پردازش', '،', 'جدا', 'بهتر', 'نیست', '؟']

>>> from hazm import Stemmer, Lemmatizer
>>> stemmer = Stemmer()
>>> stemmer.stem('کتاب‌ها')
'کتاب'
>>> lemmatizer = Lemmatizer()
>>> lemmatizer.lemmatize('می‌روم')
'رفت#رو'

>>> from hazm import POSTagger
>>> tagger = POSTagger()
>>> tagger.tag(word_tokenize('ما بسیار کتاب می‌خوانیم'))
[('ما', 'PR'), ('بسیار', 'ADV'), ('کتاب', 'N'), ('می‌خوانیم', 'V')]

>>> from hazm import DependencyParser
>>> parser = DependencyParser(tagger=POSTagger())
>>> parser.parse(word_tokenize('زنگ‌ها برای که به صدا درمی‌آید ؟'))
<DependencyGraph with 8 nodes>

Installation

pip install hazm

We also trained tagger and parser models which you may put them in resources folder of your project.

Thanks

Release files for hazm 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hazm 0.1
File Size Uploaded
hazm-0.1.tar.gz 134.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hazm 0.1
File Interpreter ABI Platform
hazm-0.1.linux-x86_64.exe Details

Total release size: 333.5 kB

Release files / hazm-0.1.tar.gz

Download URL hazm-0.1.tar.gz
Size 134.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1101cf8b66884e9f64c8fa88c129f66150a466551578812d5da7b876213c862e
BLAKE2b-256 checksum
How to use checksums
da4d7065524c9cede2f2a0e57f0a1d6663af036495f084fc60834da31bce33b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / hazm-0.1.linux-x86_64.exe

Download URL hazm-0.1.linux-x86_64.exe
Size 198.6 kB
Tags Source
SHA-256 checksum
How to use checksums
53548952bd94091256e3bb1cd9e7adc6b615bfeae2e83d83cb9ec4305828adf5
BLAKE2b-256 checksum
How to use checksums
942e5aa15812f9ca87c20210c1a94645770dd3e2fdb0b4a91279c75ab22381ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.11.0

2 release files

0.10.0

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.7.0

3 release files

0.5.2

2 release files

0.5.1

2 release files

0.5

2 release files

0.4

2 release files

0.3

2 release files

0.2

2 release files

This release

0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page