[sword-devel] Parsing Verse lists
Troy A. Griffitts
scribe at crosswire.org
Wed Jun 6 02:30:30 MST 2007
Our verse parser has to parse some crazy reference instances in Bibles,
commentaries, and the like. We have data which specifies references in
formats like: "I Pet IV:7 and following" You would be horrified if you
saw how unnormalized verse reference syntax is used in books. Currently
the parser does the best it can to derive some kind of Bible reference
from the text, and assumes the rest of the text as comment. You can see
more of the details of what parts of a reference we pay attention to by
playing with the OSIS reference tool here:
I sympathize for your need to determine if there is any unrecognized
text in a verse reference. Unfortunately, there is no direct facility
in SWORD to do this for you at the moment.
Regarding autonormalization, this is turned on by default to facilitate
using a VerseKey programmatically, e.g. key.Verse(key.Verse()+10) //
jumps ahead 10 verses. You can turn this off by setting
AutoNormalize(false) on your VerseKey. You will then need to check if
any boundaries have been crossed. This would be a fairly
straight-forward addition to VerseKey. Maybe a property on
VerseKey::RestrictBoundaries(bool), which, if true, would set error if
any boundaries were ever exceeded? Thoughts?
Ben Morgan wrote:
> I have two questions related to Parsing verselists.
> How do I detect whether the reference passed to
> VerseKey::ParseVerseList is valid?
> If I try the following python code I don't get an error, just the wron result:
>>>> listkey = SW.VerseKey().ParseVerseList("Genesis 3:5-Foo:Bar", "", True)
>>>> print listkey.getRangeText()
> Genesis 3:5-Revelation of John 22:21
> I can't find out how to tell if there was an error. If I try
> listkey.Count(), it equals 1.
> If I try listkey.GetElement(0).Error(), it says there isn't an error.
> Also, listkey.Error() gives 0
> If I parse a verselist from "Genesis 3:5-Revelation of John 22:21", it
> says it equals my listkey.
> This is quite important, as if the user types "Genesis 3:5-Geness 3:6"
> (the second Genesis missing an i), they don't want to get all the text
> to revelation!
> Also, how do I find out when the reference has wrapped (or normalized
> as I think it is called)
> e.g. Matthew 29:47 being turned into Mark 2:2
> For example using the following python code:
>>>> listkey = vk.ParseVerseList("Genesis 5:1-333","",True)
> 'Genesis 5:1-Genesis 18:14'
> I would much rather have the behaviour in JSword (an error saying
> Verse should be between 1 and 32 for Genesis 5) as that is what a user
> would expect to see.
> God Bless,
> There is no love sincerer than the love of food.
> George Bernard Shaw (1856-1950)
> sword-devel mailing list: sword-devel at crosswire.org
> Instructions to unsubscribe/change your settings at above page
More information about the sword-devel