Skip to content

Commit 5e5fcc0

Browse files
committed
translate: fix in finding all embedded reference texts
1 parent 5054c6f commit 5e5fcc0

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stam"
3-
version = "0.18.5"
3+
version = "0.18.6"
44
edition = "2021"
55
authors = ["Maarten van Gompel <proycon@anaproy.nl>"]
66
description = "STAM is a powerful library for dealing with stand-off annotations on text. This is the Rust library."

src/api/translate.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,13 @@ impl<'store> Translatable<'store> for ResultTextSelectionSet<'store> {
217217
{
218218
// get the all reference text selections that are embedded in our text selection (tsel)
219219
// we must have full coverage for a translation to be valid
220-
if tsel.test(
221-
&TextSelectionOperator::embeds(),
222-
reftsel.inner(),
223-
resource.as_ref(),
224-
) {
220+
while remainder.is_some()
221+
&& remainder.unwrap().test(
222+
&TextSelectionOperator::embeds(),
223+
reftsel.inner(),
224+
resource.as_ref(),
225+
)
226+
{
225227
refseqnrs.push(refseqnr);
226228
selectors_per_side[side_i].push(SelectorBuilder::TextSelector(
227229
resource.handle().into(),
@@ -245,12 +247,12 @@ impl<'store> Translatable<'store> for ResultTextSelectionSet<'store> {
245247
}
246248
}
247249
if remainder.is_none() {
248-
//everything form the source is covered by the references
250+
//everything from the source is covered by the references
249251
source_side = Some(side_i);
250252
break;
251253
}
252254
} else {
253-
unreachable!("[stam translate] Unexpected error: if text selections are embedded, there must be an intersection");
255+
unreachable!("[stam translate] Unexpected error: if text selections are embedded, there must be an intersection: remainder={:?} embedded={:?}", remainder, reftsel.inner());
254256
}
255257
}
256258
}

0 commit comments

Comments
 (0)