-
Notifications
You must be signed in to change notification settings - Fork 966
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
Humanized string to number #348
Comments
No |
This is not currently possible but could be a useful feature. Thanks for the suggestion. |
I don't think that this is possible at all as Humanizer definitely not an |
This isn't quite NLP. It's not very easy but it should be doable with a set of predefined rules, much like how the ToWords or Ordinalize work. |
I implemented that already...kind of :) public static int ToNumber(this string @this)
{
for (int i = 0; i < 1000000; i++)
{
if (i.ToOrdinalWords(new CultureInfo("en-US")).ToLower() == @this.ToLower())
return i;
}
throw new ArgumentException(string.Format("Invalid quantifier provided: '{0}'", @this));
} I just hope that there is much cleaner solution for it :) |
LOL. That's not what I had in mind. I suggest you at least cache the entries so you don't have to calculate
|
This is a problem that's been tackled before. I don't think it would be very difficult to add for English. What are some issues with supporting other cultures? |
I agree @jzebedee. It's better to have a feature that can be done for all languages; that said, I honestly don't mind if there are features that are only supported in a couple of languages as long as English support is in there. |
Could we model a solution similar to what Numsense has done already? var englishNumeral = Numeral.English.ToNumeral(42);
// englishNumeral is "forty-two" |
If Numsense is doing this already, is there a further need to incorporate that into Humanizer? Why not just use Numsense directly? |
The Numsense repository has recently been archived by its owner. See ploeh/Numsense#39. |
Is there any chance to convert humanized string to int like this:
?
The text was updated successfully, but these errors were encountered: