Add feature to convert numeric words to their number representation#6195
Add feature to convert numeric words to their number representation#6195siriak merged 18 commits intoTheAlgorithms:masterfrom
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 |
clang-format -i --style=file path/to/your/file.javaFeatures
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: