[jsword-devel] SimpleOsisParser - parsing whole chapter refs

Martin Denham mjdenham at gmail.com
Tue Sep 2 10:02:09 MST 2014


Hi DM,

There is a unit test attached to the previous e-mail that covers the
scenarios you have mentioned:
    @Test
    public void testChapterParsing() {
        assertEquals("Gen.1", SimpleOsisParser.parseOsisRef(testV11n,
"Gen.1").getOsisRef());
        assertEquals("Mark.10", SimpleOsisParser.parseOsisRef(testV11n,
"Mark.10").getOsisRef());
        assertEquals("Gen.1-Gen.3", SimpleOsisParser.parseOsisRef(testV11n,
"Gen.1-Gen.3").getOsisRef());
        assertEquals("Obad", SimpleOsisParser.parseOsisRef(testV11n,
"Obad.1").getOsisRef());
    }

One assumption is that chapters start with verse 1, although this could
probably be changed to assume they start with verse 0 if that is correct.

Cheers
Martin


On 1 September 2014 16:22, DM Smith <dmsmith at crosswire.org> wrote:

> Meant to respond to your first email. This is needed. Hope to review it
> soon. Work is crazy.
>
> The challenge with interpreting Gen.1 is that you have to know if it
> stands alone is the left part of a range or the right part of the range.
> When it stands alone it refers to the whole chapter, when it is the first
> part of a range it means the first verse of the chapter and if is the end
> of the range then it is the last verse of the range.
>
> We also have the complication that of what the first verse or the whole
> chapter means. Does it include verse 0?
>
> Since the start and the end of an OSIS range have to be valid OSIS refs
> the parsing of a range is much easier than user input ranges which might be
> like Gen 1:2-5. The -5 is ambiguous and has to be interpreted in context of
> what stands in front of it.
>
> -- DM
>
> On Aug 30, 2014, at 3:05 PM, Martin Denham <mjdenham at gmail.com> wrote:
>
> I have taken a stab at adding the above functionality to SimpleOsisParser
> so that it can also parse refs like 'Gen.1', 'Gen.1-Gen.3', 'Obad.1'.  I
> would like to make the methods non-static but tried to make as few changes
> as possible to the existing code but it may be that this enhancement
> necessitates some refactoring.
>
> Can somebody review the attached code and say if it is acceptable?
>
> Martin
>
>
> On 30 August 2014 15:23, Martin Denham <mjdenham at gmail.com> wrote:
>
>> Hi,
>>
>> Are there any plans to extend the SimpleOsisParser to be able to parse
>> chapter references like "Gen.1" instead of just verse references e.g.
>> "Gen.1.1" or verse range references e.g. "Gen.1.1-Gen.1.3"?
>>
>> The following fails so I can't parse a reference to the whole of Genesis
>> 1 easily:
>>
>>         assertEquals("Gen.1", SimpleOsisParser.parseOsisRef(testV11n,
>> "Gen.1").getOsisRef());
>>
>> other than by entering "Gen.1.1-Gen.1.31" which, funnily enough, returns
>> the Osis I originally tried to enter "Gen.1".
>>
>> Martin
>>
>
> <SimpleOsisParser.java><SimpleOsisIDParserTest.java>
> _______________________________________________
> jsword-devel mailing list
> jsword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/jsword-devel
>
>
>
> _______________________________________________
> jsword-devel mailing list
> jsword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/jsword-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/jsword-devel/attachments/20140902/a59de74f/attachment.html>


More information about the jsword-devel mailing list