RSS-181: Use pdfbox quicksort for sorting in rules
This commit is contained in:
parent
ae93fe7997
commit
4603b567bb
@ -70,9 +70,9 @@ public class ClassificationService {
|
|||||||
}
|
}
|
||||||
if (textBlock.getText().length() > 5 && (textBlock.getMostPopularWordHeight() > document.getTextHeightCounter().getMostPopular() || textBlock.getMostPopularWordFontSize() > document.getFontSizeCounter().getMostPopular()) && PositionUtils.getApproxLineCount(textBlock) < 5.9
|
if (textBlock.getText().length() > 5 && (textBlock.getMostPopularWordHeight() > document.getTextHeightCounter().getMostPopular() || textBlock.getMostPopularWordFontSize() > document.getFontSizeCounter().getMostPopular()) && PositionUtils.getApproxLineCount(textBlock) < 5.9
|
||||||
|
|
||||||
&& ((textBlock.getMostPopularWordStyle().contains("bold") && Character.isDigit(textBlock.toString().charAt(0)) && !matcher2.matches() && !textBlock.toString().contains(":")
|
&& (textBlock.getMostPopularWordStyle().contains("bold") && Character.isDigit(textBlock.toString().charAt(0)) && !matcher2.matches() && !textBlock.toString().contains(":")
|
||||||
|| textBlock.toString().equals(textBlock.toString().toUpperCase(Locale.ROOT)) && !matcher2.matches() && !textBlock.toString().contains(":")
|
|| textBlock.toString().equals(textBlock.toString().toUpperCase(Locale.ROOT)) && !matcher2.matches() && !textBlock.toString().contains(":")
|
||||||
|| textBlock.toString().startsWith("APPENDIX") || textBlock.toString().startsWith("TABLE")) && !textBlock.toString().endsWith(":"))) {
|
|| textBlock.toString().startsWith("APPENDIX") || textBlock.toString().startsWith("TABLE")) && !textBlock.toString().endsWith(":")) {
|
||||||
textBlock.setClassification("H 1");
|
textBlock.setClassification("H 1");
|
||||||
document.setHeadlines(true);
|
document.setHeadlines(true);
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,8 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.apache.pdfbox.util.QuickSort;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
public class SearchableText {
|
public class SearchableText {
|
||||||
@ -217,8 +219,10 @@ public class SearchableText {
|
|||||||
|
|
||||||
public String getAsStringWithLinebreaksSorted(List<TextPositionSequence> sequences) {
|
public String getAsStringWithLinebreaksSorted(List<TextPositionSequence> sequences) {
|
||||||
|
|
||||||
var sorted = sequences.stream()
|
var quickSorted = new ArrayList<>(sequences);
|
||||||
.sorted(new TextPositionSequenceComparator())
|
QuickSort.sort(quickSorted, new TextPositionSequenceComparator());
|
||||||
|
|
||||||
|
var sorted = quickSorted.stream()
|
||||||
.sorted(Comparator.comparing(a -> a.getPage()))
|
.sorted(Comparator.comparing(a -> a.getPage()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user