[sword-devel] search function?

Kevin Field kev at brantaero.com
Fri Oct 1 13:19:58 MST 2004


Troy,

Thanks for all the info!  I didn't entirely get all of it, but it made 
things a lot clearer than they were last night while I was staring the 
code and scratching my head.  I'll look into it more and probably have 
more questions for you.  I haven't tried the build option yet--I think 
I've got 1.5.7a.  Should I get subversion going and get the latest 
goodies?

Thanks again,

Kev

> Kev,
> 	Sure!  We'd always love the help.  Briefly, (this assumes you 
> understand the SWModule/SWKey construct in the API) a key has the 
> concept of a numeric index().  Basically, the current modus opperandi 
> in 
> SWModule::search is to set the module to the end, check the module's 
> key->index() and use that as the high value.  Then, set the module to 
> the beginning and start the search.  After performing the search for 
> an 
> individual entry, the key->index() is checked to see where we're at, 
> do 
> the math, and report the %.
> 
> 	A different way to do this would be to add an 
> SWModule::entryCount(), 
> use that as the high count, and merely have an int pos that we pos++ 
> while iterating during the search.
> 
> 	You'd need to try to provide a basic impl in SWModule::entryCount 
> and 
> possibly override with a better method for Bibles in 
> SWText::entryCount 
> or SWLexDict::entryCount for Bibles, or maybe even make it pure 
> virtual 
> and force the drivers to supply the information.
> 
> 	The danger to consider is that we are adding the requirement for an 
> SWModule to be able to calculate the number of entries total in it's 
> range.  This is not the case for many types of keys, e.g. keys for 
> lexicons.
> 
> 
> Keys cannot always do this for the module.  A VerseKey for a 
> canonization probably can do this, so Bibles can likely rely on their 
> key to report this to them (so your search range in VerseKey could 
> adjust).  But, for a lexicon it's different.  A lexicon knows how 
> many 
> entries it has in it (probably), but the key is merely a StrKey.  It 
> is 
> not SWKey::isTraversible().  The Lexicon is traversable, but the key, 
> all by itself, is not traversible.  To try to be clear:
> 
> VerseKey::isTraversible() == true
> because it means something to say "John 3:16"++ OUTSIDE of any given 
> Bible.
> 
> StrKey::isTraversible() == false
> because is does NOT mean something to say "Jerusalem"++ OUTSIDE of 
> any 
> given module.
> 
> 
> Sorry, most of this is just random information.  I'd be happy to 
> discuss 
> or look at any solution you might submit.
> 
> 	-Troy.
> 
> 
> 
> Kevin Field wrote:
> > Hi Troy,
> > 
> > Ah, that makes sense, as we've always been passing a scope.  I 
> > guess 
> > the best thing to do would be to not provide a scope if the scope 
> > is 
> > just going to be the whole Bible anyway.  Better yet, could I help 
> > get 
> > that into the Sword library itself?  From there I could go to 
> > getting 
> > it working if it's a single range, and then multiple ranges 
> > wouldn't be 
> > too much harder.
> > 
> > Thanks,
> > 
> > Kev
> > 
> > 
> >>Kev,
> >> 	The status callback mechanism does good in many scenerios, and 
> > > not 
> >>so good in others.  We hope to improve it.  A case where I remember 
> >>it 
> >>acting as you have posted is when one provides a search 'scope'.  
> > > We 
> >>haven't added the logic to try to figure out the complete domain of 
> >>the 
> >>search scope (e.g. "gen-deut;1jn;rev1:1-5:19").  So we don't really 
> >>have 
> >>the data to report a %.  It's not that it can't be done, but just 
> >>hasn't 
> >>been done yet.  Hope this helps.
> >>
> >> 	-Troy.
> > 
> > 
> > _______________________________________________
> > sword-devel mailing list
> > sword-devel at crosswire.org
> > http://www.crosswire.org/mailman/listinfo/sword-devel
> 
> 
> ------------------------------
> 
> Message: 3
> Date: Thu, 30 Sep 2004 23:39:09 -0700
> From: "Troy A. Griffitts" <scribe at crosswire.org>
> Subject: Re: [sword-devel] search function?
> To: "SWORD Developers' Collaboration Forum"
> 	<sword-devel at crosswire.org>
> Message-ID: <415CFB8D.3020702 at crosswire.org>
> Content-Type: text/plain; charset=us-ascii; format=flowed
> 
> Kev,
> 	One last thing.  Have you tried the Lucene feature that you can 
> enable 
> in the build?  It makes many search scenerios return fairly 
> instantaneous.  :)



More information about the sword-devel mailing list