Skip to content

Instantly share code, notes, and snippets.

#!/home/ben/software/install/bin/perl
use warnings;
use strict;
use lib 'lib';
use Lingua::EN::PluralToSingular 'to_singular';
my %words;
my $dic = '/home/ben/projects/pron-dic-db/spellings.txt';
open my $din, "<", $dic or die $!;
while (<$din>) {
my ($word) = split /\s+/, $_;
#!/home/ben/software/install/bin/perl
use warnings;
use strict;
use Lingua::JA::Moji ':all';
use utf8;
my $edict = '/home/ben/data/edrdg/edict2';
my @kana;
#!/home/ben/software/install/bin/perl
use warnings;
use strict;
my $edict = '/home/ben/data/edrdg/edict2';
my @lines;
binmode STDOUT, ":utf8";
open my $in, "<:encoding(EUC-JP)", $edict or die $!;
while (<$in>) {
chomp;
$lines[$.] = $_;
#!/home/ben/software/install/bin/perl
use warnings;
use strict;
use lib '/home/ben/projects/Text-Fuzzy/blib/lib';
use lib '/home/ben/projects/Text-Fuzzy/blib/arch';
use Text::Fuzzy 'fuzzy_index';
use Lingua::JA::Moji ':all';
my @kana;
use utf8;
xDSL [エックスディーエスエル] /(n) {comp} x digital subscriber line/xDSL/EntL2158180X/
エックスディエスエル /(n) {comp} xDSL/EntL2286200X/
アーティクル /(n) article/EntL1013590X/
アーテクル /(n) article/EntL2539460/
アービタ /(n) arbiter/EntL1013730X/
アビタ /(n) arbiter/EntL2433790X/
アーレフ /(n) Aleph (new name of religious group Aum Shinrikyo)/EntL2135120X/
#!/home/ben/software/install/bin/perl
use warnings;
use strict;
use Lingua::Gram;
binmode STDOUT, ":utf8";
use utf8;
my $string = "the quick brown fox jumped over the lazy dog";
my $string2 = <<EOF;
いろは
#!/home/ben/software/install/bin/perl
use warnings;
use strict;
use Text::Ngram qw/ngram_counts/;
binmode STDOUT, ":utf8";
use utf8;
my $string = "the quick brown fox jumped over the lazy dog";
my $ng3 = ngram_counts ($string);
for my $k (keys %$ng3) {
# get t-score
$tscore = $ngrams->tscore;
# list bigrams according to t-score
foreach ( sort { $$tscore{ $b } <=> $$tscore{ $a } } keys %$tscore ) {
print "$$tscore{ $_ }\t" . "$_\n";
}
#!/home/ben/software/install/bin/perl
use warnings;
use strict;
use Text::Ngrams;
use utf8;
my $string = "the quick brown fox jumped over the lazy dog";
my $ng3 = Text::Ngrams->new ();
$ng3->process_text ($string);
print $ng3->to_string ();
my $string2 = <<EOF;
use warnings;
use strict;
while (<DATA>) {
print;
}
exit;
__DATA__
This is super.
__END__
Doy is right.