-
Notifications
You must be signed in to change notification settings - Fork 19.9k
Add feature to convert numeric words to their number representation #6195
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
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6195 +/- ##
============================================
+ Coverage 73.59% 73.75% +0.15%
- Complexity 5228 5273 +45
============================================
Files 668 669 +1
Lines 18099 18282 +183
Branches 3496 3528 +32
============================================
+ Hits 13320 13483 +163
- Misses 4250 4258 +8
- Partials 529 541 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Your implementation is well-structured and effectively handles a variety of edge cases, including decimals, negative numbers, and large values. |
Thank you for your patience. In my opinion, everything is working now. @siriak |
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.
Looks good, thanks!
clang-format -i --style=file path/to/your/file.java
Features
Accurate Word-to-Number Conversion: Converts English word representations of numbers into their numeric form, supporting values from small fractions to trillions.
Handles Decimals and Negatives: Properly interprets decimal numbers (e.g., "three point one four" → 3.14) and negative values.
Robust Input Validation: Detects invalid phrases, incorrect formatting, and duplicate words (e.g., "one hundred hundred" → Invalid).
BigDecimal Support: Provides a method to directly convert word-based numbers into BigDecimal, ensuring precision for financial and scientific calculations.
Optimized for Readability: Modular design ensures clean, maintainable, and extensible code.
Example Usage
Here’s how you can use the WordsToNumber class in your Java application: