Live data from Hacker News

Show HN: Convert a number to an approximated text expression

github.com

21–30 of 32 posts

Re: Show HN: Convert a number to an approximated text expression

#21

Earlier quoted context omitted.

Use automation to get human-friendly text for numbers. An example from the readme: - Q2 sales were around 1M$ When the input was $1,002,184.

I'd be amazed if a company put "around $1M" for anything that was "over $1M" !

Good point! Fixed the example to reflect realities of PR language.

Re: Show HN: Convert a number to an approximated text expression

#22
Does this exist for time numbers?

I wish Telegram used such a thing. Someone not seen for 1h59m is 'last seen an hour ago'. Even just showing the actual time would be more helpful IMO - it displays it at the top right underneath (iOS) or very near (Android) the system time anyway, I don't know why it's thought to be a good idea to remove so much information.

Re: Show HN: Convert a number to an approximated text expression

#24

If you don't want it approximate, but exact, this is still a tricky non-trivial ambiguous problem. And this problem often comes up in text normalization for NLP task (e.g. speech recognition, or text-to-speech). For Python, for English, there is the inflect library: https://pypi.org/project/inflect/

I've got it (albeit limited to 7 digit numbers) in an interview before.

Lots of fun edge cases to handle.

Re: Show HN: Convert a number to an approximated text expression

#25
post #23

This is the type of thing WASM modules would be perfect for. Theres no reason for this to have so many implementations in so many languages.

That is a frustrating aspect of open-source

In the old days you would have a binary shell tool or a dll, and then you could call it from any language. It did not matter in which language the tool was written in.

Re: Show HN: Convert a number to an approximated text expression

#26
post #5

Earlier quoted context omitted.

I also wrote a function in Pascal to convert integers to natural language exactly. E.g. here is the output for 100000! https://gist.github.com/benibela/f0163b02562f647e4d2f

Isn't "one hundred thousand factorial" a more useful conversion? Would your conversion ever find utility? Aside, this is why French style punctuation with a space before ? or ! is superior.

I did not write it to be useful. I just wanted to say it can handle large integers.

I am implementing the XPath standard. The standard says there need to be a function to convert integers to English, but it does not specify an upper limit on the integers

Re: Show HN: Convert a number to an approximated text expression

#27

Earlier quoted context omitted.

Isn't "one hundred thousand factorial" a more useful conversion? Would your conversion ever find utility? Aside, this is why French style punctuation with a space before ? or ! is superior.

I did not write it to be useful. I just wanted to say it can handle large integers. I am implementing the XPath standard. The standard says there need to be a function to convert integers to English, but it does not specify an upper limit on the integers

Cool, IMO that makes it potentially useful (but being useful isn't required of course).

Out of curiosity, what part of the spec does that implement? Is it to do with fn:format-integer.

Re: Show HN: Convert a number to an approximated text expression

#28
post #22

Does this exist for time numbers? I wish Telegram used such a thing. Someone not seen for 1h59m is 'last seen an hour ago'. Even just showing the actual time would be more helpful IMO - it displays it at the top right underneath (iOS) or very near (Android) the system time anyway, I don't know why it's thought to be a good idea to remove so much information.

[deleted]

Re: Show HN: Convert a number to an approximated text expression

#29

Earlier quoted context omitted.

I did not write it to be useful. I just wanted to say it can handle large integers. I am implementing the XPath standard. The standard says there need to be a function to convert integers to English, but it does not specify an upper limit on the integers

Cool, IMO that makes it potentially useful (but being useful isn't required of course). Out of curiosity, what part of the spec does that implement? Is it to do with fn:format-integer.

Here is the function standard: https://www.w3.org/TR/xpath-functions-31/#func-format-intege...

Number formatting is really complicated

Re: Show HN: Convert a number to an approximated text expression

#30
post #22

Does this exist for time numbers? I wish Telegram used such a thing. Someone not seen for 1h59m is 'last seen an hour ago'. Even just showing the actual time would be more helpful IMO - it displays it at the top right underneath (iOS) or very near (Android) the system time anyway, I don't know why it's thought to be a good idea to remove so much information.

I always assumed their system is simply to tell you roughly whether to expect the person to be online soonish. And I would find it too invading to have exact numbers - e.g. in WhatsApp almost everyone I know disables that.
Post reply on HN