[jsword-devel] AccuracyType for single chapter books
Brian Fernandes
infernalproteus at gmail.com
Sat Dec 29 14:00:27 MST 2007
DM,
Thanks for the prompt reply, I now construct a key by adding a 1-ff at
the end (Jude.1.1-ff) and it gives me exactly what I need.
So far I only support bible texts and I have chosen to route all
requests through a URI which could be typed into the address bar or
loaded because you clicked a hyperlinked reference in a book. So using
the combo boxes ultimately creates a URI and asks Firefox to load it,
which is when you see the output text. This is cool because like every
other URI, they are recorded in your history and can be bookmarked too.
This is what it looks like: http://bible.thegoan.com/esv-jude-1.png
For the actual processing of the URI, all I do is call
Bible#getKey(String) (where the string would be the "host" part of the
URI) and use the resulting key to fetch the data, just as you suggested
(took it from APIExamples).
Regarding AccuracyType, I don't really use it directly, I was just
trying to figure out the point at which "Jude 1" is different from
"Genesis 1". My code is actually identical to
APIExamples#readStyledText. Now if we forget the technicalities, if I go
to BibleDesktop and type in "Genesis 1" in the show passage field, I get
the first chapter of Genesis, but if I type in "Jude 1" I only get the
first verse of the first (and only) chapter of Jude. Isn't this
inconsistent? At the same time I do realize from your previous reply
that "Genesis 1" might not have been a fully qualified reference to
begin with and we just received a "best fit" result; I'm fine with this.
Warm regards,
Brian.
DM Smith wrote:
> On Dec 28, 2007, at 9:38 AM, Brian Fernandes wrote:
>
>
>> In my application, I create a key based on the book and chapter
>> selected
>> by a user and pass it on to the JSWord API to get the corresponding
>> text. So if you select Genesis and chapter 1, I get the key using
>> Book#getKey("Genesis.1"); The corresponding text is the first
>> chapter of
>> Genesis. OK.
>> If I do the same for a single chapter book though, like Jude, the
>> text I
>> get back is just the first verse of that chapter and not the first
>> chapter as I expected. (The key I used is "Jude.1").
>>
>
> Verse is a special kind of key. It is merely a holder of book number
> (i.e. 1-66), chapter and verse.
> At this time, these have to be non-zero. But these should allow 0 to
> represent introductions.
>
> A VerseRange is a special kind of range in that it starts at one verse
> and ends at another, inclusive of both.
>
> Here is how the Book/Chapter picker in BibleDesktop does it:
> Verse start = new Verse(BibleInfo.getBookNumber("Jude"), 1, 1);
> Verse end = start.getLastVerseInChapter();
> VerseRange singleChapter = new VerseRange(start, end);
>
> If your program can do this, this would be best.
>
>
>
>> I stepped into the code and this seems to be because the AccuracyType
>> for "Genesis.1" is BOOK_CHAPTER, while the type for "Jude.1" is
>> BOOK_VERSE. These results are perfect according to the javadoc for
>> that
>> method. But these results also cause
>> VerseRangeFactory#fromString(String) to return a range covering just
>> that one verse instead of the entire chapter, consequently, I get a
>> single verse back instead of the chapter.
>>
>> My expectation is: Jude.1 and Genesis.1 should both be BOOK_CHAPTER
>> type, but I see that there is code which explicitly returns BOOK_VERSE
>> for the former because it has only one chapter. I'm sure there is a
>> reason for this, but I cannot figure this out. Is my expectation
>> invalid? If so, how should I construct my key so that I get back the
>> entire chapter instead of just that one verse? I'm using code nearly
>> identical to APIExamples#readStyledText.
>>
>
> The whole AccuracyType code is meant to be able to parse arbitrary
> user input into meaningful Verse objects. It should not be used
> directly.
>
> Jude 1 is verse one of the book of Jude. And Jude 5 is verse 5 of
> chapter 1 of the book of Jude.
>
> The engine allows for values like osisIDs to be used so "Jude.1.1-ff"
> will give you what you expect.
>
> "ff" is an extension that means the last verse or the last chapter,
> depending on the context.
>
> The "proper" way to parse user input into a key is to call:
> Key k = book.getKey(userInput); // Currently this only is meaningful
> for Bibles.
>
> Or:
>
> Key k = PassageKeyFactory.instance().getKey(userInput);
>
> So
> Key k = PassageKeyFactory.instance().getKey(bookName + "." + chapter +
> ".1-ff");
> would return a single chapter.
>
> (I'm doing this from memory so I may have made a typo :)
>
> May God bless your efforts!
>
> Serving Christ Together,
> DM
>
> _______________________________________________
> jsword-devel mailing list
> jsword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/jsword-devel
>
>
More information about the jsword-devel
mailing list