Skip to content
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

Help needed: Implementing ord2card in Spanish #121

Open
CarlosUriass opened this issue Feb 12, 2025 · 2 comments
Open

Help needed: Implementing ord2card in Spanish #121

CarlosUriass opened this issue Feb 12, 2025 · 2 comments

Comments

@CarlosUriass
Copy link
Contributor

I want to add support for converting ordinal numbers to cardinal numbers in Spanish, similar to the existing ord2card function for English. However, Spanish has some particular rules, and I’d love some guidance on the best way to implement this.

Challenges & Questions

  1. Handling suffixes: Spanish ordinals often end in "-avo", "-ésimo", or "-mo", but there are exceptions like "primero""uno", "tercero""tres". Any recommendations on edge cases?
  2. Compound ordinals: How should we handle numbers like "vigésimo quinto"25 or "centésimo quincuagésimo tercero"153? Should we split the words and sum the values?
  3. Existing approaches: Are there any existing conventions or resources for number normalization in Spanish that we could leverage?

Next Steps

  • Define a clear rule set for Spanish ordinals.
  • Implement a first version based on feedback.
  • Write tests to cover different cases.

I’d really appreciate any insights or suggestions before I start coding. Thanks in advance! 🙌

@rtxm
Copy link
Collaborator

rtxm commented Feb 12, 2025

Unfortunately the base algorithm used in this Python version of text2num is unable to handle ordinals where all the component are suffixed because it considers the suffix as an end-of-number marker.

The good news is we developed a novel approach, coded in rust, that already fixes that: https://github.com/allo-media/text2num-rs.
You can look at the tests:

We are going to release python bindings for it in the near future. Stay tuned!

@CarlosUriass
Copy link
Contributor Author

Oh, I see! That makes a lot of sense. Thanks for the explanation and for sharing the Rust implementation—I’ll definitely check out the tests to better understand the new approach.

I’m not very experienced with Rust, so I think the best way for me to contribute in the short term would be by working on tests. Is there anything specific you'd like help with in that area? I'd be happy to assist with test cases, validating edge cases, or improving coverage.

Also, I’m very interested in contributing to the new Python features once the bindings are available. Please let me know how I can get involved when that happens!

Looking forward to your guidance. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants