Numsense icon indicating copy to clipboard operation
Numsense copied to clipboard

Added italian language support.

Open albertodall opened this issue 9 years ago • 10 comments

I added the italian language support.

albertodall avatar Feb 21 '16 20:02 albertodall

Thank you for your interest in contributing to Numsense. Thus pull request looks promising :+1:

ploeh avatar Feb 23 '16 12:02 ploeh

It builds and runs all tests without warnings on my machine, so from a technical perspective I think we're good to go :+1:

As I don't read Italian, I'd like someone who does to review that part of it, if at all possible. I don't expect any errors, but it's always good with a second pair of eyes :smile:

ploeh avatar Feb 24 '16 06:02 ploeh

I solicited a review on Twitter: https://twitter.com/ploeh/status/702383554689417220

Please retweet and spread the word :smile:

ploeh avatar Feb 24 '16 06:02 ploeh

Couldn't spot any mistake in the unit tests. Bravo!

IvanoBilenchi avatar Feb 24 '16 08:02 IvanoBilenchi

sorry to be pedantic but I found two little issues due to nuances of the Italian grammar:

  • an accent is needed for numbers ending in 3 (except 3 itself) e.g. 23 must be written ventitré instead of ventitre. The version without accent is often used in practice (hence may be tolerated by the parser) but the italian grammar is clear: ventitré is correct, ventitre is not;
  • the other issue is when combining 100 (cento) with 80 (ottanta). The correct result should be centottanta instead of centoottanta because the two adjacent o's should be collapsed into a single one.

cheers, giacomo

giacomociti avatar Feb 24 '16 13:02 giacomociti

Hi @giacomociti I searched for some "authoritative" rules of thumb for correctly write numbers in italian, and I found only this: http://www.treccani.it/lingua_italiana/domande_e_risposte/grammatica/grammatica_258.html About collapsing the adjacent o's in "centottanta", Treccani says that both ways are correct, while I'm searching for the other rule about accent on ventitre. If you have some references, let me know. Thanks for your review, Alberto

albertodall avatar Feb 24 '16 13:02 albertodall

HI @albertodall , in fact I think the link you provided is enough to dismantle my second objection :) I think we can certainly trust Treccani about both ways being correct. For the accent on 3 I searched for a similarly authoritative source but I couldn't find none. I hope you can find something.

Ciao

giacomociti avatar Feb 24 '16 14:02 giacomociti

Since centoottanta and centottanta are both correct, Numsense now parses both as 180. Keeping "Treccani" as a reliable source, 180 is always translated as "centoottanta" (keeping the two adjacent o's). Still searching information for the final accent on ventitre.

albertodall avatar Feb 24 '16 23:02 albertodall

According to Treccani, ventitré needs to be accented (that and any other number ending with "tré", except "tre" itself, which is a monosyllable).

Source: http://www.treccani.it/enciclopedia/accento_(La_grammatica_italiana)/

IvanoBilenchi avatar Feb 25 '16 00:02 IvanoBilenchi

I should have handled the accent on "tre" if found at the end of other numbers. 3 -> "tre", 23 -> "ventitré", 23000 -> "ventitremila" The tryParse function also parses "ventitre" and "ventitre'", translating both to 23. Now, the "Treccani" rules should have been honored. :smile:

albertodall avatar Feb 29 '16 21:02 albertodall