Sunday, August 24, 2008

A Closer Look at Zekr 0.7.0 Beta 2

Zekr 0.7.0 beta 2 was released last night, mainly introducing three new features. 1) Search through translations (both with Tanzil search method, and Lucene), 2) Quran Paging: how many (and which ayas) to be shown in each page of Zekr, and 3) Quran root and stem database, supporting searching through root references, with sorting options (by revelation order, natural order, relevance, and aya size).


Quran root and stem search is a unique feature introduced in this version of the software. Root database is kindly provided by CRCIS (Computer Research Center of Islamic Sciences). Here I deeply thank this center for providing such a valuable resource for Zekr project. This root database is bundled with Zekr under a restricted license agreement. You are not allowed to use this database anywhere unless you have a written permission from CRCIS.


Paging mode is another awaiting feature. We used to have rather heavy HTML pages containing thousands of Arabic characters, which made navigation too slow. From this version, there are 4 built-in paging mode, plus as many custom paging mode as one likes. By default an Uthmani paging mode is provided with all Zekr packages.


Paging modes are specially useful for our future exegesis (tafsir) support. Almost all new-style exegeses are section-by-section. Their authors divide Quran into several sections, each has a number of related ayas within it, and put their commentaries on each section overall. Having custom paging modes, one may provide a paging mode used for an exegesis. Authors commentaries then come at the end of the page.

"Go To" menu, previously available under View > Go To, is now provided as a separate menu, with a large choice of navigation options: aya by aya, sura by sura, juz by juz, and even navigating to the next sajda.


Searching through translations was supported very elementarily before 0.7.0. In 0.7.0 beta 1, as we totally rewrote the basic search Java code, it was temporarily removed from that version and now in beta 2 is available for both search methods: Basic, and Advanced (indexed).

There is a I18N option for people to customize how search works for a language, by providing search replacements string patterns or introducing their language stop-words for better search result. In Arabic, for example we provided several replacement rules (patterns) to remove diacritic for easier to ease query writing. AS another example, the following code (available in search-info.properties) is used to work with different kinds of YEH character in Persian translation search:

search.pattern.replace.fa = [\u0626\u0649\u064a]=\u06cc


Advanced search, already available just for searching through Quran text, now also works with translations, featuring powerful Lucene queries. There are a number of Western languages whose stemmer is provided built-in. Other users can use search-info.properties patterns, or write their own stemmers and Lucene analyzers for more practical advanced search.

This release is probably the last beta version in 0.7.0 branch, and the next will be final 0.7.0. The next release, will be provided inshaAllah before this Ramadan.

Wednesday, June 11, 2008

What I Like to See in JPA 2.0

What I like to see in JPA 2.0 final specification.

1. Support for setting collection parameters in JPQL: Collections<object> in a Query in places where a list of objects is acceptable. For example a very common issue is for 'IN' keyword in JPQL:

SELECT mo FROM MyObject mo WHERE mo.id IN (:idList)


Here users should be allowed to set a collection with underling elements of type MyObject.id.

2. Basic support for object comparison (equals) in JPQL:

manager.createQuery("SELECT b FROM Book b WHERE b.author = :p").setParameter("p", managedAuthorObject);

3. When writing an application-level generic search, it's almost impossible to use a NamedQuery. Many JPA 1.0 implementers (Hibernate and EclipseLink for example) support Query-by-example which makes life really much easier when writing search queries.

Since it's very likely that users (application-level) do not enter search criteria values (null values for criteria object), it's useful to let search work without setting some parameters (or setting them to a constant field meaning IGNORE). In this case a default action (which can be customized) can be taken. For example this case:

Query q = manager.createQuery("SELECT p FROM Person p WHERE p.name = :name AND p.age = :age");
if (name is available)
q.setParameter("name", name);
if (age is available)
q.setParameter("age", age);
q.findAll();


It would be really great if 2.0 spec force implementers to support a Query by example, something like this:

Person person = new Person("Bob", 28);
manager.findByExample(person);


A similar mechanism is currently supported by both Hibernate (Criteria query) and TopLink/EclipseLink.

4. LIKE operator for non-String fields. Some database engines support this, and it's good IMHO to recommend implementers to just ignore LIKE (in favor of == operation) if underlying DBMS doesn't support it.

5. Support for @GeneratedValue which is not also @Id. There are many cases that developers need to generate another unique value other that the original entity PK. Since now spec has SEQUENCE and IDENTITY, which are not portable to all DBMSes, @GeneratedValue may also be limited in some DBMSes.

6. Support for interceptors: events that are raised just before or after some special actions: @AfterCommit, @BeforeDelete, .... These annotations may be set globally on the BaseEntity class which is a @MappedSuperClass of other entities, in order to be applied on all entities. It's very useful for injecting different cross-cutting concerns.

