Conversation
9ab441e to
5b5bd53
Compare
5b5bd53 to
0357026
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ba219b1 to
6e0875e
Compare
This comment has been minimized.
This comment has been minimized.
>> >> When a file pattern uses [DATE] and no exact match is found, the finder >> now falls back to progressively less specific date formats (year-month, >> then year-only) before returning empty.
Review Summary by QodoAdd date fallback search for file finder patterns
WalkthroughsDescription• Implement fallback search for [DATE] patterns in file finder - Tries exact date (YYYY-MM-DD) first, then year-month (YYYY-MM), then year-only (YYYY) - Constructs date from year, month, day fields if date field absent - Handles BibTeX month strings and date ranges • Add comprehensive parameterized tests for date fallback behavior • Refactor test code for improved readability and maintainability Diagramflowchart LR
A["[DATE] pattern detected"] --> B["Get date candidates"]
B --> C["Extract from date field"]
B --> D["Construct from year/month/day"]
C --> E["Build candidates list"]
D --> E
E --> F["Try exact match YYYY-MM-DD"]
F --> G{Match found?}
G -->|Yes| H["Return results"]
G -->|No| I["Try YYYY-MM"]
I --> J{Match found?}
J -->|Yes| H
J -->|No| K["Try YYYY"]
K --> L{Match found?}
L -->|Yes| H
L -->|No| M["Return empty"]
File Changes1. jablib/src/main/java/org/jabref/logic/util/io/RegExpBasedFileFinder.java
|
Code Review by Qodo
1. setField used on new BibEntry
|
This comment has been minimized.
This comment has been minimized.
…nto fix/date-fallback-file-finder
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
While working through this issue and local testing I encountered the same bug from #8902 . When testing date range, it would truncate to starting date in the entry field on biblatex. Update: Can confirm this is still the case walking through steps to test the bug. This is affecting the behavior of linking files given range of dates. If you try to link files using date regex with date range 2021-01-01/2021-12-31. It wont find any files if there are no files with 2021-01-01 in its name, which is obviously a consequence of whatever is going on with that bug, (e.g it truncates to 2021-01-01 and I'm assuming is saved as the truncated date) I might try to look at #8902 and see if I can fix it so that linking files using date regex isn't also broken as a consequence. |
| String cleanedContent = FileNameCleaner.cleanFileName(expandedContent); | ||
| return expandedContent.equals(cleanedContent) ? Pattern.quote(expandedContent) : | ||
| "(" + Pattern.quote(expandedContent) + ")|(" + Pattern.quote(cleanedContent) + ")"; | ||
| return expandedContent.equals(cleanedContent) ? Pattern.quote(expandedContent) : "(" + Pattern.quote(expandedContent) + ")|(" + Pattern.quote(cleanedContent) + ")"; |
There was a problem hiding this comment.
PLease keep the existing formatting; it makes it easier to understand the expression
| "directory/subdirectory/pdfInSubdirectory.pdf", | ||
| "directory/subdirectory/GUO ea - INORG CHEM COMMUN 2010 - Ferroelectric Metal Organic Framework (MOF).pdf" | ||
| ); | ||
| private static final List<String> FILE_NAMES = List.of("ACM_IEEE-CS.pdf", "pdfInDatabase.pdf", "Regexp from [A-Z].pdf", "directory/subdirectory/2003_Hippel_209.pdf", "directory/subdirectory/2017_Gražulis_726.pdf", "directory/subdirectory/pdfInSubdirectory.pdf", "directory/subdirectory/GUO ea - INORG CHEM COMMUN 2010 - Ferroelectric Metal Organic Framework (MOF).pdf"); |
There was a problem hiding this comment.
pleas keep the existing formatting, this is hard to read
There was a problem hiding this comment.
Will fix this and any other formatting issue today when I have time
| .withField(StandardField.AUTHOR, "Guo, M. and Cai, H.-L. and Xiong, R.-G.") | ||
| .withField(StandardField.JOURNAL, "Inorganic Chemistry Communications") | ||
| .withField(StandardField.YEAR, "2010"); | ||
| BibEntry bibEntry = new BibEntry().withCitationKey("Guo_ICC_2010").withField(StandardField.TITLE, "Ferroelectric Metal Organic Framework (MOF)").withField(StandardField.AUTHOR, "Guo, M. and Cai, H.-L. and Xiong, R.-G.").withField(StandardField.JOURNAL, "Inorganic Chemistry Communications").withField(StandardField.YEAR, "2010"); |
There was a problem hiding this comment.
same here, keep the existing formatting
There was a problem hiding this comment.
addressed all occurences
✅ All tests passed ✅🏷️ Commit: efba242 Learn more about TestLens at testlens.app. |
|
LGTM and tests are green. Lets move forward. |
Related issues and pull requests
Closes #8152
PR Description
Note: This addresses solution 2 outlined in #8152 and does not fix [YEAR], instead addresses it using [DATE] strict matching.
Bibtex after:
bibtext-year-month.mp4
Biblatex after:
biblatex-allcases.mp4
Steps to test
**/.*[DATE].*\\.[extension]Checklist
CHANGELOG.mdin a way that can be understood by the average user (if change is visible to the user)