1 | #!/usr/bin/env python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | # Plural-Forms for fr (French)) |
---|
4 | |
---|
5 | nplurals=2 # French language has 2 forms: |
---|
6 | # 1 singular and 1 plural |
---|
7 | |
---|
8 | # Determine plural_id for number *n* as sequence of positive |
---|
9 | # integers: 0,1,... |
---|
10 | # NOTE! For singular form ALWAYS return plural_id = 0 |
---|
11 | get_plural_id = lambda n: int(n != 1) |
---|
12 | |
---|
13 | # Construct and return plural form of *word* using |
---|
14 | # *plural_id* (which ALWAYS>0). This function will be executed |
---|
15 | # for words (or phrases) not found in plural_dict dictionary |
---|
16 | # construct_plural_form = lambda word, plural_id: (word + 'suffix') |
---|
17 | |
---|
18 | irregular={ |
---|
19 | 'aïeul': 'aïeux', |
---|
20 | 'bonhomme': 'bonshommes', |
---|
21 | 'ciel': 'cieux', |
---|
22 | 'oeil': 'yeux', |
---|
23 | 'œil': 'yeux', |
---|
24 | 'madame': 'mesdames', |
---|
25 | 'mademoiselle': 'mesdemoiselles', |
---|
26 | 'monsieur': 'messieurs', |
---|
27 | 'bijou': 'bijoux', |
---|
28 | 'caillou': 'cailloux', |
---|
29 | 'chou': 'choux', |
---|
30 | 'genou': 'genoux', |
---|
31 | 'hibou': 'hiboux', |
---|
32 | 'joujou': 'joujoux', |
---|
33 | 'pou': 'poux', |
---|
34 | 'corail': ' coraux', |
---|
35 | 'émail': 'émaux', |
---|
36 | 'travail': 'travaux', |
---|
37 | 'vitrail': 'vitraux', |
---|
38 | 'soupirail': 'soupiraux', |
---|
39 | 'bail': 'baux', |
---|
40 | 'fermail': 'fermaux', |
---|
41 | 'ventail': 'ventaux', |
---|
42 | 'bleu': 'bleus', |
---|
43 | 'pneu': 'pneus', |
---|
44 | 'émeu': 'émeus', |
---|
45 | 'enfeu': 'enfeus', |
---|
46 | #'lieu': 'lieus', # poisson |
---|
47 | |
---|
48 | } |
---|
49 | |
---|
50 | def construct_plural_form(word, plural_id): |
---|
51 | u""" |
---|
52 | >>> [construct_plural_form(x, 1) for x in \ |
---|
53 | [ 'bleu', 'nez', 'sex', 'bas', 'gruau', 'jeu', 'journal',\ |
---|
54 | 'chose' ]] |
---|
55 | ['bleus', 'nez', 'sex', 'bas', 'gruaux', 'jeux', 'journaux', 'choses'] |
---|
56 | """ |
---|
57 | if word in irregular: |
---|
58 | return irregular[word] |
---|
59 | if word[-1:] in ('s', 'x', 'z'): |
---|
60 | return word |
---|
61 | if word[-2:] in ('au', 'eu'): |
---|
62 | return word + 'x' |
---|
63 | if word[-2:] == 'al': |
---|
64 | return word[0:-2] + 'aux' |
---|
65 | return word + 's' |
---|
66 | |
---|
67 | if __name__ == '__main__': |
---|
68 | import doctest |
---|
69 | doctest.testmod() |
---|