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