Skip to content

Commit

Permalink
fix wrong upper indexes, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lfoppiano committed Dec 7, 2024
1 parent 17ad425 commit c830231
Showing 1 changed file with 1 addition and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,18 +374,6 @@ private static String revertResultsForBadItems(List<? extends Figure> badItems,
List<LayoutToken> rawLayoutTokenTable = badItem.getLayoutTokens();
LayoutToken firstLayoutTokenItem = rawLayoutTokenTable.get(0);

// final List<LayoutToken> documentTokenization = layoutTokenization.getTokenization();

// int tokenIndex = IntStream.range(0, documentTokenization.size())
// .filter(i -> {
// LayoutToken l = documentTokenization.get(i);
// return l.getText().equals(firstLayoutTokenTable.getText())
// && l.getPage() == firstLayoutTokenTable.getPage()
// && l.getOffset() == firstLayoutTokenTable.getOffset();
// })
// .findFirst()
// .orElse(-1);

List<Integer> candidateIndexes = IntStream.range(0, splitResult.size())
.filter(i -> splitResult.get(i).get(0).equals(firstLayoutTokenItem.getText())
&& Iterables.getLast(splitResult.get(i)).equals("I-"+itemLabel))
Expand Down Expand Up @@ -435,7 +423,7 @@ private static String revertResultsForBadItems(List<? extends Figure> badItems,

if (resultIndexCandidate > -1) {
boolean first = true;
for (int i = resultIndexCandidate;i < resultIndexCandidate + tokensNoSpace.size(); i++) {
for (int i = resultIndexCandidate;i < Math.min(resultIndexCandidate + tokensNoSpace.size(), splitResult.size()); i++) {
List<String> line = splitResult.get(i);
String label = Iterables.getLast(line);
if (first) {
Expand All @@ -450,12 +438,6 @@ private static String revertResultsForBadItems(List<? extends Figure> badItems,
} else {
LOGGER.warn("Cannot find the result index candidate.");
}
// List<List<String>> badTableResult = Arrays.stream(badTable.getRawLayoutTokens().stream()
// .map(LayoutToken::getText)
// .toArray(String[]::new))
// .map(l -> Arrays.stream(l.split("\t")).collect(Collectors.toList()))
// .collect(Collectors.toList());
//
}

String resultBody2 = splitResult.stream()
Expand Down

0 comments on commit c830231

Please sign in to comment.