[sword-devel] Re: Fw: building indexers.

Troy A. Griffitts sword-devel@crosswire.org
Tue, 21 Dec 1999 01:31:26 -0700


> i dont know where to put what. sorry. how and when to call the routine. where in Sword?

:)  You don't yet.  I will call your method.  I will put it all in
place, just needed the sort algorythm from you, and via our mail this
afternoon and this message, I believe we have it.

Just to be sure I understand correctly, all characters in your index
words only contain the ascii values below (224-250)?


> i made the wieght table.
> 
> hebrewCharacters[224]=0;    /* àalef */
> hebrewCharacters[225]=1;    /* ábet */
> hebrewCharacters[226]=2;    /* âgimel */
> hebrewCharacters[227]=3;    /* ãdalet */
> hebrewCharacters[228]=4;    /* äheh */
> hebrewCharacters[229]=5;    /* åvav */
> hebrewCharacters[230]=6;    /* æzayin */
> hebrewCharacters[231]=7;    /* çchet */
> hebrewCharacters[232]=8;    /* ètet */
> hebrewCharacters[233]=9;    /* éyod */
> hebrewCharacters[234]=10;    /* êchaf-sofit */
> hebrewCharacters[235]=11;    /* ëchaf */
> hebrewCharacters[236]=12;    /* ìlamed */
> hebrewCharacters[237]=13;    /* ímem-sofit */
> hebrewCharacters[238]=14;    /* îmem */
> hebrewCharacters[239]=15;    /* ïnun-sofit */
> hebrewCharacters[240]=16;    /* ðnun */
> hebrewCharacters[241]=17;    /* ñsamech */
> hebrewCharacters[242]=18;    /* òayin */
> hebrewCharacters[243]=19;    /* ópeh-sofit */
> hebrewCharacters[244]=20;    /* ôpeh */
> hebrewCharacters[245]=21;    /* õtzadi-sofit */
> hebrewCharacters[246]=22;    /* ötzadi */
> hebrewCharacters[247]=23;    /* ÷qof */
> hebrewCharacters[248]=24;    /* øresh */
> hebrewCharacters[249]=25;    /* ùshin */
> hebrewCharacters[250]=26;    /* útav */
> 
> ----- Original Message -----
> From: Troy A. Griffitts <scribe@crosswire.org>
> To: Yeshiah Zalman <shayah@gatecom.com>; <sword-devel@crosswire.org>
> Sent: Monday, December 20, 1999 5:03 PM
> Subject: Re: Fw: building indexers.
> 
> > OK, all you need to do is right a small C / C++ function that receive 2
> > character arrays and returns -1 if the first one is less than the second
> > one; 1 if the first one is greater than the second one, and 0 if they
> > are equal.  for ascii comparisons of standard english letters, I would
> > write something like this:
> >
> > int compare(char *value1, char *value2) {
> > int offset;
> >
> > while (true) { infinite loop that we will 'return' out of
> > if ((value1[offset] == 0) && (value2[offset] == 0))  // end of both
> > return 0; // strings are equal
> > if (value1[offset] == 0) // we've hit the end of the first string
> > return -1;
> > if (value2[offset] == 0)  // end of second string
> > return 1;
> > if (value1[offset] > value2[offset])
> > return 1;
> > if (value1[offset] < value2[offset])
> > return -1;
> > offset++; // characters at this pos must be ==
> > // goto next pos and continue checking
> >
> > }
> > }
> >
> > __________________________________________--
> >
> > you may need to create an array of ascii values and their 'weight' for
> > comparison.
> > char hebrewCharacters[255];
> > hebrewCharacters[<ascii value of Aleph>]  = 0;
> > hebrewCharacters[<ascii value of Bet>]    = 1;
> > hebrewCharacters[<ascii value of Gimmel>] = 2;
> > and so one...
> >
> > And then use this array in your comparison like:
> > Change the 2 checks above from:
> >
> > if (value1[offset] > value2[offset])
> > return 1;
> > if (value1[offset] < value2[offset])
> > return -1;
> >
> > to:
> > if (hebrewCharacters[value1[offset]] >
> > hebrewCharacters[value2[offset]])
> > return 1;
> > if (hebrewCharacters[value1[offset]] <
> > hebrewCharacters[value2[offset]])
> > return -1;
> >
> >
> > ______________________________________________________
> >
> > Hope this helps.....
> > Hope this code actually compiles :)
> >
> >
> >
> > Yeshiah Zalman wrote:
> > >
> > > I feel bad, you lost me!
> > > please be patient.
> > > Considering 2 months ago I knew NOTHING of
> > > Sword OR Cbuilder.
> > >
> > > Please explain step by step WHAT and where?
> > > Heh I develkoped a neat VB dictionary which sits as a BAR on the top of your screen. But C is harder.
> > >
> > > thank you for your patience.
> > >
> > > ----- Original Message -----
> > > From: Troy A. Griffitts <scribe@crosswire.org>
> > > To: Yeshiah Zalman <shayah@gatecom.com>; <sword-devel@crosswire.org>
> > > Sent: Monday, December 20, 1999 3:40 PM
> > > Subject: Re: Fw: building indexers.
> > >
> > > > Yeshiah,
> > > > I've been giving your delema some thought and believe that I have a
> > > > proper solution in mind instead of a hack.  I will allow you to
> > > > 'register' a 'compare' method for a lexdict module that will be used
> > > > when doing the lookup.  The compare method will take 2 char * (Strings)
> > > > and should return same as strcmp (<0 for 1 < 2; >0 for 1 > 2; and 0 for
> > > > 1 == 2).  The sig should be something like:
> > > >
> > > > int compare(char *value1, char *value2);
> > > >
> > > > This means that the file should be sorted in such a way that:
> > > > for (module == TOP; !module.Error(); module++) {
> > > > if (compare(module.KeyText(), (module + 1).KeyText()) > 0)
> > > > fprintf(stderr, "ERROR: %s is greater than %s", module.KeyText(),
> > > > (module + 1).KeyText());
> > > > }
> > > >
> > > > Does this make sense?  All I need from you is a proper implementation of
> > > > the compare method and a properly sorted module.
> > > >
> > > > Any feedback from you or anyone else on this implementation is greatly
> > > > appreciated....
> > > >
> > > > -Troy