Skip to main content

Asmai: (Al’asma’i) Arabic semantic analysis

مكتبة الأصمعي الدلالية

Asmai: (Al’asma’i) Arabic semantic analysis library for Python

asmai logo

asmai logo

PyPI - Downloads

PyPI - Downloads

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

Features

value

Authors

Authors.md

Release

0.1

License

GPL

Tracker

linuxscout/asmai/Issues

Source

Github

Feedbacks

Comments

Accounts

[@Twitter](https://twitter.com/linuxscout)

Description

Asmai: (Al’asma’i) Arabic semantic analysis library for Python

مزايا:

  • استخلاص ثنائيات الكلمات التي تحمل دلالات من نوع : (فاعلية، مفعولية، إضافة)

install

pip install asmai

Usage

import

pip install asmai

Test

import asmai.anasem as asm
text  =  u"يعبد الله منذ أن تطلع الشمس"
result  =  []
anasem  =  asm.SemanticAnalyzer()
result  =  anasem.analyze_text(text)
# the result contains objets
anasem.pprint(result)
  • Extract semantic relation, display only found relations

>>> import pprint
>>> sem_result = anasem.display_sem(result)
>>> pprint.pprint(sem_result)
[[['الشَّمْسُ', 'تَطْلُعَ', 'شَمْسٌ', 'طَلَعَ', 'Subject'],
  ['الشَّمْسُ', 'تَطْلُعُ', 'شَمْسٌ', 'طَلَعَ', 'Subject'],
  ['الشَّمْسُ', 'تَطْلُعْ', 'شَمْسٌ', 'طَلَعَ', 'Subject'],
  ['الشَّمْسُ', 'تَطْلَعَ', 'شَمْسٌ', 'طَلَعَ', 'Subject'],
  ['الشَّمْسُ', 'تَطْلَعُ', 'شَمْسٌ', 'طَلَعَ', 'Subject'],
  ['الشَّمْسُ', 'تَطْلَعْ', 'شَمْسٌ', 'طَلَعَ', 'Subject']]]
  • Extract semantic relation, display all words and tags

    >>> sem_result = anasem.display_sem(result, all=True)
    >>> pprint.pprint(sem_result)
    [('يعبد', 'O', []),
     ('الله', 'O', []),
     ('منذ', 'O', []),
     ('أن', 'O', []),
     ('تطلع', 'B', []),
     ('الشمس',
      'I',
      [['الشَّمْسُ', 'تَطْلُعَ', 'شَمْسٌ', 'طَلَعَ', 'Subject'],
       ['الشَّمْسُ', 'تَطْلُعُ', 'شَمْسٌ', 'طَلَعَ', 'Subject'],
       ['الشَّمْسُ', 'تَطْلُعْ', 'شَمْسٌ', 'طَلَعَ', 'Subject'],
       ['الشَّمْسُ', 'تَطْلَعَ', 'شَمْسٌ', 'طَلَعَ', 'Subject'],
       ['الشَّمْسُ', 'تَطْلَعُ', 'شَمْسٌ', 'طَلَعَ', 'Subject'],
       ['الشَّمْسُ', 'تَطْلَعْ', 'شَمْسٌ', 'طَلَعَ', 'Subject']])]
    >>>
  • convert to pandas ```python >>> import pandas as pd >>> >>> # flatten the result … df = pd.DataFrame(anasem.decode(result)) >>> print(df.head()) action affix affix_key forced_word_case … unvocalized unvoriginal vocalized word 0 -ي– -ي–|المضارع المنصوب:هو:y False … يعبد عبد يُعَبِّدَ يعبد 1 -ي– -ي–|المضارع المجهول المجزوم:هو:y False … يعبد عبد يُعَبَّدْ يعبد 2 -ي– -ي–|المضارع المجهول:هو:y False … يعبد عبد يُعَبَّدُ يعبد 3 -ي– -ي–|المضارع المعلوم:هو:y False … يعبد عبد يُعَبِّدُ يعبد 4 -ي– -ي–|المضارع المجزوم:هو:y False … يعبد عبد يُعَبِّدْ يعبد

[5 rows x 50 columns] >>> df.to_csv(“output/test.csv”, encoding=”utf8”, sep=”:raw-latex:’t’”)

[requirement]

1- pyarabic
2. sqlite
3. sylajone

Data Structure:

Semantic database

CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE "derivations" (
    "id" INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL  UNIQUE ,
    "verb" varchar NOT NULL ,
    "transitive" BOOL NOT NULL  DEFAULT 1,
    "derived" VARCHAR NOT NULL ,
    "type" VARCHAR NOT NULL
 );

CSV Structure:

  • Derivattion

  1. id : id unique in the database

  2. verb : vocalized collocation

  3. transtive : if the verb is transitive

  4. derived : derived word from verb number

  5. type : type

Semantic relations

CREATE TABLE "relations" (
    "id" INTEGER PRIMARY KEY  NOT NULL ,
    first" VARCHAR NOT NULL  DEFAULT ('') ,
    "second" VARCHAR NOT NULL  DEFAULT ('') ,
    "rule" VARCHAR NOT NULL  DEFAULT (0)
 );

CSV Structure:

  1. id : id unique in the database

  2. first: first word

  3. second: second word

  4. rule : the extraction rule number :

Metadata

Release files for asmai 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 asmai 0.1
File Size Uploaded Provenance Actions
asmai-0.1.tar.gz 7.7 MB Without provenance Details for asmai-0.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for asmai 0.1
File Interpreter ABI Platform Actions
asmai-0.1-py3-none-any.whl Python 3 none any Details for asmai-0.1-py3-none-any.whl
asmai-0.1-py2-none-any.whl Python 2 none any Details for asmai-0.1-py2-none-any.whl

Total release size: 16.4 MB

Release files / asmai-0.1.tar.gz

Download URL asmai-0.1.tar.gz
Size 7.7 MB
Tags Source
SHA-256 checksum
How to use checksums
d29aeb7ae7ecc12e0eada21ac41be7fbf049abbb58bca8e5ce518fbbd9dfaecf
BLAKE2b-256 checksum
How to use checksums
e3ba99efc20677b0d3634e547052afde5f051b0c2d95626dde3ac109c37affe5
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / asmai-0.1-py3-none-any.whl

Download URL asmai-0.1-py3-none-any.whl
Size 4.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
2774425c726025718d3116baed2507761f3ef3aff4e6643b542f538e42468a7d
BLAKE2b-256 checksum
How to use checksums
fc4ff096c0136c2b5ac342fe5642c41abc6358c8545d5192f6575ff58a6cf3ac
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / asmai-0.1-py2-none-any.whl

Download URL asmai-0.1-py2-none-any.whl
Size 4.3 MB
Tags Python 2
SHA-256 checksum
How to use checksums
536a2ce279ce6c67815481a5b9fc71e931a6450988f3d43354d625b14cb0450f
BLAKE2b-256 checksum
How to use checksums
fb3a546a1fb901061b4fa8c214d4346d615617b8576432625f4c2fb427f6a204
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for asmai 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

3 release files No provenance

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