[sword-devel] mod2osis - linked verses ....
DM Smith
dmsmith at crosswire.org
Tue Apr 28 07:48:57 MST 2009
Greg Hellings wrote:
> On Tue, Apr 28, 2009 at 7:50 AM, DM Smith <dmsmith at crosswire.org> wrote:
>
>> On Apr 28, 2009, at 8:40 AM, Barry Drake wrote:
>>
>>
>>> Hi there ......
>>>
>>> I've just discovered that mod2osis doesn't currently handle linked verses
>>> in bible texts. It outputs the entire linked block for every verse that it
>>> is linked from.
>>>
>> There is a new method for the module: isLinked(VerseKey *v1, VerseKey* v2)
>>
>
> This is helpful. So can I do something like this:
>
> VerseKey* endRange = myKey.clone();
> while(myModule.isLinked(myKey, endRange)) {
> endRange.increment();
> }
> // Necessary, because we stepped one beyond the linking range
> endRange.decrement();
> SWBuf osisIDValue = myKey.equals(endRange) : myKey.getOSISRef() ?
> SWBuf(myKey.getOSISRef()) + SWBuf(".") + SWBuf(endRange.getOSISRef());
>
> to determine the key range?
Looks good. I think it needs some error checking as in (I don't know if
this is correct.):
// have to increment in case you don't get in the loop body
endRange.increment();
// check error so that if you are on the last verse in the
versification, you don't loop forever.
while (!endRange.Error() && myModule.isLinked(myKey, endRange)) {
endRange.increment();
}
// If you hit the last verse you don't need to decrement
if (!endRange.Error()) {
endRange.decrement();
}
// test to see that you have a range.
if (myKey != endRange) {
... then I have a range ...
}
This has some theoretical drawbacks:
1) A verse in the range might not have an entry in the module. I think
this is unlikely.
<div annotateType="xxx" annotateRef="Matt.1.1-Matt.1.5
Matt.2.10-Matt.2.11">...</div>
2) One could have non-adjacent references to be linked. I think this is
unlikely.
<div annotateType="xxx" annotateRef="Matt.1.1-Matt.1.5
Matt.2.10-Matt.2.11">...</div>
<div annotateType="xxx" annotateRef="Matt.1.6-Matt.2.9">...</div>
I don't know how to solve the second one. The first can use
module.hasEntry(vk);
> And is a "." the proper value to use when
> linking two osisIDs together into a range?
>
For an annotateRef, use '-' e.g. annotateRef="Matt.1.1-Matt.1.5". For an
osisID, you need each osisID separated by space, e.g. osisID="Matt.1.1
Matt.1.2 Matt.1.3 Matt.1.4 Matt.1.5"
> --Greg
>
>
>
>> By passing the current and the next verse keys, one can determine the osisID
>> to use.
>>
>> In Him,
>> DM
More information about the sword-devel
mailing list