7. More consistent persistence.xml schema among different implementations. Almost all configurations (from Database URL, to Logging level) are set as generic key-value pairs in persistence.xml. So in the simplest project you should have two different versions of persistence.xml, for instance one for EclipseLink and one for Hibernate. Many of these settings (specially database connection info) can be set through a general schema.

8. User may want to set another *.xml other than the one on META-INF/persistence.xml for configurations. It's very useful that PersistenceFactory allows a file name, URL, or InputStream to set as persistence.xml content.

A similar mechanism is currently supported by both Hibernate and TopLink.

Friday, April 18, 2008

جامعه‌شناسی منبع‌باز: مقدمه‌ای انتقادی

پروژهٔ کارشناسی‌ام را با عنوان «جامعه‌شناسی بازمتن در حوزهٔ نرم‌افزار» پارسال به دکتر رامتین خسروی تحویل دادم. بعدها کَمَکی تغییرش دادم و عنوانش را هم مناسب‌تر دیدم به «جامعه‌شناسی منبع‌باز: درآمدی انتقادی به پدیدهٔ منبعْ‌باز (open source)» تغییر دهم.
مباحث جامعه‌شناسیش کمی آبکی است، و قصد داشتم پیش از انتشار کمی تکمیلش کنم. به علاوه می‌خواستم پیش از انتشار در اینجا یک جایی بفرستمش، ولی فعلاً که نه خبر از کنفرانس‌ها دارم، نه فرصت تکمیل این را.

متن مقاله را به فرمت پی‌دی‌اف می‌توانید از اینجا دریافت کنید.

فهرست مطالب:
1. مقدمه
2. نرم‌افزار آزاد
2.1. مفاهیم
2.2. تاریخچه
2.2.1. پروژهٔ گنو
2.2.2. گام‌های تاریخی منبع‌باز
2.3. مدل توسعه
2.3.1. کلیسای جامع و بازار
2.3.2. الگوهای مدل بازار
2.3.3. مدیریت پروژه‌های منبع‌باز
2.3.4. قانون بروکس
2.3.5. بررسی پروژه‌هایی در مدل بازار و کلیسای جامع
2.3.6. جمع‌بندی مدل‌های ارائه شده
2.4. مدل کسب و کار
3. جامعه‌شناسی نرم‌افزار آزاد
3.1. جنبه‌های هویتی و روانی منبع‌باز
3.2. کسب و کار
3.3. نخبه‌گرایی
3.4. آیا منبع‌باز یک انقلاب است؟
4. نتیجه‌گیری
5. منابع

Monday, March 3, 2008

Zekr on Nokia N800

Zekr seems to work on Nokia N800 Internet appliances!



Many thanks to Adibudeen for the screenshot.

Friday, November 16, 2007

How to use TopLink along with JBoss

JBoss is bundled with Hibernate as the default JPA/EJB3 persistence implementation, like GlassFish which is bundled with TopLink essentials. Developers who are trying to use TopLink in an application which is to be deployed on JBoss may face with some difficulties.

Persistence implementation class is referenced in persistence.xml. Since Hibernate JPA implementation is referenced somewhere in persistence.xml in a META-INF folder visible in JBoss classpath, javax.persistence.Persistence finds at least two implementations: TopLink (which is deployed with the application, and you put persistence.xml in your classes/META-INF) and Hibernate. A call to EntityManagerFactory implementation constructor is done through reflection. If it returns null, Persistence tries with the next implementation found. The problem here is that a call to Hibernate's EntityManagerFactory cannot be done, since Hibernate classes (org.hibernate.*) are not visible in the current classloader's classpath, so your application fails to deploy with a ClassCastException for Hibernate's EntityManagerFactory implementation. To overcome this problem you need to do a small trick. Just copy hibernate-entitymanager.jar inside WEB-INF/lib folder, so that org.hibernate.ejb.HibernateEntityManagerFactory is visible in class path. Since all hibernate libraries are not available and also you specified another implementation (TopLink) in your META-INF/persistence.xml, Hibernate is bypassed and TopLink is used instead.

Thursday, November 8, 2007

Typos in Digital Copies of Yusuf Ali Translation

There are a number of copies of widely-known Quran translation of Abdullah Yusuf Ali on the web. Since most of the digital copies are using the text provided by USC-MSA (which is actually extracted by means of OCR), they all have the same typo for 23:22.

Today, I noticed a bug report for Zekr's Yusuf Ali translation, which mentioned the typo. I then checked the printed copy of the book on Google books and found the original text, which was different in 4 places.

The original Arabic text for Sura Al-Muminun, aya 22 is:
وَعَلَيْهَا وَعَلَى الْفُلْكِ تُحْمَلُونَ

