Skip to content

Added MonthPlausibilityComparator to prefer normalized months#14629

Merged
koppor merged 7 commits into
JabRef:mainfrom
D-Prasanth-Kumar:task/month-plausibility-comparator
Jan 24, 2026
Merged

Added MonthPlausibilityComparator to prefer normalized months#14629
koppor merged 7 commits into
JabRef:mainfrom
D-Prasanth-Kumar:task/month-plausibility-comparator

Conversation

@D-Prasanth-Kumar

@D-Prasanth-Kumar D-Prasanth-Kumar commented Dec 16, 2025

Copy link
Copy Markdown
Contributor

User description

Closes #14457

Mandatory checks

Screenshot

Merge Dialog automatically preferring the normalized month format
Screenshot 2025-12-16 114316


PR Type

Enhancement


Description

  • Added MonthPlausibilityComparator to intelligently compare month field values

  • Prefers normalized months (#jun#) and integers over plain text strings

  • Integrated comparator into merge dialog for automatic field selection

  • Added comprehensive unit tests and JavaDoc documentation


Diagram Walkthrough

flowchart LR
  A["Month Field Values"] -->|Parse & Compare| B["MonthPlausibilityComparator"]
  B -->|Check Format| C["isStrictFormat"]
  C -->|Prefer| D["Normalized/Integer Format"]
  D -->|Result| E["Merge Dialog Auto-Selection"]
Loading

File Walkthrough

Relevant files
Enhancement
MonthPlausibilityComparator.java
New month field value comparator implementation                   

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

  • New comparator class implementing FieldValuePlausibilityComparator
    interface
  • Compares two month values and prefers normalized formats (#jun#) or
    integers
  • Returns UNDETERMINED when months differ or both are unparseable
  • Delegates format checking to Month.isStrictFormat() method
+44/-0   
Month.java
Add strict format validation for month values                       

jablib/src/main/java/org/jabref/model/entry/Month.java

  • Added static method isStrictFormat() to check if month value is in
    strict BibTeX format
  • Recognizes integers (e.g., "6") and BibTeX strings (e.g., "#jun#") as
    strict format
  • Plain text months (e.g., "June") are considered non-strict format
+17/-0   
PlausibilityComparatorFactory.java
Register month comparator in factory                                         

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

  • Integrated MonthPlausibilityComparator into factory pattern
  • Returns comparator when field has FieldProperty.MONTH property
  • Follows existing pattern used for person names and year fields
+3/-0     
FieldRowViewModel.java
Enable auto-selection in field row view model                       

jabgui/src/main/java/org/jabref/gui/mergeentries/threewaymerge/FieldRowViewModel.java

  • Added call to autoSelectBetterValue() in constructor initialization
  • Enables automatic selection of better month format during merge
    operations
+2/-0     
Tests
MonthPlausibilityComparatorTest.java
Comprehensive unit tests for month comparator                       

jablib/src/test/java/org/jabref/logic/bibtex/comparator/plausibility/MonthPlausibilityComparatorTest.java

  • New parameterized test class with 12 test cases covering various month
    comparison scenarios
  • Tests preference of normalized formats over plain text
  • Tests handling of invalid/unparseable month values
  • Tests comparison of different months returning UNDETERMINED
+37/-0   
Documentation
CHANGELOG.md
Document month comparator feature in changelog                     

CHANGELOG.md

  • Added entry documenting new month field plausibility comparator
    feature
  • Explains preference for normalized months and integers in merge dialog
  • References issue Add MonthPlausibilityComparator #14457
+1/-0     

@github-actions github-actions Bot added the good first issue An issue intended for project-newcomers. Varies in difficulty. label Dec 16, 2025

@koppor koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please learn from last PRs We don't want to repeat the same comments over and over again.

#14546 (comment)

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Dec 16, 2025
@D-Prasanth-Kumar

Copy link
Copy Markdown
Contributor Author

Please learn from last PRs We don't want to repeat the same comments over and over again.

#14546 (comment)

I am sorry for causing you to repeat this feedback. I am adding the test case immediately

@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Dec 16, 2025
@calixtus calixtus added the component: merge Merging of BibTeX entries, merge entry dialog, diffing ... label Dec 16, 2025

@koppor koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests should be created using @ParameterizedTest

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Dec 17, 2025

@koppor koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code does not cover all cases.

Moreover, org.jabref.model.entry.Month#parse should be used to check for validity.

@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Dec 17, 2025
@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Dec 20, 2025
@github-actions

Copy link
Copy Markdown
Contributor

Your pull request conflicts with the target branch.

Please merge with your code. For a step-by-step guide to resolve merge conflicts, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line.

@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: changes-required Pull requests that are not yet complete labels Dec 20, 2025
@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: changes-required Pull requests that are not yet complete labels Dec 22, 2025
@calixtus

Copy link
Copy Markdown
Member

Please change the test according to @koppor s comment and adapt the code. (TTD)

Comment thread jablib/src/main/java/org/jabref/model/entry/Month.java Outdated
@D-Prasanth-Kumar

Copy link
Copy Markdown
Contributor Author

Thanks for the guidance @koppor @HoussemNasri @calixtus. This PR has become quite complicated with the various changes and merge conflicts. I’ve decided to close it for now to rethink the approach and perhaps start fresh later.

@github-actions

Copy link
Copy Markdown
Contributor

This pull requests was closed without merging. You have been unassigned from the respective issue #14457. In case you closed the PR for yourself, you can re-open it. Please also check After submission of a pull request in the CONTRIBUTING.md

@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Jan 2, 2026
@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Jan 7, 2026
@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Jan 19, 2026
Comment thread jablib/src/test/java/org/jabref/model/entry/MonthTest.java Outdated
Comment thread jablib/src/main/java/org/jabref/model/entry/Month.java Outdated
Comment thread jablib/src/main/java/org/jabref/model/entry/Month.java Outdated
Comment thread jablib/src/test/java/org/jabref/model/entry/MonthTest.java
@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Jan 22, 2026
@koppor

koppor commented Jan 22, 2026

Copy link
Copy Markdown
Member

I think, we are close to merging now :). Please merge upstream/main to have the latest tests also in your branch.

@koppor koppor added this to the 6.0-alpha.6 milestone Jan 23, 2026
@D-Prasanth-Kumar D-Prasanth-Kumar force-pushed the task/month-plausibility-comparator branch from c5d8056 to 40ef8cf Compare January 23, 2026 17:57
@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Jan 23, 2026
@D-Prasanth-Kumar

Copy link
Copy Markdown
Contributor Author

@koppor can you once review the pr, as the pr is created way back there were lot of things happened and after having the latest changes to my branch there were few failed builds ...

@koppor koppor force-pushed the task/month-plausibility-comparator branch from 0479c71 to b9c5f86 Compare January 24, 2026 06:26

@koppor koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now. Thank you for following-up.

@koppor koppor enabled auto-merge January 24, 2026 06:29
@koppor koppor added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Jan 24, 2026
@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Jan 24, 2026
@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Jan 24, 2026
@koppor koppor added this pull request to the merge queue Jan 24, 2026
Merged via the queue into JabRef:main with commit 45f23c8 Jan 24, 2026
57 of 62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: merge Merging of BibTeX entries, merge entry dialog, diffing ... good first issue An issue intended for project-newcomers. Varies in difficulty. Review effort 2/5 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.

Add MonthPlausibilityComparator

4 participants