Skip to content

Heuristics also used at batch#15025

Merged
Siedlerchr merged 3 commits into
mainfrom
use-heuristics-at-batch
Feb 4, 2026
Merged

Heuristics also used at batch#15025
Siedlerchr merged 3 commits into
mainfrom
use-heuristics-at-batch

Conversation

@koppor

@koppor koppor commented Feb 4, 2026

Copy link
Copy Markdown
Member

User description

We have the batch-update. We introduced heuristics to select the "better" field. This heuristics is also used at batch-update now.

Steps to test

Some how at "Loopkup" -> "... fully automated ..."

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • [/] I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • I described the change in CHANGELOG.md in a way that is understandable for the average user (if change is visible to the user)
  • [/] I checked the user documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.

PR Type

Enhancement


Description

  • Apply field plausibility heuristics to batch update operations

  • Replace simple empty-check with intelligent field comparison logic

  • Reuse existing PlausibilityComparator infrastructure for consistency


Diagram Walkthrough

flowchart LR
  A["shouldUpdateField method"] -->|now receives| B["Field parameter"]
  B -->|uses| C["PlausibilityComparatorFactory"]
  C -->|gets comparator for| D["specific field type"]
  D -->|compares values| E["LEFT_BETTER result"]
  E -->|determines if| F["update should occur"]
Loading

File Walkthrough

Relevant files
Enhancement
MergeEntriesHelper.java
Integrate plausibility comparators into field merge logic

jabgui/src/main/java/org/jabref/gui/mergeentries/MergeEntriesHelper.java

  • Added imports for ComparisonResult and PlausibilityComparatorFactory
  • Modified shouldUpdateField method signature to accept Field parameter
  • Replaced simple empty-check logic with plausibility comparator-based
    comparison
  • Now intelligently selects better field values using field-specific
    comparators
+13/-7   
Documentation
PlausibilityComparatorFactory.java
Add documentation reference to issue tracker                         

jablib/src/main/java/org/jabref/logic/bibtex/comparator/plausibility/PlausibilityComparatorFactory.java

+1/-0     
CHANGELOG.md
Document batch update heuristics feature                                 

CHANGELOG.md

  • Added entry documenting batch update now uses heuristics for field
    selection
  • Placed in user-visible changes section for clarity
+1/-0     

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Missing null handling: The shouldUpdateField method does not handle potential null values from fetcherValue
parameter before passing to comparator

Referred Code
private static boolean shouldUpdateField(Field field, String fetcherValue, Optional<String> libraryValue) {
    if (libraryValue.isEmpty()) {
        return true;
    }

    return PlausibilityComparatorFactory.INSTANCE.getPlausibilityComparator(field)
            .map(comparator -> comparator.compare(fetcherValue, libraryValue.get()))
            .filter(result -> result == ComparisonResult.LEFT_BETTER)
            .map(_ -> true)
            .orElse(false);
}

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Learned
best practice
Update outdated documentation comment

The comment states "longer field values preferred" but the new implementation
uses plausibility comparators for field quality comparison, not length. Update
the documentation to accurately reflect the current behavior.

jabgui/src/main/java/org/jabref/gui/mergeentries/MergeEntriesHelper.java [20-22]

 /// Helper class for merging bibliography entries with undo support.
-/// Source entry data is merged into the library entry, with longer field values preferred
+/// Source entry data is merged into the library entry, with better quality field values preferred
 /// and obsolete fields removed.

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 6

__

Why:
Relevant best practice - Fix typographical errors in comments and documentation to maintain professionalism and clarity

Low
General
Simplify Optional usage with isPresent

Simplify the Optional processing chain by replacing
.filter(...).map(...).orElse(false) with the more concise
.filter(...).isPresent().

