Mysam: Arabic tags manager
Project description
Installation
` pip install mysam-tagmanager `
Usage
import mysam.tagmaker as tagmaker
Example
Test load configuration
import mysam.tagconfig as tagconfig
import mysam.tag_const as tag_const
import pandas as pd
configuer = tagconfig.tagConfig()
configuer.load_config()
# display
df = pd.DataFrame(tag_const.TAGSDICT)
print('****tagdict ****')
print(df)
*****Result *****
****tagdict ****
1st person 2nd person 3rd person Beh FEH \
ar_attr شخص شخص شخص جر عطف
ar_value متكلم مخاطب غائب باء الفاء
attr person person person preposition conjonction
code I Y H B F
inflect بالباء
part 4 4 4 3 3
pos 4 4 4 2 1
value 1st person 2nd person 3rd person Beh FEH
....
....
You can load a specific config file by passing parameter to load_conf. If the file doesn’t exist or failed to be open, the default config is loaded.
configuer = tagconfig.tagConfig()
configuer.load_config("tag.config")
If you want to know if the input file is opened, fix ‘debug’ parameter to ‘True’
If you want to know if the input file is open, fix ‘debug’ parameter to ‘True’
configuer = tagconfig.tagConfig()
configuer.load_config("tag.config", debug=True)
Test call tagmaker
import mysam.tagmaker as tagmaker
taglists = [[u'اسم', u'هاء', u'مجرور',],
u'تعريف::مرفوع:متحرك:ينون:::'.split(":"),
]
for taglist in taglists:
tag_maker = tagmaker.tagMaker()
# encode
tag_maker.encode(taglist)
print(u"+".join(taglist).encode('utf8'))
tagstr = str(tag_maker)
print(tagstr)
# decode a unifed tag string
print(tag_maker.decode())
**** result ****
اسم+هاء+مجرور
N--;--I-;----;----
[(u'نوع الكلمة', u'اسم'), (u'جنس', u'لاشيء'), (u'عدد', u'لاشيء'), (u'إعراب', u'مجرور'), (u'علامة', u'لاشيء'), (u'عطف', u'لاشيء'), (u'جر', u'لاشيء'), (u'تعريف', u'نكرة'), (u'ضمير متصل', u'لاشيء'), (u'استقبال', u'لاشيء'), (u'بناء', u'لاشيء'), (u'زمن', u'لاشيء'), (u'شخص', u'لاشيء')]
تعريف++مرفوع+متحرك+ينون+++
---;--U-;--L-;----
[(u'نوع الكلمة', u'لاشيء'), (u'جنس', u'لاشيء'), (u'عدد', u'لاشيء'), (u'إعراب', u'مرفوع'), (u'علامة', u'لاشيء'), (u'عطف', u'لاشيء'), (u'جر', u'لاشيء'), (u'تعريف', u'معرفة'), (u'ضمير متصل', u'لاشيء'), (u'استقبال', u'لاشيء'), (u'بناء', u'لاشيء'), (u'زمن', u'لاشيء'), (u'شخص', u'لاشيء')]
Exmaple for inflect
>>> tag_maker = tagmaker.tagMaker()
>>> tagcode = 'N--;--I-;----;---'
>>> print(tag_maker.inflect(tagcode).encode('utf8'))
اسم مجرور وعلامة جرّه الياء لأنه جمع مذكر سالم وهو مضاف، والضمير المتصل مبني في محل جر مضاف إليه
Exmaple for add tag
>>> tag_maker = tagmaker.tagMaker()
>>> tagcode = 'N--;--I-;----;---'
>>> tag_new = u"تعريف"
>>> tag_maker.add(tag_new)
>>> tag_new = u"اسم"
>>> tag_maker.add(tag_new)
>>> print(str(tag_maker).encode('utf8'))
N--;----;--L-;----
Exmaple for has tag
>>> tag_maker = tagmaker.tagMaker()
>>> tagcode = 'N--;--I-;----;---'
>>> tag_search = u"مجرور"
>>> print(tag_maker.has_tag(tag_search, tagcode))
True
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
mysam-tagmanager-0.2.tar.gz
(14.5 kB
view hashes)
Built Distributions
Close
Hashes for mysam_tagmanager-0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fc606beb842da6222ddbac7e582fe1cd1efef583411022ce9efc6dd68ed00bd |
|
MD5 | ee92eee27794bb23650571ed643e1be8 |
|
BLAKE2b-256 | 9de04c36bc886122fc47f55b8976173ac68c3463b5dc654181b4ca512819fd92 |
Close
Hashes for mysam_tagmanager-0.2-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37e3427ef33264afaf231490090b16c11408de851762c6e022a846b8aeb586cb |
|
MD5 | 60823bcc52c0af981e683442814bdf3b |
|
BLAKE2b-256 | 9d680612878a454af4880ef8b6bbe98c8771c5eab9f0fe483e213041e591931f |