[ANN] inflect.py: generate plurals, ordinals, numbers to words...

MRAB python at mrabarnett.plus.com
Fri Jul 16 12:15:19 EDT 2010


Paul wrote:
 >> Thomas Jollans, 15.07.2010 18:41:
 >
 >>> On 07/15/2010 01:00 PM, Paul wrote:
 >>>> I'm pleased to announce the release of inflect.py v0.1.8, a module
 >>>> that correctly generates:
 >
 >>>> * the plural of singular nouns and verbs
 >>>> * the singular of plural nouns
 >>>> * ordinals
 >>>> * indefinite articles
 >>>> * present participles
 >>>> * and converts numbers to words
 >
 >>> Which languages does it support? If the answer is what I expect it
 >>> is,
 >
 >> It is. Most of the time, when people forget to say what they are
 >> talking about, assuming that they are either US-Americans or Windows
 >> users will hit the nail on the head.
 >
 >> Still, a pretty nice tool, I'd say.
 >
 >>> did you design the module with multilingualism in mind?
 >
 >> Just look at the code, it consists almost exclusively of long lists
 >> of words. Multilingualism clearly wasn't a design goal.
 >
 >> Stefan
 >
 > The module is based upon a Perl module that has been around for about
 > ten years. I did a line by line translation of the Perl code into
 > Python, got that working and am now slowly redesigning the code. I am
 > currently removing many of the regular expressions, which makes the
 > code many times faster (and clearer, I think).
 >
 > The code alternates between applying rules and using lists of words.
 > The author of the original Perl code, Damian Conway, wrote an academic
 > paper on the approach taken.
 > http://www.csse.monash.edu.au/~damian/papers/HTML/Plurals.html
 >
 > A future goal is to have this work in a way that is far more pluggable
 > and so be applicable to other languages. But at the moment I'm happy
 > to have got it working.
 >
 > I'm pretty sure that if Damian was writing this from scratch today he
 > would design it differently. However, I had existing Perl code that
 > worked, so I would rather start with that, get it working in Python
 > and covered by tests. Then I can improve the design with the safety of
 > test coverage.
 >
 > The Perl version is called Lingua::EN::Inflect, so was more explicit
 > about being for English in its naming and there are other Perl
 > Lingua::XX::Inflects for other languages. But my lack of mentioning
 > English in the announcement was an oversight. Both the Perl author and
 > I are Australian, and so the modules support British English over
 > American English where necessary, with the Oxford English Dictionary
 > as our guide.
 >
Could I suggest that you also change the method names to something
clearer?



More information about the Python-list mailing list