Skip to content

Commit

Permalink
If context tag not found, use a context of 0.
Browse files Browse the repository at this point in the history
E.g. when you ask for context=s but there is no s matching the snippet.
  • Loading branch information
jan-niestadt committed Jun 4, 2024
1 parent 1641331 commit 8bae634
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ public class ResultDocSnippet {
} catch (InvalidQuery e) {
throw new BlackLabRuntimeException(e);
}
} else {
}
if (hits != null && !hits.hitsStats().processedAtLeast(1)) {
// We couldn't find the tag for the context; use a context of 0 words instead
hits = null;
context = ContextSize.get(0, maxSnippetSize);
}
if (hits == null) {
// Limit context if necessary
// (done automatically as well, but this should ensure equal before/after parts)
int snippetSize = end - start + context.before() + context.after();
Expand Down

0 comments on commit 8bae634

Please sign in to comment.