-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
OCR integration #13313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
OCR integration #13313
Conversation
Tip for future - always take a fresh pull from upstream/main before beginning to work on a branch (if there has been a decent time gap). |
Your code currently does not meet JabRef's code guidelines. We use Checkstyle to identify issues. You can see which checks are failing by locating the box "Some checks were not successful" on the pull request page. To see the test output, locate "Tests / Checkstyle (pull_request)" and click on it. In case of issues with the import order, double check that you activated Auto Import. You can trigger fixing imports by pressing Ctrl+Alt+O to trigger Optimize Imports. Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues, commit, and push. |
9f91505
to
db1f577
Compare
Your code currently does not meet JabRef's code guidelines. We use Checkstyle to identify issues. You can see which checks are failing by locating the box "Some checks were not successful" on the pull request page. To see the test output, locate "Tests / Checkstyle (pull_request)" and click on it. In case of issues with the import order, double check that you activated Auto Import. You can trigger fixing imports by pressing Ctrl+Alt+O to trigger Optimize Imports. Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues, commit, and push. |
…tation' into gsoc-ocr-tess4j-initial-implementation
Note that your PR will not be reviewed/accepted until you have gone through the mandatory checks in the description and marked each of them them exactly in the format of |
JUnit tests of You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide. |
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
// Create the OCR action | ||
OcrAction ocrAction = new OcrAction( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is trivial and does not add any new information beyond what is clearly visible in the code. It simply restates what the code is doing.
// Set the action to execute when clicked | ||
ocrItem.setOnAction(event -> ocrAction.execute()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is redundant and merely describes what the code does without providing additional context or reasoning. The code is self-explanatory.
// Disable if the action is not executable (file doesn't exist) | ||
ocrItem.disableProperty().bind(ocrAction.executableProperty().not()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment restates what is evident from the code itself without providing additional insight or explanation about the underlying logic or design decision.
configureTessdata(); | ||
this.isAvailable = true; | ||
LOGGER.debug("Initialized TesseractOcrProvider successfully"); | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catching generic Exception is too broad and may mask specific issues. Should catch specific exceptions that can occur during initialization.
return true; | ||
} | ||
} | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generic Exception catch block in setTessdataPath method should be replaced with specific exceptions like IOException or SecurityException.
|
||
private void configureTessdata() { | ||
// Priority 1: Check user preferences (from settings) | ||
if (filePreferences != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Null check on constructor-injected filePreferences indicates potential null usage. Should use Optional or enforce non-null in constructor.
*/ | ||
record Failure(String errorMessage) implements OcrResult { | ||
public Failure { | ||
// Provide default message instead of throwing exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is trivial and simply describes what the code does. The code is self-explanatory and doesn't need this comment.
@trag-bot didn't find any issues in the code! ✅✨ |
Closes #13267.
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)