--- loncom/localize/localize/x_chef.pm 2004/07/20 23:04:38 1.1 +++ loncom/localize/localize/x_chef.pm 2004/07/20 23:12:29 1.2 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Russian Localization Lexicon # -# $Id: x_chef.pm,v 1.1 2004/07/20 23:04:38 albertel Exp $ +# $Id: x_chef.pm,v 1.2 2004/07/20 23:12:29 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -84,10 +84,8 @@ sub chefify { # March 26, 2000 # adpated from chef.l by John Hagerman -use vars qw($lexer $result); sub create_parser { use Parse::RecDescent; - use strict; $Parse::RecDescent::skip = ''; # skip nothing @@ -114,41 +112,41 @@ sub create_parser { | the | The | th | tion | u | U | v | V | w | W - | NW { $niw = 0; $i_seen = 0; $::result .= $item[1] } - | WC { $niw = 1; $::result .= $item[1] } - | /\n/ { $niw = 0; $i_seen = 0; $::result .= $item[1] } - - end_of_sentence: /[.?!]+/ /\s+/ { $niw = 0; $i_seen = 0; $::result .= $item[1] . "\nBork Bork Bork!\n" } - - Bbork: /([Bb]ork)/ ...NW { $::result .= "$1" } - an: /an/ { $niw = 1; $::result .= 'un' } - An: /An/ { $niw = 1; $::result .= 'Un' } - au: /au/ { $niw = 1; $::result .= 'oo' } - Au: /Au/ { $niw = 1; $::result .= 'Oo' } - ax: /a/ ...WC { $niw = 1; $::result .= "e" } - Ax: /A/ ...WC { $niw = 1; $::result .= "E" } - en: /en/ ...NW { $niw = 1; $::result .= "ee" } - ew: /ew/ { $niw = 1; $::result .= "oo" } - edone: /e/ ...NW { $niw = 1; $::result .= "e-a" } - ex: /e/ { $niw = 1; $::result .= "i" } - Ex: /E/ { $niw = 1; $::result .= "I" } - f: /f/ { $niw = 1; $::result .= "ff" } - ir: /ir/ { $niw = 1; $::result .= "ur" } - i: /i/ { $niw=1;$i_seen=1; $::result .= "ee" } - ow: /ow/ { $niw = 1; $::result .= "oo" } - o: /o/ { $niw = 1; $::result .= "oo" } - O: /O/ { $niw = 1; $::result .= "Oo" } - xo: /o/ { $niw = 1; $::result .= "u" } - the: /the/ { $niw = 1; $::result .= 'zee' } - The: /The/ { $niw = 1; $::result .= 'Zee' } - th: /th/ ...NW { $niw = 1; $::result .= "t" } - tion: /tion/ { $niw = 1; $::result .= "shun" } - u: /u/ { $niw = 1; $::result .= "oo" } - U: /U/ { $niw = 1; $::result .= "Oo" } - v: /v/ { $niw = 1; $::result .= 'f' } - V: /V/ { $niw = 1; $::result .= 'F' } - w: /w/ { $niw = 1; $::result .= 'v' } - W: /W/ { $niw = 1; $::result .= 'V' } + | NW { $niw = 0; $i_seen = 0; $Apache::localize::x_chef::result .= $item[1] } + | WC { $niw = 1; $Apache::localize::x_chef::result .= $item[1] } + | /\n/ { $niw = 0; $i_seen = 0; $Apache::localize::x_chef::result .= $item[1] } + + end_of_sentence: /[.?!]+/ /\s+/ { $niw = 0; $i_seen = 0; $Apache::localize::x_chef::result .= $item[1] . "\nBork Bork Bork!\n" } + + Bbork: /([Bb]ork)/ ...NW { $Apache::localize::x_chef::result .= "$1" } + an: /an/ { $niw = 1; $Apache::localize::x_chef::result .= 'un' } + An: /An/ { $niw = 1; $Apache::localize::x_chef::result .= 'Un' } + au: /au/ { $niw = 1; $Apache::localize::x_chef::result .= 'oo' } + Au: /Au/ { $niw = 1; $Apache::localize::x_chef::result .= 'Oo' } + ax: /a/ ...WC { $niw = 1; $Apache::localize::x_chef::result .= "e" } + Ax: /A/ ...WC { $niw = 1; $Apache::localize::x_chef::result .= "E" } + en: /en/ ...NW { $niw = 1; $Apache::localize::x_chef::result .= "ee" } + ew: /ew/ { $niw = 1; $Apache::localize::x_chef::result .= "oo" } + edone: /e/ ...NW { $niw = 1; $Apache::localize::x_chef::result .= "e-a" } + ex: /e/ { $niw = 1; $Apache::localize::x_chef::result .= "i" } + Ex: /E/ { $niw = 1; $Apache::localize::x_chef::result .= "I" } + f: /f/ { $niw = 1; $Apache::localize::x_chef::result .= "ff" } + ir: /ir/ { $niw = 1; $Apache::localize::x_chef::result .= "ur" } + i: /i/ { $niw=1;$i_seen=1; $Apache::localize::x_chef::result .= "ee" } + ow: /ow/ { $niw = 1; $Apache::localize::x_chef::result .= "oo" } + o: /o/ { $niw = 1; $Apache::localize::x_chef::result .= "oo" } + O: /O/ { $niw = 1; $Apache::localize::x_chef::result .= "Oo" } + xo: /o/ { $niw = 1; $Apache::localize::x_chef::result .= "u" } + the: /the/ { $niw = 1; $Apache::localize::x_chef::result .= 'zee' } + The: /The/ { $niw = 1; $Apache::localize::x_chef::result .= 'Zee' } + th: /th/ ...NW { $niw = 1; $Apache::localize::x_chef::result .= "t" } + tion: /tion/ { $niw = 1; $Apache::localize::x_chef::result .= "shun" } + u: /u/ { $niw = 1; $Apache::localize::x_chef::result .= "oo" } + U: /U/ { $niw = 1; $Apache::localize::x_chef::result .= "Oo" } + v: /v/ { $niw = 1; $Apache::localize::x_chef::result .= 'f' } + V: /V/ { $niw = 1; $Apache::localize::x_chef::result .= 'F' } + w: /w/ { $niw = 1; $Apache::localize::x_chef::result .= 'v' } + W: /W/ { $niw = 1; $Apache::localize::x_chef::result .= 'V' } WC: /[A-Za-z']/ NW: /[^A-Za-z']/ @@ -158,10 +156,12 @@ sub create_parser { sub chefify2 { my ($str) = @_; - $::result=''; + my $backup=$str; + $Apache::localize::x_chef::result=''; if (!defined($lexer)) { &create_parser(); } $lexer->chef(\$str); - return $::result; + $Lexicon{$backup}=$Apache::localize::x_chef::result; + return $Apache::localize::x_chef::result; } 1;