[sword-devel] Synodal versification & IBT modules?
Ben Morgan
benpmorgan at gmail.com
Mon May 13 07:20:47 MST 2013
BPBible already has code which (attempts) to check if a chapter is present.
https://code.google.com/p/bpbible/source/browse/trunk/backend/book.py?spec=svn1419&r=1414#716
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++
Basically, this takes advantage of hasEntry and also of module.
setSkipConsecutiveLinks(True) and module.increment()
(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
https://code.google.com/p/bpbible/source/browse/trunk/backend/book.py?spec=svn1419&r=1414#231
)
God Bless,
Ben
-------------------------------------------------------------
For I have no pleasure in the death of anyone,
declares the Lord God; so turn, and live.”
Ezekiel 18:32 (ESV)
On Mon, May 13, 2013 at 6:57 PM, John Austin <gpl.programs.info at gmail.com>wrote:
>
>
> On 05/13/2013 10:30 AM, Troy A. Griffitts wrote:
>
>> We have the first part already in the API:
>>
>> SWModule::hasEntry(const SWKey *)
>>
>> What sort of use cases do we have to build further API calls on this?
>>
>> vector<string> getBooksPresent()
>>
>> ???
>>
> Yes- or even just:
>
> bool isBookPresent(aBook)
>
> and there also probably needs to be something like:
>
> int lastChapterPresent(aBook)
>
> 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.
>
> and then something like:
>
> int lastVersePresent(aBook, aChapter)
>
> 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.
>
> 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.
>
> 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.
>
> John
>
>
>
>>
>>
>>
>>
>>
>> On 05/12/2013 07:11 PM, DM Smith wrote:
>>
>>> More:
>>> Once that is written, the worst case for analysis is a book that is
>>> entirely absent. Basically, when you find something from a book, you
>>> don't need to look any further in the book and go to the next.
>>>
>>>
>>> On May 12, 2013, at 10:06 PM, DM Smith <dmsmith at crosswire.org> wrote:
>>>
>>> JSword (Java) is quite different from SWORD (C++). But I'll give you
>>>> an overview. Each module has a similar structure. There is an index
>>>> file where slots have records indicating offset and size into a data
>>>> file. For a Bible module, each slot represents a verse.
>>>>
>>>> If the size is 0 then that indexed location is empty. A compressed
>>>> module is slightly more complicated. The index consists of two parts.
>>>> But the idea is the same. If the length of the data is 0, then it is
>>>> empty.
>>>>
>>>> Basically if you look at the chain of calls to get the raw text of a
>>>> verse, it digs down and at some point it gets the data size. Our code
>>>> merely bails once it gets the data size.
>>>>
>>>> I can point you to our Java code, if you like, but I don't know how
>>>> much that'd help.
>>>>
>>>> In Him,
>>>> DM
>>>>
>>>> On May 12, 2013, at 9:53 PM, Nic Carter <niccarter at mac.com> wrote:
>>>>
>>>> Hi DM,
>>>>>
>>>>> On 12/05/2013, at 7:40 AM, DM Smith <dmsmith at crosswire.org> wrote:
>>>>>
>>>>> Chris Burrell added some code to JSword that allows for the quick
>>>>>> determination of whether a verse is present in a module. He is
>>>>>> using this in STEP to prune the v11n to only those books, chapters
>>>>>> and verses that are actually present. On old slow hardware he
>>>>>> reported that it is very fast to analyze an entire module.
>>>>>>
>>>>> Could you please let me know where this is? Would be interesting to
>>>>> look at and see how it performs on a handheld in C++ or Obj-C :)
>>>>>
>>>>> Thanks heaps, ybic
>>>>> nic... :)
>>>>>
>>>>> ps: I don't know the JSword codebase at all, so it may be easier if
>>>>> I'm pointed in the right direction rather than trying to find it :)
>>>>> ______________________________**_________________
>>>>> sword-devel mailing list: sword-devel at crosswire.org
>>>>> http://www.crosswire.org/**mailman/listinfo/sword-devel<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<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<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<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<http://www.crosswire.org/mailman/listinfo/sword-devel>
> Instructions to unsubscribe/change your settings at above page
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/sword-devel/attachments/20130514/86859fe6/attachment.html>
More information about the sword-devel
mailing list