Skip to content

Commit

Permalink
Moved old test.pl to a temporary directory
Browse files Browse the repository at this point in the history
  • Loading branch information
cosimo committed Sep 6, 2010
1 parent d0031f6 commit 4c1968c
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions old/test.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/perl -w
# first install perl-devel
# then install Text::Hunspell
#
use Text::Hunspell;
use Data::Dumper;
my $curDir;
$currDir = `pwd`;
chomp $currDir;
# print $currDir."/test.aff","\n";
my $affloc = "$currDir/t/test.aff";
my $dicloc = "$currDir/t/test.dic";
if(!(-e $affloc) || !(-e $dicloc)){
$affloc = "$currDir/test.aff";
$dicloc = "$currDir/test.dic";
}
if(!(-e $affloc) || !(-e $dicloc)){
die "test.aff or test.dic not found- dieing\n";
}
print $affloc." ".$dicloc."\n";
my $speller = Text::Hunspell->new($affloc, $dicloc);

die unless $speller;

# Set some words
my $word = "lótól";
my $word1 = "lóotól";
my $misspelled = "lóo";
my $stem = "";
# my $word = "romtól";
# my $word1 = "romnak";
# my $misspelled = "romtóol";
# my $stem = "rom";
my $stem1 = "haj";
my $count, $i;
my $res;

# check word & word1
print $speller->check( $word )
? "$word found\n"
: "$word not found!\n";
print $speller->check( $word1 )
? "$word1 found\n"
: "$word1 not found!\n";

# lookup correction for bad word
my @suggestions;
@suggestions = $speller->suggest( $misspelled );
print $misspelled.": Suggest result\n";
print Data::Dumper::Dumper( \@suggestions );

# check morphological analysis for ABL class word
@suggestions = $speller->analyze($word);
print $word.": Analyze result\n";
print Data::Dumper::Dumper( \@suggestions );

# check morphological analysis for stem class word
@suggestions = $speller->analyze($stem);
print $stem.": Analyze result\n";
print Data::Dumper::Dumper( \@suggestions );

# Test here generator for morphological modification (NOM->ACC)
@suggestions = $speller->analyze($stem);
$count = @suggestions;
print "cnt:".$count." element count:".$#suggestions." ".$stem.": Analyze result\n";
print Data::Dumper::Dumper( \@suggestions );

# modify analyze output for required class (ACC)
for($i = 0; $i < $count; $i++){
$res = @suggestions[$i];
$res =~ s/NOM/ACC/g;
print "res:".$res."\n";
@suggestions[$i] = $res;
}
print Data::Dumper::Dumper( \@suggestions );
# generate ACC class of stem
@suggestions = $speller->generate2($stem, \@suggestions);
print "generate2 result\n";
print Data::Dumper::Dumper( \@suggestions );
# end of generator for morphological modification (NOM->ACC) test

# stem test
@suggestions = $speller->stem($word);
print $word.": Stem result\n";
print Data::Dumper::Dumper( \@suggestions );

# test generator for mrphological modification, modify $stem like $word
@suggestions = $speller->generate($stem, $word);
print $stem." ".$word.": Generate result\n";
print Data::Dumper::Dumper( \@suggestions );


$speller->delete($speller);
print "1..3\n";
print "ok\n";
print "ok\n";
print "ok\n";

0 comments on commit 4c1968c

Please sign in to comment.