[sword-devel] Dictionary ordering

Greg Hellings greg.hellings at gmail.com
Thu Sep 18 08:25:15 MST 2008


On Thu, Sep 18, 2008 at 1:24 AM, Ben Morgan <benpmorgan at gmail.com> wrote:
> Strong's numbers are padded by 0, which is why they currently sort properly.
>
> Such a sort order sounds a good idea (though perhaps not for the developers
> ;).
> Modules produced in such a way wouldn't be compatible with Sword <= 1.5.11,
> though.

They could certainly be designed to be compatible.  Sticking the
sorted list of keys in a separate file, while maintaining the current
files for the dictionary in the same format would result in forwards
and backwards compatibility.

>
> I still suspect that sorting isn't quite as easy as specifying a simple sort
> order such as you suggested.
> Once diacritics enter into it (especially non-composed diacritics), things
> could get a little more difficult.
> Perhaps allowing the delimiter separated variables to be longer than 1
> character long might help.

That's the point of having them space-delimited.  You can have an
arbitrarily length string for each character, and each string would be
replaced with a single, unique integer.

>
> This still won't catch everything, but it would be a good thing to have - I
> think I've seen english dictionaries which put "St. Something" entries at
> the start of S...

Sure it would.  If you started with the longest entry in the list and
moved backwards to the shortest entries, then St. would be given its
own value before you got to the S itself.  It wouldn't be an issue.

>
> As for the example 'tis, you can't catch everything. This is when you want
> to do a search on the keys of the dictionary.

That depends on how you implement characters which are not in the
specified ordering sequence.  Probably the best thing to do with them
is to completely ignore them, if an explicit order is specified.  That
way, 'tis and tis would be sorted identically by the algorithm.

The only major problem is the complexity of doing all of the search
and replace through the keys.  Obviously, storing the results in a
cache somewhere would be the only performance-responsible method, and
only resorting if the sort order has changed since the cache was
created.  Thus, having the cache in an additional file that only
versions >1.5.11 read, while <=1.5.11 would just ignore that, would
still allow forwards and backwards version compatibility.

All of that is, of course, if such is still needed with the current
version of tei2mod that DM is talking about.

--Greg

