Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 1.12 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #! /usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4.  
  5.  
  6. ail = 'bail corail émail fermail soupirail travail vantail vitrail'.split()
  7. al = 'final cheval journal tropical canal'.split()
  8. au = 'landau sarrau'.split()
  9. eau = 'eau seau cadeau rideau beau  oiseau corbeau'.split()
  10. eu = 'pneu bleu emeu'.split()
  11. ou = 'bijou hibou chou genou caillou pou ripou '.split()
  12.  
  13. def pluriel(mot):
  14.         mot = mot.lower()                       #choix de returner les mots en minuscule
  15.         if mot[-1] is 's' : return mot         
  16.         if mot == 'ail': return 'aulx'
  17.         if mot in ail : return mot[:-2] + 'ux'
  18.         if mot in al : return mot[:-1] + 'ux'  
  19.         if mot in ou : return mot + 'x'
  20.         if mot[-1] is 'x' : return mot
  21.         if mot[-1] is 'z' : return mot
  22.         if mot in eu : return mot + 's'
  23.         if mot in au : return mot + 's'
  24.         if mot in eau : return mot + 'x'
  25.         if mot == 'oeil' : return 'yeux'
  26.         if mot == 'ciel' : return 'cieux'
  27.         if mot == 'au' : return 'aux'  
  28.         return mot + 's'
  29.  
  30. import sys
  31.  
  32. if len (sys.argv) > 1 :
  33.         for x in range(1, len(sys.argv)):
  34.                 m =  pluriel(sys.argv[x])
  35.                 print m,  #la virgule affiche un espace au lieu du saut de ligne
  36. else : exit('argument manquant : mot')