Skip to content

Commit

Permalink
Don't abort when trying to highlight empty documents, skip docs inste…
Browse files Browse the repository at this point in the history
…ad (fixes #200)
  • Loading branch information
jbaiter committed Aug 16, 2021
1 parent 623c325 commit 93632ac
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ public OcrHighlightResult[] highlightOcrFields(
int docInIndex = docInIndexes[docIdx]; // original input order
assert resultByDocIn[docInIndex] == null;
OcrFormat ocrFormat = getFormat(content);
if (ocrFormat == null) {
continue;
}
String limitBlockParam = params.get(OcrHighlightParams.LIMIT_BLOCK, "block");
OcrBlock[] limitBlocks = null;
if (!limitBlockParam.equalsIgnoreCase("NONE")) {
Expand Down Expand Up @@ -498,10 +501,7 @@ private OcrFormat getFormat(IterableCharSequence content) {
return FORMATS.stream()
.filter(fmt -> fmt.hasFormat(sampleChunk))
.findFirst()
.orElseThrow(
() ->
new RuntimeException(
"Could not determine OCR format for sample '" + sampleChunk + "'"));
.orElse(null);
}

/**
Expand Down

0 comments on commit 93632ac

Please sign in to comment.