Package: pyaramorph
# pyaramorph*An Arabic morphological analyzer and lexicon*## Introduction**pyaramorph** is a morphological analyzer and lexicon for the Arabiclanguage. It is a loose port of the [Buckwalter Arabic MorphologicalAnalyzer Version1.0](http://www.ldc.upenn.edu/Catalog/CatalogEntry.jsp?catalogId=LDC2002L49),though it does not implement all of that program’s functionality.This software is supposed to provide quick successive analyses of singlewords or short phrases. Buckwalter’s original Perl script only supportedinput in the `cp1256` encoding, and I really did not want to refit itfor UTF-8. (Also, given how long it has been since I worked with Perland my preference for Python, it seemed worth it to do a Pythonrewrite.) The Java port of the same script,[AraMorph](http://www.nongnu.org/aramorph/), does accept UTF-8, but itonly processes specified input files, and its dictionary loading isquite slow. It’s great for analyzing full texts, but not so much forinteractive analysis.That’s why I wrote this port. The script itself is quite simple – TimBuckwalter really did all the hard work by putting together thedictionary and table files – so all credit for the functionalityprovided by this program should go to him! I have simply re-written theprogram to suit my own needs.## Requirements1. [python](http://www.python.org/). Currently you need Python 3.2. A terminal emulator with UTF-8 and BiDi support. I use[mlterm](http://mlterm.sourceforge.net/) with[unifont](http://www.unifoundry.com/index.html) or[DejaVu Sans Mono](http://dejavu-fonts.org/wiki/Main_Page).(Here are some old though perhaps useful[setup instructions](http://lists.arabeyes.org/archives/general/2004/February/msg00004.html).)3. Ability to type in UTF-8 Arabic text. Linux/Unix users can try theArabic layout included in my[Classical Input Methods for M17N](https://bitbucket.org/alexlee/m17n-classical),which are intended for use with[IBus](https://github.com/ibus/ibus/wiki).## InstallationYou can install using `pip`, or from source with `python setup.pyinstall`.## UsageOnce you have the software installed and your BiDi-enabled, UTF-8capable terminal up and running, you simply need to run the `pyaramorph`command. At the prompt, enter an Arabic word or phrase, using Unicode.Words not written in the Arabic script will be ignored.The session output below should give you an idea of how it works:alexlee@sartorius:~$ pyaramorphloading dictPrefixes ... loaded 299 entriesloading dictStems ... loaded 38600 lemmas and 82158 entriesloading dictSuffixes ... loaded 618 entriesUnicode Arabic Morphological Analyzer (press ctrl-d to exit)$ كتب كتابا في المكتبanalysis for: كتب ktbsolution: (كَتَبَ kataba) [katab-u_1]pos: katab/VERB_PERFECT+a/PVSUFF_SUBJ:3MSgloss: ___ + write + he/it <verb>solution: (كُتِبَ kutiba) [katab-u_1]pos: kutib/VERB_PERFECT+a/PVSUFF_SUBJ:3MSgloss: ___ + be written;be fated;be destined + he/it <verb>solution: (كُتُب kutub) [kitAb_1]pos: kutub/NOUNgloss: ___ + books + ___analysis for: كتابا ktAbAsolution: (كِتاباً kitAbAF) [kitAb_1]pos: kitAb/NOUN+AF/NSUFF_MASC_SG_ACC_INDEFgloss: ___ + book + [acc.indef.]solution: (كِتابا kitAbA) [kitAb_1]pos: kitAb/NOUN+A/NSUFF_MASC_DU_NOM_POSSgloss: ___ + book + twosolution: (كُتّاباً kut~AbAF) [kut~Ab_1]pos: kut~Ab/NOUN+AF/NSUFF_MASC_SG_ACC_INDEFgloss: ___ + kuttab (village school);Quran school + [acc.indef.]solution: (كُتّاباً kut~AbAF) [kAtib_1]pos: kut~Ab/NOUN+AF/NSUFF_MASC_SG_ACC_INDEFgloss: ___ + authors;writers + [acc.indef.]analysis for: في fysolution: (فِي fiy) [fiy_1]pos: fiy/PREPgloss: ___ + in + ___solution: (فِيَّ fiy~a) [fiy_1]pos: fiy/PREP+~a/PRON_1Sgloss: ___ + in + mesolution: (فِي fiy) [fiy_2]pos: Viy/ABBREVgloss: ___ + V. + ___analysis for: المكتب Almktbsolution: (المَكْتَب Almakotab) [makotab_1]pos: Al/DET+makotab/NOUNgloss: the + bureau;office;department + ___$## TodoDiacritics are ignored for now. It would be nice to use theuser-supplied diacritics to filter through the generated solutions. Thatway if you enter something like `dar~ast` (دَرَّست), it won’t return anyresults from the `daras` (دَرَس) root.In his original Perl script, Buckwalter applies a number of spellingsubstitutions if a given word does not generate any solutions. Thisfunctionality should be easy to add, but I didn’t get around to it.A simple GUI would be nice, for a better choice of fonts (like the[SIL Arabic fonts](http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&item_id=ArabicFonts))and for Windows support.## ContactIf you have any comments, suggestions, fixes, contributions, etc., pleasecontact Alex Lee (alexlee at fastmail net). Thanks!