Skip to main content

Qalsadi Arabic Morphological Analyzer and lemmatizer for Python

Project description

Qalsadi Arabic Morphological Analyzer for Python

Developpers: Taha Zerrouki: http://tahadz.com taha dot zerrouki at gmail dot com

Feature s

value

Authors

Authors.md

Release

0.3.6

License

GPL

Tracker

linuxscout/qalsadi/Issues

Website

https://pypi.python.org/pypi/qalsadi

Doc

package Documentaion

Source

Github

Downloa d

sourceforge

Feedbac ks

Comments

Account s

[@Twitter](https://twitter.com/linuxscout) [@Sourceforge](http://sourceforge.net/projects/qalsadi/)

Citation

If you would cite it in academic work, can you use this citation

T. Zerrouki‏, Qalsadi, Arabic mophological analyzer Library for python.,  https://pypi.python.org/pypi/qalsadi/

Features مزايا

Applications

  • Stemming texts

  • Text Classification and categorization

  • Sentiment Analysis

  • Named Entities Recognition

Installation

pip install qalsadi

Requirements

pip install -r requirements.txt

Usage

Example

>>> import qalsadi.lemmatizer
    >>> text = u"""هل تحتاج إلى ترجمة كي تفهم خطاب الملك؟ اللغة "الكلاسيكية" (الفصحى) موجودة في كل اللغات وكذلك اللغة "الدارجة" .. الفرنسية التي ندرس في المدرسة ليست الفرنسية التي يستخدمها الناس في شوارع باريس .. وملكة بريطانيا لا تخطب بلغة شوارع لندن .. لكل مقام مقال"""
    >>> lemmer = qalsadi.lemmatizer.Lemmatizer()
    >>> # lemmatize a word
    ... lemmer.lemmatize("يحتاج")
    'احتاج'
    >>> # lemmatize a word with a specific pos
    >>> lemmer.lemmatize("وفي")
    'في'
    >>> lemmer.lemmatize("وفي", pos="v")
    'وفى'

    >>>
    >>> lemmas = lemmer.lemmatize_text(text)
    >>> print(lemmas)
    ['هل', 'احتاج', 'إلى', 'ترجمة', 'كي', 'تفهم', 'خطاب', 'ملك', '؟', 'لغة', '"', 'كلاسيكي', '"(', 'فصحى', ')', 'موجود', 'في', 'كل', 'لغة', 'ذلك', 'لغة', '"', 'دارج', '"..', 'فرنسي', 'التي', 'درس', 'في', 'مدرسة', 'ليست', 'فرنسي', 'التي', 'استخدم', 'ناس', 'في', 'شوارع', 'باريس', '..', 'ملك', 'بريطانيا', 'لا', 'خطب', 'بلغة', 'شوارع', 'دنو', '..', 'كل', 'مقام', 'مقالي']
    >>> # lemmatize a text and return lemma pos
    ... lemmas = lemmer.lemmatize_text(text, return_pos=True)
    >>> print(lemmas)
    [('هل', 'stopword'), ('احتاج', 'verb'), ('إلى', 'stopword'), ('ترجمة', 'noun'), ('كي', 'stopword'), ('تفهم', 'noun'), ('خطاب', 'noun'), ('ملك', 'noun'), '؟', ('لغة', 'noun'), '"', ('كلاسيكي', 'noun'), '"(', ('فصحى', 'noun'), ')', ('موجود', 'noun'), ('في', 'stopword'), ('كل', 'stopword'), ('لغة', 'noun'), ('ذلك', 'stopword'), ('لغة', 'noun'), '"', ('دارج', 'noun'), '"..', ('فرنسي', 'noun'), ('التي', 'stopword'), ('درس', 'verb'), ('في', 'stopword'), ('مدرسة', 'noun'), ('ليست', 'stopword'), ('فرنسي', 'noun'), ('التي', 'stopword'), ('استخدم', 'verb'), ('ناس', 'noun'), ('في', 'stopword'), ('شوارع', 'noun'), ('باريس', 'all'), '..', ('ملك', 'noun'), ('بريطانيا', 'noun'), ('لا', 'stopword'), ('خطب', 'verb'), ('بلغة', 'noun'), ('شوارع', 'noun'), ('دنو', 'verb'), '..', ('كل', 'stopword'), ('مقام', 'noun'), ('مقالي', 'noun')]

    >>>
filename="samples/text.txt"
import qalsadi.analex as qa
try:
    myfile=open(filename)
    text=(myfile.read()).decode('utf8');

    if text == None:
        text=u"السلام عليكم"
except:
    text=u"أسلم"
    print " given text"

debug=False;
limit=500
analyzer = qa.Analex()
analyzer.set_debug(debug);
result = analyzer.check_text(text);
print '----------------python format result-------'
print result
for i in range(len(result)):
#       print "--------تحليل كلمة  ------------", word.encode('utf8');
    print "-------------One word detailed case------";
    for analyzed in  result[i]:
        print "-------------one case for word------";
        print repr(analyzed);

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

qalsadi-0.4.2.tar.gz (240.8 kB view details)

Uploaded Source

Built Distribution

qalsadi-0.4.2-py3-none-any.whl (261.3 kB view details)

Uploaded Python 3

File details

Details for the file qalsadi-0.4.2.tar.gz.

File metadata

  • Download URL: qalsadi-0.4.2.tar.gz
  • Upload date:
  • Size: 240.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.19.9 CPython/2.7.12

File hashes

Hashes for qalsadi-0.4.2.tar.gz
Algorithm Hash digest
SHA256 d3e809a74190fd5f8d63f7a62841e4bfcbdbe5235003afae27ba14f77abc2c88
MD5 707baa89308c802a3690c5961e1a6b41
BLAKE2b-256 3cffd66986079fa718ea788d70e212779cf4032b128d2704efa777be03527884

See more details on using hashes here.

File details

Details for the file qalsadi-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: qalsadi-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 261.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.19.9 CPython/2.7.12

File hashes

Hashes for qalsadi-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5ab619434139b3588643d5f38c1a8c003b425fe395ad6ae00c175ca650d10328
MD5 e308c3762798243cefb2113edf59867d
BLAKE2b-256 7f63a2f50d82d1ec418d5a0fb2a80f2a8caa8963a64d35354333c409805bc132

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page