jabgui/src/main/java/org/jabref/gui/mergeentries/MergeEntriesHelper.java [102-112]

 private static boolean shouldUpdateField(Field field, String fetcherValue, Optional<String> libraryValue) {
     if (libraryValue.isEmpty()) {
         return true;
     }
 
     return PlausibilityComparatorFactory.INSTANCE.getPlausibilityComparator(field)
-            .map(comparator -> comparator.compare(fetcherValue, libraryValue.get()))
-            .filter(result -> result == ComparisonResult.LEFT_BETTER)
-            .map(_ -> true)
-            .orElse(false);
+                                                  .map(comparator -> comparator.compare(fetcherValue, libraryValue.get()))
+                                                  .filter(result -> result == ComparisonResult.LEFT_BETTER)
+                                                  .isPresent();
 }
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why: The suggestion correctly identifies that the .filter(...).map(...).orElse(false) chain is functionally equivalent to .filter(...).isPresent(). Applying this change improves code conciseness and readability by using a more idiomatic approach for this check.

Low
  • Update

@koppor koppor added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Feb 4, 2026
@Siedlerchr Siedlerchr added this pull request to the merge queue Feb 4, 2026
@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Feb 4, 2026
Merged via the queue into main with commit 0be9b4b Feb 4, 2026
56 checks passed
@Siedlerchr Siedlerchr deleted the use-heuristics-at-batch branch February 4, 2026 19:46
Siedlerchr added a commit to Jalina2007/jabref that referenced this pull request Feb 5, 2026
…4902

* upstream/main: (23 commits)
  Some more recipes from OpenRewrite (JabRef#15030)
  feat: Add PDF Upload endpoint to EntryResource (JabRef#14963)
  Heuristics also used at batch (JabRef#15025)
  Fix cleanup-pr.yml
  New Crowdin updates (JabRef#15035)
  Use patched Gradle version (JabRef#15034)
  Add OpenAlex-based Citation Fetcher (JabRef#15023)
  Update null annotaitons at EntryBasedFetcher (JabRef#15024)
  Fix CHANGELOG.md test
  Use _ for unused variables (JabRef#15028)
  Use ubuntu-latest for checkstyle and javadoc
  Update Gradle Wrapper from 9.3.0-jabref-2 to 9.3.1 (JabRef#15021)
  Use "ubuntu-slim" for most workflows (JabRef#15019)
  Refine GroupsTree (JabRef#15013)
  New Crowdin updates (JabRef#15018)
  Added Clear group option (JabRef#15017)
  Chore(deps): Bump com.uber.nullaway:nullaway from 0.12.15 to 0.13.1 in /versions (JabRef#15006)
  Chore(deps): Bump tools.jackson:jackson-bom in /versions (JabRef#15007)
  No rush in Docker building
  Yaml issue workaround
  ...
Siedlerchr added a commit that referenced this pull request Feb 8, 2026
…es/jablib/src/main/resources/csl-styles-6c79ffe

* upstream/main: (68 commits)
  Chore(deps): Bump org.apache.httpcomponents.client5:httpclient5 (#15060)
  Chore(deps): Bump com.google.errorprone:error_prone_core in /versions (#15059)
  Chore(deps): Bump de.undercouch.download:de.undercouch.download.gradle.plugin (#15057)
  Chore(deps): Bump org.postgresql:postgresql in /versions (#15058)
  Chore(deps): Bump de.undercouch.download:de.undercouch.download.gradle.plugin (#15056)
  Updates on Wednesday, not on Sunday
  Add screenshot requirement (#15050)
  Switch image for javadoc
  Better docker layer caching during build (#15042)
  New Crowdin updates (#15045)
  Chore: reuse shared 'setup-gradle' in all places in test-code.yml (#15043)
  Chore: add 'testlens-app/setup-testlens' GH action (#15044)
  Add: HTTP Server and LSP server toggles to quick settings (#14972)
  Some more recipes from OpenRewrite (#15030)
  feat: Add PDF Upload endpoint to EntryResource (#14963)
  Heuristics also used at batch (#15025)
  Fix cleanup-pr.yml
  New Crowdin updates (#15035)
  Use patched Gradle version (#15034)
  Add OpenAlex-based Citation Fetcher (#15023)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review effort 2/5 status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers status: to-be-merged PRs which are accepted and should go into the merge-queue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants