Author: schor Date: Fri Nov 22 22:36:04 2019 New Revision: 1870197 URL: http://svn.apache.org/viewvc?rev=1870197&view=rev Log: no jira add alternative overlap impl allowing abutting
Modified: uima/site/trunk/uima-website/docs/doc-uimaj-cookbook.html uima/site/trunk/uima-website/xdocs/doc-uimaj-cookbook.xml Modified: uima/site/trunk/uima-website/docs/doc-uimaj-cookbook.html URL: http://svn.apache.org/viewvc/uima/site/trunk/uima-website/docs/doc-uimaj-cookbook.html?rev=1870197&r1=1870196&r2=1870197&view=diff ============================================================================== --- uima/site/trunk/uima-website/docs/doc-uimaj-cookbook.html (original) +++ uima/site/trunk/uima-website/docs/doc-uimaj-cookbook.html Fri Nov 22 22:36:04 2019 @@ -425,7 +425,7 @@ <pre>a != null && b != null && // null check a.getBegin() <= b.getBegin() && // a starts before (or equal to) b a.getEnd() >= b.getEnd() // a ends after (or equal to) b</pre> - <h3>a and b overlap (have at least one char in common)</h3> + <h3>a and b overlap (have at least one char position in common)</h3> <pre> // ((omitted) check for non-null) if (a.getBegin() <= b.getBegin()) { // if a starts before (or equal to) b @@ -433,6 +433,16 @@ if (a.getBegin() <= b.getBegin()) { / } else { // otherwise, b's begin is before a's begin return b.getEnd() > a.getBegin(); // so it overlaps if b's end is after a's begin. </pre> + <p> + An alternative, where overlap includes the edge case when the annotations just touch each other, but have no char position in common: + </p> + <pre> + // ((omitted) check for non-null) +if (a.getBegin() <= b.getBegin()) { // if a starts before (or equal to) b + return a.getEnd() >= b.getBegin(); // then it overlaps or abuts if a's end is after or equal to b's begin +} else { // otherwise, b's begin is before a's begin + return b.getEnd() >= a.getBegin(); // so it overlaps or abuts if b's end is after or equal to a's begin. +</pre> </blockquote> </td></tr> </table> Modified: uima/site/trunk/uima-website/xdocs/doc-uimaj-cookbook.xml URL: http://svn.apache.org/viewvc/uima/site/trunk/uima-website/xdocs/doc-uimaj-cookbook.xml?rev=1870197&r1=1870196&r2=1870197&view=diff ============================================================================== --- uima/site/trunk/uima-website/xdocs/doc-uimaj-cookbook.xml (original) +++ uima/site/trunk/uima-website/xdocs/doc-uimaj-cookbook.xml Fri Nov 22 22:36:04 2019 @@ -169,14 +169,24 @@ a.getBegin() <= b.getBegin() && // a starts before (or equal to) b a.getEnd() >= b.getEnd() // a ends after (or equal to) b</pre> - <h3>a and b overlap (have at least one char in common)</h3> + <h3>a and b overlap (have at least one char position in common)</h3> <pre> // ((omitted) check for non-null) if (a.getBegin() <= b.getBegin()) { // if a starts before (or equal to) b return a.getEnd() > b.getBegin(); // then it overlaps if a's end is after b's begin } else { // otherwise, b's begin is before a's begin return b.getEnd() > a.getBegin(); // so it overlaps if b's end is after a's begin. -</pre> +</pre> + <p> + An alternative, where overlap includes the edge case when the annotations just touch each other, but have no char position in common: + </p> + <pre> + // ((omitted) check for non-null) +if (a.getBegin() <= b.getBegin()) { // if a starts before (or equal to) b + return a.getEnd() >= b.getBegin(); // then it overlaps or abuts if a's end is after or equal to b's begin +} else { // otherwise, b's begin is before a's begin + return b.getEnd() >= a.getBegin(); // so it overlaps or abuts if b's end is after or equal to a's begin. +</pre> </subsection>