Perl Advent Calendar 2008-12-04

Mais si, Virginie, le Père Noël existe

by Jerrad Pierce

For all its magic, Père Noël's sack is just a big velvet bag, and sometimes things get a little mixed up. On top of that, with the variety of toys that exist today—gone are the days of dollies or pop guns—he can't always figure out what's what. Therefore, he keeps a little app on his PDA to check that a toy is culturally appropriate; children may play with identical toys around the world, but the packaging and directions can vary. A simplified version of this tool, featuring Lingua::Ident, is shown below.

Hyper Blocs Colorés => fr.iso-8859-1
Mega Color Blox => en.iso-8859-1
Elmo => en.iso-8859-1
Monsieur Patate => fr.iso-8859-1

More probable uses of this module include spam filtering, or even sorting texts into different forms or dialects e.g; Middle English, slang, legalese, academic; as a substitute legibility indicator.

   1 use Lingua::Ident;
   3 #Load sample tables from module
   4 $i = new Lingua::Ident(qw(data.en;
   6 #What's what?
   7 printf("$_ => %s\n", $i->identify($_)) while( chomp($_=<DATA>) );
   9 __DATA__
  10 Hyper Blocs Colorés
  11 Mega Color Blox
  12 Elmo
  13 Monsieur Patate

Published 2008-12-13

View Source (POD)