RED-9149 - Header and footer extraction by page-association

This commit is contained in:
Andrei Isvoran 2024-05-10 16:04:06 +03:00
parent f1dbcc24a2
commit aeaca2f278

View File

@ -103,18 +103,18 @@ public class HeaderFooterDetection {
}
private double compare(String candidate1, String candidate2) {
private double compare(String firstCandidate, String secondCandidate) {
int count = 0;
candidate1 = candidate1.replaceAll("\\d", "@");
candidate2 = candidate2.replaceAll("\\d", "@");
String cleanedFirstCandidate = firstCandidate.replaceAll("\\d", "@");
String cleanedSecondCandidate = secondCandidate.replaceAll("\\d", "@");
for (int i = 0; i < Math.min(candidate1.length(), candidate2.length()); i++) {
if (candidate1.charAt(i) == candidate2.charAt(i)) {
for (int i = 0; i < Math.min(cleanedFirstCandidate.length(), cleanedSecondCandidate.length()); i++) {
if (cleanedFirstCandidate.charAt(i) == cleanedSecondCandidate.charAt(i)) {
count++;
}
}
return (double) count / Math.max(candidate1.length(), candidate2.length());
return (double) count / Math.max(cleanedFirstCandidate.length(), cleanedSecondCandidate.length());
}