>
> God Bless,
> Ben
> -------------------------------------------------------------------------------------------
> The Lord is not slow to fulfill his promise as some count slowness,
> but is patient toward you, not wishing that any should perish,
> but that all should reach repentance.
> 2 Peter 3:9 (ESV)
>
>
> 2008/9/18 Greg Hellings <greg.hellings at gmail.com>
>>
>> On Wed, Sep 17, 2008 at 10:38 PM, Daniel Owens <dhowens at pmbx.net> wrote:
>> >
>> >
>> > Greg Hellings wrote:
>> >
>> > On Wed, Sep 17, 2008 at 9:56 PM, Daniel Owens <dhowens at pmbx.net> wrote:
>> >
>> >
>> > Ben,
>> >
>> > Thanks for the explanation. It seems to me that setting up dictionaries
>> > to
>> > use key retrieval from an uncompressed file with one key per line
>> > (ordered
>> > as the module creator orders it) makes the most sense to me. If that
>> > helps
>> > increase efficiency and preserves the order of dictionary entries, then
>> > that
>> > is what we want.
>> >
>> >
>> > Would it also be possible to put a space-delimited (or anything else
>> > delimited) list of the order that characters ought to be arranged in
>> > for a given dictionary?  Then the module creator could put them in
>> > whatever is desired in the import file, and the ordering can be based
>> > off of the configuration file.  Sorting would be as simple as
>> > replacing the characters in each entry with an integer and sorting the
>> > resulting vectors.  In the absence of a sort-field, then the module
>> > import file's order could default (or the current behavior, whichever
>> > is deemed better)?
>> >
>> >
>> > --Greg
>> >
>> >
>> >
>> > What if one of the TEI elements were an integer (much like Strong's)?
>> > The
>> > dictionary could be sorted by that integer but entries would not display
>> > the
>> > integer but rather the actual word entry.
>>
>> I would suppose, in that case, the sorting could be left in the
>> default mode of sorting based on the document's type.  Alternatively
>> two config entries could be devised.
>> Sorting=None|Default|Config
>> SortOrder=a b c d e...
>>
>> The Sorting=None would be sorting left in the order of the import
>> file, Default would be the current (and default) behavior and Config
>> would indicate to follow the sorting order listed in SortOrder, which
>> could be completely arbitrary, based on the module creator's
>> preferences.  For a language or a listing which used numerals, like
>> Strongs, they would not be perturbed by either the original scheme or
>> this expanded suggestion.  Since the characters of the Strongs entries
>> are distinct from integers, and the mapping would take characters into
>> integers for the sorting process, then back into their original
>> characters, no violence would be done to the Strongs numbers
>> themselves.  If there was a mixture of letters and numbers, it still
>> wouldn't be a problem, and the module creator could include the
>> integers wherever they wanted in the SortOrder listing.
>>
>> --Greg
>>
>> >
>> > Daniel
>> >
>> > I will agree that the sorted order is not as important in BPBible
>> > because of
>> > the lookup feature, but that breaks down when you need to browse further
>> > within a range of entries. Furthermore, the example of "'tis" suggests
>> > that,
>> > even in English, code pointing disturbs the natural order of the
>> > dictionary,
>> > making it harder to browse for the right entry. Unless you type in the
>> > apostrophe, you won't find "'tis" because it will not be near "t" but be
>> > at
>> > the top of the dictionary, which is very far away. In BibleDesktop,
>> > which
>> > doesn't yet have the lookup feature yet, you have to browse for any
>> > dictionary entry (except Strongs, where the key is a number and
>> > therefore in
>> > printed order!), so the ordering really does matter. Also, frankly, a
>> > dictionary out of alphabetical order just looks silly. In Vietnamese
>> > it's
>> > chaotic when dictionaries are ordered by code point. Who ever heard of a
>> > dictionary where "d" comes after "z"? That's what happens in Vietnamese.
>> >
>> > Daniel
>> >
>> > Ben Morgan wrote:
>> >
>> > Hi Daniel,
>> >
>> > Code points are not the only way to sort it.
>> > However, there does need to be a comparison function defined, which will
>> > compare two words and give which is bigger.
>> > This needs to be used consistently, from module creation to frontend.
>> > There
>> > could be a library of defined comparators provided by SWORD - but you
>> > would
>> > need one for each sort order you wanted (which approaches one per
>> > language).
>> >
>> > Personally, I don't find that sorted order is particularly important in
>> > dictionaries - I would type in a word, and then hope that if it is a
>> > different form of the word it would be relatively close. Some frontends
>> > may
>> > not give the ability to type in words, though.
>> >
>> > But I haven't used dictionaries in other languages, so it may be
>> > different
>> > for them - especially once diacritics are involved.
>> >
>> > The reasons why dictionaries are different from bibles are:
>> > 1) Bibles have a known structure, which is hardcoded in the key type
>> > (this
>> > is going to be able to change soon, for alternate versification, though
>> > -
>> > probably leading to less efficient modules)
>> > 2) Dictionaries can be much, much larger - Websters is a 14Mb download
>> > compressed, as compared to the WEB's ~1.5Mb
>> >
>> > That's not to say the dictionaries can't be done more efficiently than
>> > they
>> > are currently. Looking at the code, they could be quicker for the
>> > (common?)
>> > case of incrementing a module. Currently they do a binary search for
>> > every
>> > increment.
>> > Further, they could probably be optimized for key retrieval - which is
>> > the
>> > really important thing here. (For example by storing the keys
>> > separately,
>> > uncompressed, 1 key per line)
>> >
>> > God Bless,
>> > Ben
>> >
>> > -------------------------------------------------------------------------------------------
>> > The Lord is not slow to fulfill his promise as some count slowness,
>> > but is patient toward you, not wishing that any should perish,
>> > but that all should reach repentance.
>> > 2 Peter 3:9 (ESV)
>> >
>> >
>> > On Thu, Sep 18, 2008 at 11:21 AM, Daniel Owens <dhowens at pmbx.net> wrote:
>> >
>> >
>> >
>> >  Is code point order the ONLY way to sort dictionary entries? Surely
>> > there
>> > is a solution which would retain the printed or intended order of
>> > dictionary
>> > entries without giving up lots of efficiency. If not, I think users
>> > would
>> > find a correctly ordered but slower dictionary to one which is fast but
>> > jumbled up.
>> >
>> > At the very least, even if dictionaries aren't sorted by the printed
>> > order,
>> > they should AT LEAST be in alphabetical order. To me that is a
>> > non-negotiable for a dictionary--people depend on dictionaries being in
>> > the
>> > right order, and code point order disturbs that for some languages. Here
>> > are
>> > a couple of ideas:
>> >     - Could a configuration file of some sort be created to define a
>> > sorted order for a given language that would actually be in alphabetical
>> > order?
>> >     - Could a dictionary index be created to handle large dictionaries
>> > which allows for the retention of the correct order of entries (whether
>> > that
>> > is the printed order or alphabetical order)?
>> >     - Bibles are not ordered by code point, and we are able to search
>> > them
>> > fairly quickly. Do dictionaries need to be compiled in a fashion similar
>> > to
>> > Bibles?
>> >
>> > As it stands, dictionaries are NOT displayed in alphabetical order (at
>> > least not Vietnamese, and apparently Farsi), which at best looks silly
>> > to
>> > the user and at worst means you have to manually hunt around to find the
>> > right entry, making a Genbook more efficient for the user in the end.
>> > But
>> > then you lose the dictionary lookup feature.
>> >
>> > Daniel
>> >
>> > Ben Morgan wrote:
>> >
>> > The issue with ordering as I understand it is that if it is in (some
>> > form
>> > of) sorted order, you can use binary search to find entries.
>> > If you want order retained, it is best to use a genbook - but it won't
>> > be as
>> > efficient, and may not have as good UI support.
>> > With huge english dictionaries (like Webster's, for instance) this
>> > becomes
>> > very important.
>> >
>> > >From BPBible's perspective, dictionary handling is done as follows:
>> > 1. Read the index of the dictionary and divide by 4 or 6 to get the
>> > length
>> > (depending on the driver)
>> > 2. Set the virtual list length to the dictionary length
>> > 3. When any item is displayed in the virtual list, it retrieves it from
>> > the
>> > module.
>> > 4. When the user starts typing in the text box above, it does a binary
>> > search to find which item to display.
>> >
>> > 4 is already quite slow enough on big dictionaries - by having it
>> > unsorted,
>> > it would make it quite a lot slower, I imagine.
>> > All the keys from the module would have to be read in, which takes a
>> > while.
>> >
>> > God Bless,
>> > Ben
>> >
>> > ------------------------------------------------------------------------------------------
>> > -
>> > The Lord is not slow to fulfill his promise as some count slowness,
>> > but is patient toward you, not wishing that any should perish,
>> > but that all should reach repentance.
>> > 2 Peter 3:9 (ESV)
>> >
>> >
>> > On Thu, Sep 18, 2008 at 12:43 AM, Daniel Owens <dhowens at pmbx.net>
>> > <dhowens at pmbx.net> wrote:
>> >
>> >
>> >
>> >  mention that byte ordering does some strange things to Vietnamese
>> > dictionaries. The Vietnamese script is a Latin script, but because it
>> > uses
>> > some odd characters code point ordering results in illogical and
>> > non-alphabetical entry ordering. For example, the "d" with a line
>> > through it
>> > (đ) gets relegated to near the end of the dictionary instead of after
>> > the
>> > regular "d" or anything with an apostrophe at the beginning of a word or
>> > phrase gets moved to the top of the list regardless of the first letter
>> > (such as 'tis). I am supportive of the IIRC general opinion. Let the
>> > module
>> > creator worry about the ordering. Otherwise you get some very strange
>> > dictionary behavior.
>> >
>> >
>> >
>> > ------------------------------
>> >
>> > _______________________________________________
>> > sword-devel mailing list:
>> >
>> > sword-devel at crosswire.orghttp://www.crosswire.org/mailman/listinfo/sword-devel
>> > Instructions to unsubscribe/change your settings at above page
>> >
>> >
>> > --
>> > PMBX license 1502
>> >
>> >
>> > _______________________________________________
>> > sword-devel mailing list: sword-devel at crosswire.org
>> > http://www.crosswire.org/mailman/listinfo/sword-devel
>> > Instructions to unsubscribe/change your settings at above page
>> >
>> >
>> >
>> > ________________________________
>> > _______________________________________________
>> > sword-devel mailing list: sword-devel at crosswire.org
>> > http://www.crosswire.org/mailman/listinfo/sword-devel
>> > Instructions to unsubscribe/change your settings at above page
>> >
>> > --
>> > PMBX license 1502
>> >
>> > _______________________________________________
>> > sword-devel mailing list: sword-devel at crosswire.org
>> > http://www.crosswire.org/mailman/listinfo/sword-devel
>> > Instructions to unsubscribe/change your settings at above page
>> >
>> >
>> >
>> > _______________________________________________
>> > sword-devel mailing list: sword-devel at crosswire.org
>> > http://www.crosswire.org/mailman/listinfo/sword-devel
>> > Instructions to unsubscribe/change your settings at above page
>> >
>> >
>> >
>> > --
>> > PMBX license 1502
>> >
>> > _______________________________________________
>> > sword-devel mailing list: sword-devel at crosswire.org
>> > http://www.crosswire.org/mailman/listinfo/sword-devel
>> > Instructions to unsubscribe/change your settings at above page
>> >
>> _______________________________________________
>> sword-devel mailing list: sword-devel at crosswire.org
>> http://www.crosswire.org/mailman/listinfo/sword-devel
>> Instructions to unsubscribe/change your settings at above page
>
>
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page
>


More information about the sword-devel mailing list