<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">The other factor is that block elements might not actually be containers but milestoned.<div><br><div><div>On Sep 26, 2012, at 6:39 PM, DM Smith <<a href="mailto:dmsmith@crosswire.org">dmsmith@crosswire.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">The routine is not very bright. The issue that the inserted space is trying to handle is when text in one block element is followed by text perhaps in another block element.<div><br></div><div>A block element implies a newline. The seg element is an inline element and does not imply added spacing. However, it is only an issue if elements split words.</div><div><br></div><div>So the fix is to categorize each element as block or inline and smartly putting the extra space where it is needed.</div><div><br></div><div>Need to verify how ruby is handled in OSIS. Or change this may break that.</div><div><br></div><div>Please file a bug.</div><div><br></div><div>In Him,</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>DM</div><div><br><div><div>On Sep 26, 2012, at 3:47 PM, Chris Burrell <<a href="mailto:chris@burrell.me.uk">chris@burrell.me.uk</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi</div><div><br></div><div>I have a question around the <i>seg </i>element in OSIS. Versions like the WLC have separated each part of the word as a seg (see below). And then separates the words (sets of segs) with spaces.</div>
<div><br></div><div><div><title type="x-gen">Genesis 1:1</title><verse osisID="Gen.1.1"><seg type="x-morph">בְּ</seg><seg type="x-morph">רֵאשִׁ֖ית</seg> <seg type="x-morph">בָּרָ֣א</seg> <seg type="x-morph">אֱלֹהִ֑ים</seg> <seg type="x-morph">אֵ֥ת</seg> <seg type="x-morph">הַ</seg><seg type="x-morph">שָּׁמַ֖יִם</seg> <seg type="x-morph">וְ</seg><seg type="x-morph">אֵ֥ת</seg> <seg type="x-morph">הָ</seg><seg type="x-morph">אָֽרֶץ׃</seg> </verse></div></div>
<div><br></div><div>The JSword compare functionality (and indexing) uses OSISUtil.getCanonicalText(). This seems to add spaces between the seg elements which then makes for inconsistent results in the diffing (extra differences). The following comment is seen in the method:</div>
<div><div> // make sure that adjacent text elements are separated by whitespace</div><div>// TODO(dms): verify that the xml parser does not split words containing entities.</div></div><div><br></div><div>Presumably, we want to add an exception for <i>seg</i> elements. I assume indexing/searching is also going to be affected by this problem...</div>
<div><br></div><div>My question is whether to add a new block in the instanceof Element part. Or in the instanceof Text part? </div><div>Also, are there any other times ever where we want additional spaces between segs? Any other gotchas?</div>
<div><br></div><div>(see below for JSword function)</div><div>Cheers</div><div>Chris</div><div><br></div><div>Copy of the function in JSword:</div><div><br></div><div><div><b>public static String getCanonicalText(Element root) {</b></div>
<div> StringBuilder buffer = new StringBuilder();</div><div><br></div><div> // Dig past osis, osisText, if present, to get to the real content.</div><div> List<Content> frag = OSISUtil.getFragment(root);</div>
<div><br></div><div> Iterator<Content> dit = frag.iterator();</div><div> String sID = null;</div><div> Content data = null;</div><div> Element ele = null;</div><div> while (dit.hasNext()) {</div>
<div> data = dit.next();</div><div> if (data instanceof Element) {</div><div> ele = (Element) data;</div><div> if (!isCanonical(ele)) {</div><div> continue;</div>
<div> }</div><div><br></div><div> if (ele.getName().equals(OSISUtil.OSIS_ELEMENT_VERSE)) {</div><div> sID = ele.getAttributeValue(OSISUtil.OSIS_ATTR_SID);</div><div> }</div>
<div><br></div><div> if (sID != null) {</div><div> getCanonicalContent(ele, sID, dit, buffer);</div><div> } else {</div><div> getCanonicalContent(ele, null, ele.getContent().iterator(), buffer);</div>
<div> }</div><div> } else if (data instanceof Text) {</div><div> // make sure that adjacent text elements are separated by</div><div> // whitespace</div><div> // TODO(dms): verify that the xml parser does not split words</div>
<div> // containing entities.</div><div> int lastIndex = buffer.length() - 1;</div><div> String text = ((Text) data).getText();</div><div> // Ignore empty text nodes.</div>
<div> if (text.length() != 0) {</div><div> if (lastIndex >= 0 && !Character.isWhitespace(buffer.charAt(lastIndex)) && !Character.isWhitespace(text.charAt(0))) {</div><div>
buffer.append(' ');</div><div> }</div><div> buffer.append(text);</div><div> }</div><div> }</div><div> }</div><div><br>
</div><div> return buffer.toString().trim();</div><div> }</div></div><div><br></div><div><br></div><div>Cheers</div><div>Chris</div><div><br></div>
_______________________________________________<br>jsword-devel mailing list<br><a href="mailto:jsword-devel@crosswire.org">jsword-devel@crosswire.org</a><br><a href="http://www.crosswire.org/mailman/listinfo/jsword-devel">http://www.crosswire.org/mailman/listinfo/jsword-devel</a><br></blockquote></div><br></div></div>_______________________________________________<br>jsword-devel mailing list<br><a href="mailto:jsword-devel@crosswire.org">jsword-devel@crosswire.org</a><br>http://www.crosswire.org/mailman/listinfo/jsword-devel<br></blockquote></div><br></div></body></html>