<div dir="ltr">BPBible already has code which (attempts) to check if a chapter is present.<div><a href="https://code.google.com/p/bpbible/source/browse/trunk/backend/book.py?spec=svn1419&r=1414#716">https://code.google.com/p/bpbible/source/browse/trunk/backend/book.py?spec=svn1419&r=1414#716</a></div>
<div><br></div><div>Note this isn't yet av11n compliant, but the general principle should be much the same. It's in Python but should be pretty much the same in C++</div><div><br></div><div>Basically, this takes advantage of hasEntry and also of <span class="" style="color:rgb(102,102,0);font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono','Lucida Console',monospace;font-size:12px;white-space:pre-wrap"><span class="" style="color:rgb(0,0,0)">module</span><span class="">.</span><span class="" style="color:rgb(0,0,0)">setSkipConsecutiveLinks</span><span class="">(</span><span class="" style="color:rgb(0,0,136)">True</span><span class="">)</span> and module.increment()</span></div>
<div><span class="" style="color:rgb(102,102,0);font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono','Lucida Console',monospace;font-size:12px;white-space:pre-wrap"><br></span></div><div>
<span class="" style="color:rgb(102,102,0);font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono','Lucida Console',monospace;font-size:12px;white-space:pre-wrap">(similar code is also used in the rendering loop so that it can detect linked verses to give verse numbers like "3-5", see the somewhat messy code here <a href="https://code.google.com/p/bpbible/source/browse/trunk/backend/book.py?spec=svn1419&r=1414#231">https://code.google.com/p/bpbible/source/browse/trunk/backend/book.py?spec=svn1419&r=1414#231</a>)</span></div>
</div><div class="gmail_extra"><br clear="all"><div>God Bless,<br>Ben<br>-------------------------------------------------------------<br>
        <div>
        <div>For I have no pleasure in the death of anyone, <br>declares the Lord <span style="font-variant:small-caps">God</span>; so turn, and live.”<br>Ezekiel 18:32 (ESV)</div>
        </div>
        
<br></div>
<br><br><div class="gmail_quote">On Mon, May 13, 2013 at 6:57 PM, John Austin <span dir="ltr"><<a href="mailto:gpl.programs.info@gmail.com" target="_blank">gpl.programs.info@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
<br>
On 05/13/2013 10:30 AM, Troy A. Griffitts wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
We have the first part already in the API:<br>
<br>
SWModule::hasEntry(const SWKey *)<br>
<br>
What sort of use cases do we have to build further API calls on this?<br>
<br>
vector<string> getBooksPresent()<br>
<br>
???<br>
</blockquote></div>
Yes- or even just:<br>
<br>
bool isBookPresent(aBook)<br>
<br>
and there also probably needs to be something like:<br>
<br>
int lastChapterPresent(aBook)<br>
<br>
An example of why this would be useful is seen in v11n Synodal, the book of Daniel. The last two chapters (13-14) are Apocryphal material which many translations purposefully exclude. Psalms 151 in Synodal is the same. So something like lastChapterPresent(aBook) allows correct building of chapter lists etc.<br>
<br>
and then something like:<br>
<br>
int lastVersePresent(aBook, aChapter)<br>
<br>
An example for its usefulness would again be in Synodal, the book of Daniel. Daniel chapter 3 verses 34-100 are Apocryphal and will be excluded from many Synodal modules. Having lastVersePresent would allow verse lists etc. to be built according to the actual module's content.<br>
<br>
Usually these last-Present functions would simply check hasEntry on the last unit and quickly return. Only in rare cases would they actually need to iterate to find the answer.<br>
<br>
This API has the advantage over the Scope .conf param in that it allows module content to be fully queried even if the module makers failed to supply a Scope param. On the other hand, it requires installation of the module before "scope" can be determined, whereas having Scope in the .conf allows pre-install knowledge of what's in a given module. But if this becomes the Scope param's only usefulness, maybe Scope should then be simplified substantially to indicate only the included books within the module, and not chapters and verses too, which can get hairy.<span class="HOEnZb"><font color="#888888"><br>
<br>
John</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
<br>
<br>
<br>
<br>
On 05/12/2013 07:11 PM, DM Smith wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
More:<br>
Once that is written, the worst case for analysis is a book that is<br>
entirely absent. Basically, when you find something from a book, you<br>
don't need to look any further in the book and go to the next.<br>
<br>
<br>
On May 12, 2013, at 10:06 PM, DM Smith <<a href="mailto:dmsmith@crosswire.org" target="_blank">dmsmith@crosswire.org</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
JSword (Java) is quite different from SWORD (C++). But I'll give you<br>
an overview. Each module has a similar structure. There is an index<br>
file where slots have records indicating offset and size into a data<br>
file. For a Bible module, each slot represents a verse.<br>
<br>
If the size is 0 then that indexed location is empty. A compressed<br>
module is slightly more complicated. The index consists of two parts.<br>
But the idea is the same. If the length of the data is 0, then it is<br>
empty.<br>
<br>
Basically if you look at the chain of calls to get the raw text of a<br>
verse, it digs down and at some point it gets the data size. Our code<br>
merely bails once it gets the data size.<br>
<br>
I can point you to our Java code, if you like, but I don't know how<br>
much that'd help.<br>
<br>
In Him,<br>
DM<br>
<br>
On May 12, 2013, at 9:53 PM, Nic Carter <<a href="mailto:niccarter@mac.com" target="_blank">niccarter@mac.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi DM,<br>
<br>
On 12/05/2013, at 7:40 AM, DM Smith <<a href="mailto:dmsmith@crosswire.org" target="_blank">dmsmith@crosswire.org</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Chris Burrell added some code to JSword that allows for the quick<br>
determination of whether a verse is present in a module. He is<br>
using this in STEP to prune the v11n to only those books, chapters<br>
and verses that are actually present. On old slow hardware he<br>
reported that it is very fast to analyze an entire module.<br>
</blockquote>
Could you please let me know where this is? Would be interesting to<br>
look at and see how it performs on a handheld in C++ or Obj-C :)<br>
<br>
Thanks heaps, ybic<br>
nic... :)<br>
<br>
ps: I don't know the JSword codebase at all, so it may be easier if<br>
I'm pointed in the right direction rather than trying to find it :)<br>
______________________________<u></u>_________________<br>
sword-devel mailing list: <a href="mailto:sword-devel@crosswire.org" target="_blank">sword-devel@crosswire.org</a><br>
<a href="http://www.crosswire.org/mailman/listinfo/sword-devel" target="_blank">http://www.crosswire.org/<u></u>mailman/listinfo/sword-devel</a><br>
Instructions to unsubscribe/change your settings at above page<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
sword-devel mailing list: <a href="mailto:sword-devel@crosswire.org" target="_blank">sword-devel@crosswire.org</a><br>
<a href="http://www.crosswire.org/mailman/listinfo/sword-devel" target="_blank">http://www.crosswire.org/<u></u>mailman/listinfo/sword-devel</a><br>
Instructions to unsubscribe/change your settings at above page<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
sword-devel mailing list: <a href="mailto:sword-devel@crosswire.org" target="_blank">sword-devel@crosswire.org</a><br>
<a href="http://www.crosswire.org/mailman/listinfo/sword-devel" target="_blank">http://www.crosswire.org/<u></u>mailman/listinfo/sword-devel</a><br>
Instructions to unsubscribe/change your settings at above page<br>
</blockquote>
<br>
<br>
______________________________<u></u>_________________<br>
sword-devel mailing list: <a href="mailto:sword-devel@crosswire.org" target="_blank">sword-devel@crosswire.org</a><br>
<a href="http://www.crosswire.org/mailman/listinfo/sword-devel" target="_blank">http://www.crosswire.org/<u></u>mailman/listinfo/sword-devel</a><br>
Instructions to unsubscribe/change your settings at above page<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
sword-devel mailing list: <a href="mailto:sword-devel@crosswire.org" target="_blank">sword-devel@crosswire.org</a><br>
<a href="http://www.crosswire.org/mailman/listinfo/sword-devel" target="_blank">http://www.crosswire.org/<u></u>mailman/listinfo/sword-devel</a><br>
Instructions to unsubscribe/change your settings at above page<br>
</div></div></blockquote></div><br></div>