Arabic Spelling Correction
Project description
Description
Simple library to check the spelling of arabic sentences. This library uses a vocabulary that consists of +500K words, and uses 1-edit_distance and 2-edit_distance to correct the misspelled words. It also uses 1-ngram language model to correct the words depending on the previous context.
Installation
pip install ar-corrector
Usage
Correct word spelling
from ar_corrector.corrector import Corrector
corr = Corrector()
corr.spell_correct('بختب') # return 5 corrections with top frequencies
# [('بكتب', 61), ('برتب', 22), ('بختم', 21), ('بختي', 9), ('بخت', 7)]
corr.spell_correct('بختب', 2) # return 2 corrections with top frequencies
# [('بكتب', 61), ('برتب', 22),]
corr.spell_correct('بختب', 1) # return 1 correction with top frequency
# [('بكتب', 61)]
corr.spell_correct('لتمشتلميتلكب', 4) # return the same word
# لتمشتلميتلكب
corr.spell_correct('من') # return true
# True
Correct word spelling using the context
from ar_corrector.corrector import Corrector
corr = Corrector()
sent = 'أكدت قواءص التمذد في تشاد أنها تواضضل طريقها للعاحمة'
print(corr.contextual_correct(sent))
#أكدت قوات التمرد في تشاد أنها تواصل طريقها للعاصمة
sent = 'اتتنتهى حدث آبل المنتظو بالإعلاخ عن مموعة من المنتجات'
print(corr.contextual_correct(sent))
#انتهى حدث آبل المنتظر الإعلان عن مجموعة من المنتجات
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ar_corrector-1.1.5.tar.gz
(51.5 MB
view details)
Built Distribution
File details
Details for the file ar_corrector-1.1.5.tar.gz
.
File metadata
- Download URL: ar_corrector-1.1.5.tar.gz
- Upload date:
- Size: 51.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53e089772c0865393f9424d59a4942a1d4a7b2b64595ad64503bb7d00cffe8d6 |
|
MD5 | 19a8e6ad99e39477bd3f61c810754a7e |
|
BLAKE2b-256 | af94354ac9f4255e8959a7c8fa64d65774414f76bd3c2b883d6102996f22ad64 |
File details
Details for the file ar_corrector-1.1.5-py3-none-any.whl
.
File metadata
- Download URL: ar_corrector-1.1.5-py3-none-any.whl
- Upload date:
- Size: 53.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0af4c0c7f0eb04b69cccb4899506c0cea69e17fea2f505e6057b0ea2aa549071 |
|
MD5 | a1c74fe694e9ecbaf657bd775f8e5b41 |
|
BLAKE2b-256 | 17cdaf817a214b694304f7a0ab53cf6991fabcd537a189805b0e621c928517f2 |