<div dir="ltr">There was a more flexible way to create this parser. The previous was rather fussy about the ids passed in. This new version (attached) should handle all combinations:<div><br></div><div><div><font face="courier new, monospace"> @Test</font></div><div><font face="courier new, monospace"> public void testChapterParsing() {</font></div><div><font face="courier new, monospace"> assertEquals("Gen.1", osisParser.parseOsisRef(testV11n, "Gen.1").getOsisRef());</font></div><div><font face="courier new, monospace"> assertEquals("Mark.10", osisParser.parseOsisRef(testV11n, "Mark.10").getOsisRef());</font></div><div><font face="courier new, monospace"> assertEquals("Gen.1-Gen.3", osisParser.parseOsisRef(testV11n, "Gen.1-Gen.3").getOsisRef());</font></div><div><font face="courier new, monospace"> assertEquals("Obad", osisParser.parseOsisRef(testV11n, "Obad.1").getOsisRef());</font></div><div><font face="courier new, monospace"> assertEquals("Obad", osisParser.parseOsisRef(testV11n, "Obad").getOsisRef());</font></div><div><font face="courier new, monospace"> assertEquals("Gen", osisParser.parseOsisRef(testV11n, "Gen").getOsisRef());</font></div><div><font face="courier new, monospace"> }</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"> @Test</font></div><div><font face="courier new, monospace"> public void testMixedLengthParsing() {</font></div><div><font face="courier new, monospace"> assertEquals("Gen-Exod.1", osisParser.parseOsisRef(testV11n, "Gen-Exod.1").getOsisRef());</font></div><div><font face="courier new, monospace"> assertEquals("Gen.2-Gen.3", osisParser.parseOsisRef(testV11n, "Gen.2.1-Gen.3").getOsisRef());</font></div><div><font face="courier new, monospace"> assertEquals("Gen.1-Gen.3", osisParser.parseOsisRef(testV11n, "Gen-Gen.3").getOsisRef());</font></div><div><font face="courier new, monospace"> assertEquals("Gen.1-Gen.3.4", osisParser.parseOsisRef(testV11n, "Gen-Gen.3.4").getOsisRef());</font></div><div><font face="courier new, monospace"> assertEquals("Gen.3.4-Exod", osisParser.parseOsisRef(testV11n, "Gen.3.4-Exod").getOsisRef());</font></div><div><font face="courier new, monospace"> }</font></div></div><div><br></div><div>Comments?</div><div><br></div><div>Cheers</div><div>Martin</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 2 September 2014 18:02, Martin Denham <span dir="ltr"><<a href="mailto:mjdenham@gmail.com" target="_blank">mjdenham@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi DM,<div><br></div><div>There is a unit test attached to the previous e-mail that covers the scenarios you have mentioned:</div><div><div> @Test</div><div> public void testChapterParsing() {</div><span class=""><div>
assertEquals("Gen.1", SimpleOsisParser.parseOsisRef(testV11n, "Gen.1").getOsisRef());</div></span><div> assertEquals("Mark.10", SimpleOsisParser.parseOsisRef(testV11n, "Mark.10").getOsisRef());</div>
<div> assertEquals("Gen.1-Gen.3", SimpleOsisParser.parseOsisRef(testV11n, "Gen.1-Gen.3").getOsisRef());</div><div> assertEquals("Obad", SimpleOsisParser.parseOsisRef(testV11n, "Obad.1").getOsisRef());</div>
<div> }</div></div><div><br></div><div>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.</div><div><br></div><div>Cheers</div><span class="HOEnZb"><font color="#888888">
<div>Martin</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On 1 September 2014 16:22, DM Smith <span dir="ltr"><<a href="mailto:dmsmith@crosswire.org" target="_blank">dmsmith@crosswire.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Meant to respond to your first email. This is needed. Hope to review it soon. Work is crazy.<div>
<br></div><div>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.</div>
<div><br></div><div>We also have the complication that of what the first verse or the whole chapter means. Does it include verse 0?</div><div><br></div><div>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.<div>
<br></div><div>-- DM</div><div><br><div><div><div><div>On Aug 30, 2014, at 3:05 PM, Martin Denham <<a href="mailto:mjdenham@gmail.com" target="_blank">mjdenham@gmail.com</a>> wrote:</div><br></div></div><blockquote type="cite">
<div><div><div dir="ltr">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.<div>
<br></div><div>Can somebody review the attached code and say if it is acceptable?<br><div><br></div><div>Martin</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 30 August 2014 15:23, Martin Denham <span dir="ltr"><<a href="mailto:mjdenham@gmail.com" target="_blank">mjdenham@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>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"?</div>
<div><br></div><div>The following fails so I can't parse a reference to the whole of Genesis 1 easily:</div><div><br></div><div><div> assertEquals("Gen.1", SimpleOsisParser.parseOsisRef(testV11n, "Gen.1").getOsisRef());</div>
</div><div><br></div><div>other than by entering "Gen.1.1-Gen.1.31" which, funnily enough, returns the Osis I originally tried to enter "Gen.1".<span><font color="#888888"><br></font></span></div>
<span><font color="#888888"><div><br></div><div>Martin</div></font></span></div>
</blockquote></div><br></div>
</div></div><span><SimpleOsisParser.java></span><span><SimpleOsisIDParserTest.java></span>_______________________________________________<br>jsword-devel mailing list<br><a href="mailto:jsword-devel@crosswire.org" target="_blank">jsword-devel@crosswire.org</a><br>
<a href="http://www.crosswire.org/mailman/listinfo/jsword-devel" target="_blank">http://www.crosswire.org/mailman/listinfo/jsword-devel</a><br></blockquote></div><br></div></div></div><br>_______________________________________________<br>
jsword-devel mailing list<br>
<a href="mailto:jsword-devel@crosswire.org" target="_blank">jsword-devel@crosswire.org</a><br>
<a href="http://www.crosswire.org/mailman/listinfo/jsword-devel" target="_blank">http://www.crosswire.org/mailman/listinfo/jsword-devel</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>