Monday, August 31, 2009

Hebrew Conjugator - a Delphi Prism Project

For the past few weeks, I have been working on a Delphi Prism project, a Hebrew verb conjugation program. It is meant to handle regular as well as irregular verbs.


The program consists of two parts, a conjugation library HebrewConjugation.dll and a front end HebrewConjugator.exe. The library defines a class HebrewWord as well as a class Conjugation, a base class from which the several conjugations (in Hebrew: binyanim = buildings) are derived. So far I have implemented parts of two conjugation classes, ConjugationPa3al and ConjugationPi3el.


The base class also defines as constants all letters of the Alefbet (Hebrew alphabet), helper methods to access the characters (for example to modify final letters when appropriate), and empty conjugation methods that simply return empty strings.


public

function Alefbet(i: Int32): String;

function Sofit(s: String): String;

function GetInfinitive(root: String): String; virtual;

function GetPresentTense(root: String; person: Integer; male: Boolean): String; virtual;

function GetPastTense(root: String; person: Integer; male: Boolean): String; virtual;

function GetFutureTense(root: String; person: Integer; male: Boolean): String; virtual;


An object of the type HebrewWord creates an object named conjugation first of the type Conjugation (i.e. the base class) and then of the correct type (e.g. ConjugationPa3al) if such a class already exists. (This means that all conjugations will technically work and not throw exceptions. If a conjugation is not implemented yet, it will return empty strings for any finite verb form requested.)


Catching irregular verbs is done step-by-step, like here:


function ConjugationPa3al.GetPastTense(root: String; person: Int32; male: Boolean): String;

var


r: String;


begin


if (root.Length = 2) then begin // two-letter root


r := GetPresentTenseHollow(root, person, male);


result := r;


exit;


end else begin // three-letter root



The Windows.Forms front end doesn't work on Mac OS X because of, I think, a bug in how Mono handles right-to-left scripts. (Input also doesn't work. I reported the bug to Novell.) So the current version runs on Windows (and perhaps Linux, I haven't tried).


I was planning to build separate front ends for Mac OS X (Monobjc) and Linux (GTK#) anyway, also for WPF and Silverlight (if I find the time).


Plus I plan to add an option to save a root and all finite forms in a (Blackfish SQL) database so that a conjugation once corrected and confirmed can be remembered by the program and accessed when the same root is asked again.


Currently the following items work:


Pa3al: infinitive, present tense (i.e. nouns), past tense (i.e. perfect tense)

Pi3el: infinitive, present tense

Hif3il: nothing

Hitpa3el: nothing

passive conjugations: not supported at all for the moment


Wish me luck!