the right English translation of Yusuf Ali is:
And on them, as well as in ships, ye ride.

while many websites have the meaningless translation:
An on them, as well as in slips, ye side.

I just tried a Google search and found that the buggy one is more commonly used than the right one. My first query resulted in 6 items, while the second one (buggy) resulted in 27. The copy on on Wikisource also had that problem, which is now fixed.

Special thanks to Benjamin Geer for pointing out these typos.

Friday, September 21, 2007

یادی از علامه سید مرتضی عسکری و اندیشهٔ وحدت اسلامی


خدا رحمت کند علامهٔ فقید سید مرتضی عسکری را. این مقاله را امروز توی سایت تقریب دات آی‌آر دیدم. یکی دو قسمت جالب رو اینجا نقل می‌کنم. متن کاملش رو از اینجا ببینید.
خدای سبحان می‏فرماید: «ان هذه امتکم امة واحدة وانا ربکم فاعبدون‏» (انبیاء /92)؛ این پیامبران بزرگی که به آنان اشاره کردیم (و پیروانشان) همه یک امت واحد بودند و من پروردگار شمایم، تنها مرا بپرستید.
...
وحدت عملی
در این باره از باب مثال عرض می‏کنم: ما در مکتب اهل بیت (علیهم السلام) حُکمی داریم مبنی بر این که «هر کس در نماز بسم‏الله الرحمن الرحیم نگوید نمازش باطل است‏»، و نمی‏توان به او اقتدا کرد ولی با توجه به این که برادران حنفی مذهب ما چنین عقیده‏ای ندارند و حمد را بدون «بسم‏الله‏» قرائت می‏کنند، از ائمه ما در کتاب «وسائل الشیعه‏»، در سه حدیث از امام صادق (علیه السلام) آمده‌است که فرمود:
«من صلي خلفهم كان كمن صلي خلف رسول الله‏»، (یعنی؛ کسی که پشت‏سر آنان نماز بخواند، مانند آن است که پشت‏سر رسول خداصلی الله علیه وآله نماز خوانده است)، با این که آن امام [جماعت] حنفی «بسم‏الله‏» نمی‏گوید. در حدیث دیگری آمده:
«اذا صلّيت معهم غفرلك بعدد من خالفك - في قراءة البسملة - و حضر الصلاة في المسجد»، (یعنی؛ هر گاه تو با آنان نماز بگزاری، به تعداد کسانی که در خواندن بسم‏الله با تو مخالفت کرده و در مسجد به نماز ایستاده‏اند، از گناهانت آمرزیده می‏شود).
راوی دیگری به امام صادق (علیه السلام) شکایت می‏کند و می‏گوید: «امام جماعت ما در عقیده مخالف با ماست، او همه یاران ما [شیعیان] را دشمن می‏دارد، [وظیفه ما چیست؟]. امام (علیه السلام) فرمود: از سخن وی چیزی بر تو نیست، به خدا سوگند اگر آنچه می‏گویی راست باشد، تو از او به امامت در مسجد سزاوارتری، تو در ورود به مسجد نخستین و در خروج از آن آخرین نفر باش و با مردم خوشرفتاری کن و سخن نیکو بگو.
از فرمایش امام صادق (علیه‏السلام) برمی‏آید که آن حضرت از سخن راوی و انتقادش خشنود نشده، لذا به او فرمودند: با مردم خوش‌رفتار باش و نیکو سخن بگو.
امام صادق (علیه السلام) به راوی دیگری فرمود:
«یا اسحاق! اتصلی معهم فی المسجد؟ قال: قلت نعم، قال: «صل معهم، فان المصلي معهم في الصف الاول كالشاهر سيفه في سبيل الله‏» (*) ، ای اسحاق، آیا با آنان [مخالفان] نماز می‏گزاری؟ گفتم: آری؛ فرمود: با آنان نماز بگزار، همانا، نمازگزار با آنان در صف اول، مانند کسی است که در راه خدا شمشیر کشیده است.
بدین سان وحدت عملی تحقق می‏یابد.
امام صادق (علیه السلام) شخصاً با ابوحنیفه می‏نشست و در عقاید و احکام با وی مناظره می‏کرد، و این کار تا زمان شیخ مفید در بغداد معمول بود. شیخ طوسی استاد کرسی تدریس در دارالخلافه بود، ولی سلاجقه که به بغداد رفتند، کرسی شیخ را سوزاندند و میان ما جدایی افکندند، سپس اختلافهایی میان صفویه و خلافت عثمانی پدید آمد، و این اختلافات در واقع از سیاست ناشی می‏شد نه از دین.

(*) و در این لحظه کتاب «معالم المدرستین‏» را با دست‏خویش بلند کرد.

منبع: مجمع جهانی تقریب مذاهب اسلامی