From 772f24b7d4a7af8c2a019f608280df2d5977c86f Mon Sep 17 00:00:00 2001 From: Christoph Date: Fri, 10 Jan 2025 13:07:25 +0100 Subject: [PATCH 1/3] Downgrade Ubuntu (#12375) Refs https://github.com/actions/runner-images/issues/10636 Hopefully Fixes https://github.com/JabRef/jabref/issues/12370 --- .github/workflows/deployment.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 879b495e040..a82be79aae7 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -38,9 +38,9 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-13] + os: [ubuntu-22.04, windows-latest, macos-13] include: - - os: ubuntu-latest + - os: ubuntu-22.04 displayName: linux archivePortable: tar -c -C build/distribution JabRef | pigz --rsyncable > build/distribution/JabRef-portable_linux.tar.gz && rm -R build/distribution/JabRef - os: windows-latest From 94f0f4e27c6bbd1c8b909fbb6f70a50bc0f1566c Mon Sep 17 00:00:00 2001 From: Loay Ghreeb Date: Fri, 10 Jan 2025 18:26:21 +0200 Subject: [PATCH 2/3] Searching for entries with empty field (#12376) * Searching for entries with empty field * Simplify condition --- .../search/query/SearchToSqlVisitor.java | 10 ++++++ .../query/SearchQuerySQLConversionTest.java | 32 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/main/java/org/jabref/logic/search/query/SearchToSqlVisitor.java b/src/main/java/org/jabref/logic/search/query/SearchToSqlVisitor.java index e204ea9de78..8805c9b19cc 100644 --- a/src/main/java/org/jabref/logic/search/query/SearchToSqlVisitor.java +++ b/src/main/java/org/jabref/logic/search/query/SearchToSqlVisitor.java @@ -207,6 +207,16 @@ public SqlQueryNode visitComparison(SearchParser.ComparisonContext ctx) { setFlags(searchFlags, REGULAR_EXPRESSION, true, true); } + // field = "" -> should find entries where the field is empty + // field != "" -> should find entries where the field is not empty + if (term.isEmpty()) { + if (searchFlags.contains(NEGATION)) { + searchFlags.remove(NEGATION); + } else { + searchFlags.add(NEGATION); + } + } + return getFieldQueryNode(field.toLowerCase(Locale.ROOT), term, searchFlags); } diff --git a/src/test/java/org/jabref/logic/search/query/SearchQuerySQLConversionTest.java b/src/test/java/org/jabref/logic/search/query/SearchQuerySQLConversionTest.java index 87172feff1d..755171768ec 100644 --- a/src/test/java/org/jabref/logic/search/query/SearchQuerySQLConversionTest.java +++ b/src/test/java/org/jabref/logic/search/query/SearchQuerySQLConversionTest.java @@ -695,6 +695,38 @@ cte0 AS ( ) ) SELECT * FROM cte0 GROUP BY entryid""" + ), + + Arguments.of( + "file = \"\"", + """ + WITH + cte0 AS ( + SELECT main_table.entryid + FROM bib_fields."tableName" AS main_table + WHERE main_table.entryid NOT IN ( + SELECT inner_table.entryid + FROM bib_fields."tableName" AS inner_table + WHERE ( + (inner_table.field_name = 'file') AND ((inner_table.field_value_literal ILIKE ('%%')) OR (inner_table.field_value_transformed ILIKE ('%%'))) + ) + ) + ) + SELECT * FROM cte0 GROUP BY entryid""" + ), + + Arguments.of( + "file != \"\"", + """ + WITH + cte0 AS ( + SELECT main_table.entryid + FROM bib_fields."tableName" AS main_table + WHERE ( + (main_table.field_name = 'file') AND ((main_table.field_value_literal ILIKE ('%%')) OR (main_table.field_value_transformed ILIKE ('%%'))) + ) + ) + SELECT * FROM cte0 GROUP BY entryid""" ) ); } From 2cd83dfdb056482aad9595489a4a7c4b796f6e37 Mon Sep 17 00:00:00 2001 From: leaf-soba Date: Sat, 11 Jan 2025 00:35:13 +0800 Subject: [PATCH 3/3] Refactor the isUnwantedText (#12369) * Refactor the IsFarAway 1. Add comment 2. minor refactor * remove extra space remove extra space * remove unnecessary quote remove unnecessary quote --------- Co-authored-by: Christoph --- .../fileformat/PdfContentImporter.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java index 14a5b1e6c21..6a8eae4c769 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java @@ -252,16 +252,24 @@ private boolean isFarAway(TextPosition previous, TextPosition current) { return Math.abs(Xgap) > XspaceThreshold && Math.abs(Ygap) > YspaceThreshold; } - private boolean isUnwantedText(TextPosition previousTextPosition, TextPosition textPosition) { + private boolean isUnwantedText(TextPosition previousTextPosition, TextPosition textPosition, + Map lastPositionMap, float fontSize) { + // This indicates that the text is at the start of the line, so it is needed. if (textPosition == null || previousTextPosition == null) { return false; } + // We use the font size to identify titles. Blank characters don't have a font size, so we discard them. + // The space will be added back in the final result, but not in this method. if (StringUtil.isBlank(textPosition.getUnicode())) { return true; } - // The title usually don't in the bottom 10% of a page. - return (textPosition.getPageHeight() - textPosition.getYDirAdj()) - < (textPosition.getPageHeight() * 0.1); + // Titles are generally not located in the bottom 10% of a page. + if ((textPosition.getPageHeight() - textPosition.getYDirAdj()) < (textPosition.getPageHeight() * 0.1)) { + return true; + } + // Characters in a title typically remain close together, + // so a distant character is unlikely to be part of the title. + return lastPositionMap.containsKey(fontSize) && isFarAway(lastPositionMap.get(fontSize), textPosition); } private Optional findLargestFontText(List textPositions) { @@ -271,8 +279,7 @@ private Optional findLargestFontText(List textPositions) { for (TextPosition textPosition : textPositions) { float fontSize = textPosition.getFontSizeInPt(); // Exclude unwanted text based on heuristics - if (isUnwantedText(previousTextPosition, textPosition) || - (lastPositionMap.containsKey(fontSize) && isFarAway(lastPositionMap.get(fontSize), textPosition))) { + if (isUnwantedText(previousTextPosition, textPosition, lastPositionMap, fontSize)) { continue; } fontSizeTextMap.putIfAbsent(fontSize, new StringBuilder());