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.
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.
In the following I use the input letters
f to specify gender, and
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