samples/naif_translator
raw| 1 | #!/usr/bin/perl |
| 2 | use Text::RewriteRules; |
| 3 | |
| 4 | %dict=(driver=>"motorista", |
| 5 | the=>"o", |
| 6 | of=>"de", |
| 7 | car=>"carro"); |
| 8 | |
| 9 | $word='\b\w+\b'; |
| 10 | |
| 11 | if( b(a("I see the Driver of the car")) eq "(I) (see) o Motorista do carro" ) |
| 12 | {print "ok\n"} |
| 13 | else {print "ko\n"} |
| 14 | |
| 15 | RULES/m a |
| 16 | ($word)==>$dict{$1}!! defined($dict{$1}) |
| 17 | ($word)=e=> ucfirst($dict{lc($1)}) !! defined($dict{lc($1)}) |
| 18 | ($word)==>($1) |
| 19 | ENDRULES |
| 20 | |
| 21 | RULES/m b |
| 22 | \bde o\b==>do |
| 23 | ENDRULES |