-
Notifications
You must be signed in to change notification settings - Fork 6
Add interactive language selection and command-line options for OCR4Linux #19
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
Conversation
…inux - Implemented interactive language selection using rofi in the shell script. - Added support for specifying languages via command-line arguments. - Updated README.md to reflect new features and usage instructions.
|
Caution Review failedFailed to post review comments. Configuration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (3)
🧰 Additional context used🪛 LanguageToolREADME.md[grammar] ~22-~22: There might be a mistake here. (QB_NEW_EN) [grammar] ~23-~23: There might be a mistake here. (QB_NEW_EN) [grammar] ~33-~33: There might be a mistake here. (QB_NEW_EN) [grammar] ~71-~71: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~98-~98: There might be a problem here. (QB_NEW_EN_MERGED_MATCH) [grammar] ~99-~99: There might be a mistake here. (QB_NEW_EN) [grammar] ~99-~99: There might be a problem here. (QB_NEW_EN_MERGED_MATCH) [grammar] ~100-~100: Insert the missing word (QB_NEW_EN_OTHER_ERROR_IDS_32) [grammar] ~104-~104: There might be a mistake here. (QB_NEW_EN_OTHER) [grammar] ~104-~104: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~106-~106: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~108-~108: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~110-~110: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~112-~112: Use hyphens correctly (QB_NEW_EN_OTHER_ERROR_IDS_29) [grammar] ~114-~114: There might be a mistake here. (QB_NEW_EN_OTHER) [grammar] ~116-~116: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~118-~118: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~120-~120: There might be a mistake here. (QB_NEW_EN_OTHER) [grammar] ~122-~122: There might be a mistake here. (QB_NEW_EN_OTHER) [grammar] ~124-~124: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~126-~126: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~128-~128: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~130-~130: There might be a mistake here. (QB_NEW_EN) [grammar] ~131-~131: There might be a mistake here. (QB_NEW_EN) [grammar] ~132-~132: There might be a mistake here. (QB_NEW_EN) [grammar] ~133-~133: There might be a mistake here. (QB_NEW_EN_OTHER) [grammar] ~134-~134: There might be a mistake here. (QB_NEW_EN) [grammar] ~135-~135: There might be a mistake here. (QB_NEW_EN) [grammar] ~136-~136: There might be a mistake here. (QB_NEW_EN) [grammar] ~137-~137: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~139-~139: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~143-~143: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~145-~145: There might be a mistake here. (QB_NEW_EN) [grammar] ~146-~146: There might be a mistake here. (QB_NEW_EN) [grammar] ~147-~147: There might be a mistake here. (QB_NEW_EN) [grammar] ~148-~148: There might be a mistake here. (QB_NEW_EN) [grammar] ~149-~149: There might be a mistake here. (QB_NEW_EN) [grammar] ~150-~150: There might be a mistake here. (QB_NEW_EN) [grammar] ~151-~151: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~153-~153: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~155-~155: There might be a mistake here. (QB_NEW_EN_OTHER) [grammar] ~157-~157: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~159-~159: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~161-~161: There might be a mistake here. (QB_NEW_EN) [grammar] ~162-~162: There might be a mistake here. (QB_NEW_EN) [grammar] ~163-~163: There might be a mistake here. (QB_NEW_EN) [grammar] ~164-~164: There might be a mistake here. (QB_NEW_EN) [grammar] ~165-~165: There might be a mistake here. (QB_NEW_EN) [grammar] ~166-~166: There might be a mistake here. (QB_NEW_EN) [grammar] ~167-~167: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~169-~169: There might be a mistake here. (QB_NEW_EN_OTHER) [grammar] ~200-~200: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~221-~221: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~223-~223: There might be a problem here. (QB_NEW_EN_MERGED_MATCH) [grammar] ~225-~225: There might be a mistake here. (QB_NEW_EN_OTHER) [grammar] ~227-~227: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~229-~229: There might be a mistake here. (QB_NEW_EN_OTHER) [grammar] ~233-~233: There might be a mistake here. (QB_NEW_EN_OTHER) [grammar] ~235-~235: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~237-~237: There might be a mistake here. (QB_NEW_EN_OTHER) [grammar] ~238-~238: There might be a mistake here. (QB_NEW_EN) [grammar] ~238-~238: There might be a mistake here. (QB_NEW_EN_OTHER) [grammar] ~239-~239: There might be a mistake here. (QB_NEW_EN_OTHER) [grammar] ~241-~241: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~243-~243: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~245-~245: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~255-~255: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~257-~257: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~267-~267: There might be a mistake here. (QB_NEW_EN) [grammar] ~268-~268: There might be a mistake here. (QB_NEW_EN_OTHER) [grammar] ~270-~270: There might be a mistake here. (QB_NEW_EN_OTHER) [grammar] ~272-~272: Use correct spacing (QB_NEW_EN_OTHER_ERROR_IDS_5) [grammar] ~275-~275: There might be a mistake here. (QB_NEW_EN) 🪛 markdownlint-cli2 (0.17.2)README.md21-21: Unordered list indentation (MD007, ul-indent) 22-22: Unordered list indentation (MD007, ul-indent) 23-23: Unordered list indentation (MD007, ul-indent) 33-33: Unordered list indentation (MD007, ul-indent) 108-108: Heading levels should only increment by one level at a time (MD001, heading-increment) 223-223: Unordered list indentation (MD007, ul-indent) 225-225: Unordered list indentation (MD007, ul-indent) 226-226: Unordered list indentation (MD007, ul-indent) 227-227: Unordered list indentation (MD007, ul-indent) 229-229: Unordered list indentation (MD007, ul-indent) 230-230: Unordered list indentation (MD007, ul-indent) 231-231: Unordered list indentation (MD007, ul-indent) 232-232: Unordered list indentation (MD007, ul-indent) 233-233: Unordered list indentation (MD007, ul-indent) 237-237: Unordered list indentation (MD007, ul-indent) 238-238: Unordered list indentation (MD007, ul-indent) 239-239: Unordered list indentation (MD007, ul-indent) 243-243: Trailing punctuation in heading (MD026, no-trailing-punctuation) 245-245: Unordered list indentation (MD007, ul-indent) 255-255: Trailing punctuation in heading (MD026, no-trailing-punctuation) 257-257: Unordered list indentation (MD007, ul-indent) 268-268: Unordered list indentation (MD007, ul-indent) 269-269: Unordered list indentation (MD007, ul-indent) 270-270: Unordered list indentation (MD007, ul-indent) 📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds configurable OCR language selection across the Python and shell scripts: new CLI flags (--langs/--lang), optional interactive selection via rofi, updated argument parsing and help, propagation of language settings to Tesseract, a small encoding attribute rename, and README updates documenting both direct and interactive flows. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User
participant SH as OCR4Linux.sh
participant R as rofi (interactive)
participant PY as OCR4Linux.py
participant TES as Tesseract
participant CB as Clipboard
U->>SH: Run script [-r/-d/-l/--lang LANGS]
alt --lang provided
SH->>SH: process_specified_langs()
else interactive
SH->>R: choose_lang() prompt
R-->>SH: Selected languages
end
SH->>SH: Take screenshot to file
SH->>PY: Invoke with --langs (if set) and paths
PY->>PY: Configure TesseractConfig(langs)
PY->>TES: OCR image with selected langs
TES-->>PY: Extracted text
PY-->>SH: Output text (UTF-8)
SH->>CB: Copy to clipboard
SH-->>U: Done (logs emitted)
opt Error paths
SH->>U: Log error (missing rofi, invalid langs, etc.)
end
sequenceDiagram
autonumber
participant CLI as CLI (args)
participant PY as OCR4Linux.py
participant CFG as TesseractConfig
participant TES as Tesseract
CLI->>PY: Parse args [image, output, --langs?]
PY->>CFG: __init__(image_path, output_path, langs)
note right of CFG: If langs empty: use all available or 'eng'
CFG->>TES: Run OCR with lang string
TES-->>PY: Text
PY-->>CLI: Write output (output_encoding UTF-8)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Ruff (0.12.2)OCR4Linux.py�[1;31mruff failed�[0m ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Pull Request Overview
This pull request adds interactive language selection capabilities to OCR4Linux through a rofi-based menu system and direct command-line language specification. Users can now either specify languages directly via the --lang option or select them interactively from a menu, improving flexibility for multi-language OCR processing.
- Interactive language selection menu using
rofiwith multi-select support - Direct command-line language specification via
--langoption in the shell script and--langsin the Python script - Fixed typos in the Python TesseractConfig class and updated documentation
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| README.md | Comprehensive documentation updates covering new language selection features, usage examples, and workflow explanations |
| OCR4Linux.sh | Added interactive rofi-based language selection, command-line language specification, and updated argument parsing |
| OCR4Linux.py | Added language parameter support, fixed typos in TesseractConfig class, and updated argument handling |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This pull request introduces interactive and flexible language selection for OCR processing in OCR4Linux, both in the Bash (
OCR4Linux.sh) and Python (OCR4Linux.py) scripts thanks to @HexChap for his inspiration. Users can now specify languages directly via command-line options or use an interactive menu powered byrofi. The documentation (README.md) is updated to reflect these new features and usage patterns.Language Selection Enhancements
--langoption toOCR4Linux.shfor specifying OCR languages directly (e.g.,--lang eng+fraor--lang all), bypassing the interactive menu. If not provided, arofi-based menu allows users to interactively choose one or more languages. ([[1]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-01d7fb14176bf75976a4ed0a47fed53e49c2ffa1dd5c2844afaee5ba98a25389R43-R46),[[2]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-01d7fb14176bf75976a4ed0a47fed53e49c2ffa1dd5c2844afaee5ba98a25389R55-R94),[[3]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-01d7fb14176bf75976a4ed0a47fed53e49c2ffa1dd5c2844afaee5ba98a25389R146-R189),[[4]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-01d7fb14176bf75976a4ed0a47fed53e49c2ffa1dd5c2844afaee5ba98a25389R266-R273))[OCR4Linux.shR146-R189](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-01d7fb14176bf75976a4ed0a47fed53e49c2ffa1dd5c2844afaee5ba98a25389R146-R189))[OCR4Linux.shR266-R273](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-01d7fb14176bf75976a4ed0a47fed53e49c2ffa1dd5c2844afaee5ba98a25389R266-R273))Python Script Improvements
OCR4Linux.pyto accept an optional--langsargument, supporting both--langs=eng+fraand--langs eng+fraforms, and defaulting to all available languages if not specified. ([[1]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-8d235df76c33e3dcb73754335872fc339873557f11c8c557aa2669c242c6ebcfL63-R93),[[2]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-8d235df76c33e3dcb73754335872fc339873557f11c8c557aa2669c242c6ebcfL202-R230),[[3]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-8d235df76c33e3dcb73754335872fc339873557f11c8c557aa2669c242c6ebcfR287-R295))TesseractConfigclass, renamingouput_encodingtooutput_encodingthroughout. ([[1]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-8d235df76c33e3dcb73754335872fc339873557f11c8c557aa2669c242c6ebcfL49-R49),[[2]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-8d235df76c33e3dcb73754335872fc339873557f11c8c557aa2669c242c6ebcfL63-R93),[[3]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-8d235df76c33e3dcb73754335872fc339873557f11c8c557aa2669c242c6ebcfL118-R127))[[1]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-8d235df76c33e3dcb73754335872fc339873557f11c8c557aa2669c242c6ebcfL152-R175),[[2]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-8d235df76c33e3dcb73754335872fc339873557f11c8c557aa2669c242c6ebcfL255-R271))Documentation Updates
README.mdto document the new interactive language selection menu, the--langoption, and updated usage examples for both scripts. Emphasized the requirement forrofiand detailed the workflow for language selection and OCR processing. ([[1]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L21-R23),[[2]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R33),[[3]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R71-R72),[[4]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L94-R137),[[5]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L103-R211))Dependency and Usability Improvements
rofias a required dependency for the interactive menu and included checks to ensure it is installed before running the script. ([[1]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-01d7fb14176bf75976a4ed0a47fed53e49c2ffa1dd5c2844afaee5ba98a25389R26),[[2]](https://github.com/moheladwy/OCR4Linux/pull/19/files#diff-01d7fb14176bf75976a4ed0a47fed53e49c2ffa1dd5c2844afaee5ba98a25389R117-R122))These changes significantly improve user experience by making multi-language OCR selection intuitive and flexible, while keeping the workflow transparent and well-documented.