Skip to content

Commit

Permalink
made Annotation.text_textselection() and variants more robust.
Browse files Browse the repository at this point in the history
No longer fails when an annotation references multiple texts.
  • Loading branch information
proycon committed Feb 25, 2024
1 parent 6ed664a commit dd6544d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/api/annotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,13 @@ impl<'store> ResultItem<'store, Annotation> {
}

/// Compares whether a particular spatial relation holds between two annotations
/// This only works if both annotations reference text in the same resource.
pub fn test(
&self,
operator: &TextSelectionOperator,
other: &ResultItem<'store, Annotation>,
) -> bool {
if let Some(tset) = self.textselectionset() {
if let Some(tset2) = other.textselectionset() {
for tset in self.textselectionsets() {
for tset2 in other.textselectionsets() {
if tset.resource() == tset2.resource() && tset.test_set(operator, &tset2) {
return true;
}
Expand All @@ -256,13 +255,12 @@ impl<'store> ResultItem<'store, Annotation> {
}

/// Compares whether a particular spatial relation holds between this annotation and a textselection set.
/// This only works if both reference text in the same resource.
pub fn test_textselectionset(
&self,
operator: &TextSelectionOperator,
other: &ResultTextSelectionSet,
) -> bool {
if let Some(tset) = self.textselectionset() {
for tset in self.textselectionsets() {
if tset.resource() == other.resource() && tset.test_set(operator, other) {
return true;
}
Expand All @@ -271,13 +269,12 @@ impl<'store> ResultItem<'store, Annotation> {
}

/// Compares whether a particular spatial relation holds between this annotation and a textselection
/// This only works if both reference text in the same resource.
pub fn test_textselection(
&self,
operator: &TextSelectionOperator,
other: &ResultTextSelection,
) -> bool {
if let Some(tset) = self.textselectionset() {
for tset in self.textselectionsets() {
if tset.resource() == other.resource() && tset.test(operator, other) {
return true;
}
Expand Down

0 comments on commit dd6544d

Please sign in to comment.