On Feb 1, 10:00 am, [EMAIL PROTECTED] (Rob Dixon) wrote:
> axtenswrote:
> > G'day everyone
Thanks for that. I did, however, give up on using TwoWay and used an
idea a colleague had given me, as below:
sub Misspellings_Setup {
@wordsList = split /\n/, <<'__WORDLIST__'
abandonned abandoned
aberation aberration
abilities abilties
.
.
.
__WORDLIST__
;
foreach (@wordsList) {
($left, $right) = split /\t/, $_;
@leftList = split /,\s* /, $left;
@rightList = split /,\s*/, $right;
foreach $l (@leftList) {
foreach $r (@rightList) {
if ( exists $misDict{"!-$l"} ) { $misDict{"!-$l"} .= $r . "^"; }
else { $misDict{"!-$l"} = $r . "^"; }
if ( exists $misDict{"?-$r"} ) { $misDict{"?-$r"} .= $l . "^"; }
else { $misDict{"?-$r"} = $l . "^"; }
}
}
}
}
misDict is an "our" declared elswhere. Getting something out of the
hash is as below.
sub Misspellings_Suggest {
#receives string
#returns string
my $res;
my $string = shift;
if ( ! %misDict ) {
Misspellings_Setup();
}
if ( exists( $misDict{"!-$string"} ) ) {
$res = $misDict{"!-$string"};
} else {
$res = $string;
}
$res =~ s/\^/FS/ge;
return $res;
}
Kind regards,
Bruce.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/