[sword-devel] Efficiently extracting section + chapter headers

Tobias Klein contact at tklein.info
Sun Jan 9 05:03:57 EST 2022


Thank you, Troy!

The setIntros call on the VerseKey does not help in getting the chapter 
headers in the context of the entry attribute search. I am getting the 
same results as without setting it.

Best regards,
Tobias

On 1/8/22 3:58 PM, Troy A. Griffitts wrote:
> Sorry Tobias,
>
> Yes, I incorrectly told you to call setIntros on SWModule instead of 
> VerseKey.
>
> - module->setIntros(true);
> + ((VerseKey *)module->getKey())->setIntros(true);
>
> That's a bit ugly typed from my phone, with no check to be sure the 
> cast succeeds, but should get the point across.
>
> I should actually have some time this weekend to try some of these 
> suggestions before emailing you 🙂
>
> Troy
>
> On January 8, 2022 1:15:18 AM MST, Tobias Klein <contact at tklein.info> 
> wrote:
>
>     Hi Troy,
>
>     Thank you so much for looking into this!
>
>     setIntros is not available on SWModule, but only on SWKey.
>
>     I suppose the setIntros must be used like this?
>
>     SWKey*key= module->getKey();
>     VerseKey*verseKey= SWDYNAMIC_CAST(VerseKey, key);
>     *verseKey**->**setIntros**(**true**);*
>     ListKeyscope= verseKey->parseVerseList(bookCode, *verseKey, true);
>     ListKeyresultKey= module->search("/Heading",
>     SWModule::SEARCHTYPE_ENTRYATTR, 0, &scope);
>
>     When I did that I still did not get the chapter headings, though.
>
>     Best regards,
>     Tobias
>
>     On 1/7/22 3:44 PM, Troy A. Griffitts wrote:
>>     Dear Tobias,
>>
>>     I haven't had a chance to dig into this yet, but my first guess
>>     is that you may be missing the intro slots from the module.
>>
>>     VerseKey modules have intro entries:
>>
>>     for the chapter if you set verse to 0
>>     for the book, if you set chapter to 0
>>     for the testament, if you set book to 0
>>     for the module, if you set testament to 0
>>
>>     You'll need to module->setIntros(true) if you want to access these.
>>
>>     Actually, maybe even just try setIntros(true) before your
>>     headings search. The content in these entries is likely marked up
>>     as headings, as well. For your purposes, you'll need to decide if
>>     you want anything in these entries. They might be a long book
>>     introduction. The presence of intro entries, length, and type of
>>     content varies greatly between modules.
>>
>>     Hope this give something to try,
>>
>>     Troy
>>
>>     On January 6, 2022 9:41:31 AM MST, Tobias Klein
>>     <contact at tklein.info> wrote:
>>
>>         Hi Troy,
>>
>>         I have started looking again into extracting book headings, so that I
>>         can generate a book outline in Ezra Bible App even when looking at
>>         individual chapters only. I had stopped looking at it when I was not
>>         successfully generating a Windows build any longer last year - but I
>>         could fix that, so now the work continues.
>>
>>         I based my code on your example findHeadings.cpp.
>>
>>         It seems like the list of extracted headings is not complete, though.
>>
>>         When running this with the module GerNeUe and the book Acts I find that
>>         the headers returned are only section headers, but not chapter headers.
>>         Could you have another look based on the example and GerNeUe/Acts and
>>         advise?
>>
>>         I have attached a list of headers that I get from the Bible text of
>>         GerNeUe/Acts - just for reference.
>>
>>         Best regards,
>>         Tobias
>>
>>         On 4/12/21 9:07 PM, Troy A. Griffitts wrote:
>>
>>             Sure Tobias, module->getEntryAttributes() will allow you
>>             to pull the headings from a verse, and an Entry
>>             Attributes search for '/Heading' will give you only the
>>             verses with Heading entries attributes. I've thrown
>>             together a quick example here, which you can use with
>>             something like: ./showHeadings NASB Matt-John which will
>>             give you the headings from the Gospels.
>>             https://crosswire.org/svn/sword/trunk/examples/tasks/findHeadings.cpp
>>             <https://crosswire.org/svn/sword/trunk/examples/tasks/findHeadings.cpp>
>>             Creating this example, I found I needed to fix a bug in
>>             the engine.  The engine Entry Attributes search lets you
>>             search for values in the entry attributes (e.g., a
>>             Strong's number 1234).  In your use case, when searching,
>>             you don't care about the value; you only care about
>>             presence.  This wasn't working, but simple presence can
>>             now be searched for with my latest commit. Hope this
>>             helps, Troy On 4/12/21 9:31 AM, Tobias Klein wrote:
>>
>>                 Hi, I have been getting a request from a user to
>>                 render section headings independently of the
>>                 currently opened bible translation module. So for
>>                 example when opening the KJV still using the
>>                 section/chapter headers of the NASB. This would be
>>                 useful in those cases when the respective bible
>>                 translation module does not come with section/chapter
>>                 headers, but another one does. A requirement would be
>>                 to efficiently extract section/chapter headers from a
>>                 module using the SWORD API. As of now I only see that
>>                 you can iterate over the verses of a book and
>>                 individually scan each verse for the headers. Is
>>                 there a more efficient way of doing that? Another use
>>                 case could be to render a book outline. This is what
>>                 I am already doing now in Ezra, but in a way that is
>>                 not so clean (I am traversing the DOM looking for all
>>                 section header elements of the current book). Best
>>                 regards, Tobias
>>                 ------------------------------------------------------------------------
>>                 sword-devel mailing list: sword-devel at crosswire.org
>>                 http://crosswire.org/mailman/listinfo/sword-devel
>>                 <http://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://crosswire.org/mailman/listinfo/sword-devel
>>             <http://crosswire.org/mailman/listinfo/sword-devel>
>>             Instructions to unsubscribe/change your settings at above
>>             page 
>>
>>     -- Sent from my Android device with K-9 Mail. Please excuse my
>>     brevity.
>
> -- Sent from my Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://crosswire.org/pipermail/sword-devel/attachments/20220109/9a346039/attachment.html>


More information about the sword-devel mailing list