21
2
Background
The Italian definite article (corresponding to English the) has seven different forms: l', il, lo, gli, i, la, le. Which one to use depends on three variables:
- Gender: masculine / feminine.
- Number: singular / plural.
- Initial letter of the subsequent word: vowel / consonant type A / consonant type B.
- Vowel is any of these: aeiou.
- Consonant type B is any of these cases: s- followed by another consonant, z-, gn-, pn-, ps-, x-, i- followed by vowel (this i acts as a semivowel).
- Consonant type A is a consonant that is not type B.
The table shows the article form to be used in each of the twelve combinations of the three above variables. Note that the l' form is attached to the following word with a single quote and without a space.
The challenge
Input a word and one or two strings, numbers or Booleans indicating gender and number. (The initial letters will have to be obtained from the input word).
The input word will be a sequence of lowercase ASCII letters. Accented vowels will be replaced by their non-accented versions (for example, realtà will be input as realta).
The gender and number inputs can be separate numbers, Booleans or strings, or a combined number of string (for example, 1 for masculine singular, 2 for feminine singular, etc).
Any reasonable format and separator can be used, as long as it is specified in the answer.
Output the word preceded by the appropriate form of the article, with space or single quote as needed. The output should also be lowercase. Trailing or leading blank space is allowed.
Code golf, shortest wins.
Test cases
In the following I use the input letters m
, f
to specify gender, and s
, p
for number (this is just one possible input format).
Input Output Comment
macchina f s la macchina Initial letter is cons. A
zio m s lo zio Initial letter is cons. B
libri m p i libri Initial letter is cons. A
ieri m s lo ieri Initial letter is cons. B
aquile f p le aquile Initial letter is vowel
spagnoli m p gli spagnoli Initial letter is cons. B
golf m s il golf Initial letter is cons. A
ombra f s l'ombra Initial letter is vowel
impossibili m p gli impossibili Initial letter is vowel
You may want to also make a challenge on the coniugation of regular verbs. – user6245072 – 2016-07-16T09:31:37.427
@user6245072 Well, there's already this... the difference would probably be too small
– Luis Mendo – 2016-07-16T09:49:17.5371A minor technical niggle: /j/ is normally called a semivowel in English, not a semiconsonant. I wonder what the solutions would be if they were to factor in edge cases like ⟨ch⟩ representing [ʃ] rather than [k] (lo chef, lo chardonnay), the variation with French names (l’Havet but lo Hugo), fossilised forms (gli dei, per lo meno), women referred to by their last name (l’Antonia but la Antonini), etc. That would be quite the formidable thing to golf-code. – Janus Bahs Jacquet – 2016-07-16T19:56:54.513
@JanusBahsJacquet Oh, I thought it was called semiconsonant also in English (as in Spanish) when it appears in the beginning of a syllable. I've corrected it. I had no idea about gli dei or per lo meno. Thanks for the information! – Luis Mendo – 2016-07-17T02:45:11.600
1As Italian I ask you to take off
ieri
test case because is an adverb and not a noun! (BTW it was formally correct) Please! – Giacomo Garabello – 2016-07-18T14:40:26.050@GiacomoGarabello I know it's an adverb, but it's also used as a noun, isn't it?, as it is in English and in Spanish. Anyway, if you think it's too streched, can you suggest a noun that starts with semiconsonant "i-"?
– Luis Mendo – 2016-07-18T14:57:17.677In 21 years of life in Italy I never seen Ieri used as a noun, but i know it's formally correct! In only sounds awful in my head... And then, It's a Code-Golf! If we don't need a clean code, we also don't need a clean language, if it works! – Giacomo Garabello – 2016-07-18T15:23:50.720
@GiacomoGarabello So can't you say something like "Non pensare allo ieri, pensa allo domani" (non-native here) – Luis Mendo – 2016-07-18T15:25:38.470
1We usally say: "Non pensare a ieri, Pensa a Domani" – Giacomo Garabello – 2016-07-18T15:27:30.957
@GiacomoGarabello Anyway, isn't ieri and domani nouns there? :-) – Luis Mendo – 2016-07-18T15:28:08.373
@GiacomoGarabello Thanks for the idea anyway. I think I'll leave "ieri" because quite a few answers are using it as a test case – Luis Mendo – 2016-07-18T15:38:35.767
Good Check! But in special cases like this one we don't use the Articles! We use the preposition. Before I've mispelled...
I never seen Ieri used as a noun
had to be I never seen Ieri used as a noun with a defined Article (My awful English didn't help me explaining italian grammar :-P ) I cant think about a phrase with lo Ieri in the Italian common language :-D – Giacomo Garabello – 2016-07-18T15:38:53.017@GiacomoGarabello Got it. Thanks for the tip! E spero che possiamo parlare (scrivere) in italiano alcuna volta se visiterai lo chat :-) – Luis Mendo – 2016-07-18T15:42:39.210
Of course you can keep it, It's Correct! My only word about that it's uncommon and we don't use it that much (and it's sound is awful)! P.S.: Se vuoi Imparare l'italiano spero di poterti essere di aiuto! – Giacomo Garabello – 2016-07-18T15:43:41.940