OSDN Git Service

initial version. 0.0.1
authorTaku Amano <taku@toi-planning.net>
Fri, 20 Feb 2009 01:23:00 +0000 (10:23 +0900)
committerTaku Amano <taku@toi-planning.net>
Fri, 20 Feb 2009 01:23:00 +0000 (10:23 +0900)
14 files changed:
.gitattributes [new file with mode: 0644]
Build.PL [new file with mode: 0644]
LICENSE [new file with mode: 0644]
MANIFEST [new file with mode: 0644]
MANIFEST.SKIP [new file with mode: 0644]
config.yaml [new file with mode: 0644]
extlib/Acme/Lou.pm [new file with mode: 0644]
extlib/Acme/Lou/Effect.pm [new file with mode: 0644]
extlib/Acme/Lou/lou-ja2kana.db [new file with mode: 0644]
lib/Lou.pm [new file with mode: 0644]
lib/Lou/L10N.pm [new file with mode: 0644]
lib/Lou/L10N/en_us.pm [new file with mode: 0644]
lib/Lou/L10N/ja.pm [new file with mode: 0644]
tmpl/system_config.tmpl [new file with mode: 0644]

diff --git a/.gitattributes b/.gitattributes
new file mode 100644 (file)
index 0000000..bf17ac3
--- /dev/null
@@ -0,0 +1,4 @@
+*.pm       ident
+*.html       ident
+*.tmpl       ident
+*.yaml       ident
diff --git a/Build.PL b/Build.PL
new file mode 100644 (file)
index 0000000..cad1022
--- /dev/null
+++ b/Build.PL
@@ -0,0 +1,119 @@
+use strict;
+use warnings;
+use Module::Build;
+use File::Spec;
+use File::Basename;
+use YAML qw/ Load /;
+
+my $class = Module::Build->subclass(
+       class => 'MTToiplanPluginDirectoryBuilder',
+       code => q{
+               # Don't make blib
+               # sub ACTION_code {};
+               # Don't make blib
+               sub ACTION_docs {};
+               # Don't make META.yml
+               sub ACTION_distmeta {
+                       # no warning on ACTION_distdir
+                       $_[0]->{metafile} = 'MANIFEST';
+               };
+               # Don't add MEATA.yml to MANIFEST
+               sub ACTION_manifest {
+                       $_[0]->{metafile} = 'MANIFEST',
+                       $_[0]->SUPER::ACTION_manifest(@_);
+               };
+               sub ACTION_test {
+                       my $p = $_[0]->{properties};
+                       unshift(
+                               @INC,
+                               File::Spec->catdir($p->{base_dir}, 'extlib'),
+                               File::Spec->catdir($p->{base_dir}, '../../lib'),
+                               File::Spec->catdir($p->{base_dir}, '../../extlib'),
+                       );
+
+                       $_[0]->SUPER::ACTION_test(@_);
+               };
+               sub ACTION_upload_google {
+                       my ($self) = @_;
+                       my $prj = 'toiplan-mtplugin-directory';
+                       my $ver = $self->dist_version;
+                       my $dist_dir = $self->dist_dir;
+                       my $name = $self->dist_name;
+
+                       $self->depends_on('dist');
+                       #$self->_call_action('distdir');
+                       $self->ACTION_distdir;
+                       $self->depends_on('zipdist');
+                       system(
+                               "googlecode_upload.py -s 'Release $ver (TGZ)' -p $prj -l $name $dist_dir.tar.gz"
+                       );
+                       system(
+                               "googlecode_upload.py -s 'Release $ver (ZIP)' -p $prj -l $name $dist_dir.zip"
+                       );
+                       unlink("$dist_dir.tar.gz");
+                       unlink("$dist_dir.zip");
+               };
+
+               sub ACTION_zipdist {
+                       my ($self) = @_;
+                       my $dist_dir = $self->dist_dir;
+                       $self->depends_on('distdir');
+                       print "Creating $dist_dir.zip\n";
+                       system("zip -r $dist_dir.zip $dist_dir") == 0 or die $?;
+                       $self->delete_filetree($dist_dir);
+               }
+
+               sub ACTION_distdir {
+                       my ($self) = @_;
+
+                       $_[0]->SUPER::ACTION_distdir(@_);
+
+                       my $dist_dir = $self->dist_dir;
+                       rename($dist_dir, $self->{properties}{dist_name});
+                       use File::Path;
+                       use File::Spec;
+                       use File::Basename;
+                       my $plugins = File::Spec->catfile($dist_dir, 'plugins');
+                       mkpath($plugins, 1, 0755);
+
+                       my $static = File::Spec->catfile($dist_dir, 'mt-static/plugins');
+                       mkpath($static, 1, 0755);
+
+                       my $new_dist_dir = File::Spec->catfile(
+                               $plugins, $self->{properties}{dist_name}
+                       );
+                       rename($self->{properties}{dist_name}, $new_dist_dir);
+
+                       foreach my $f (glob(File::Spec->catfile($new_dist_dir, 'LIC*'))) {
+                               rename($f, File::Spec->catfile($dist_dir, basename($f)));
+                       }
+
+                       if (my @statics = glob(File::Spec->catfile($new_dist_dir, 'static/*'))) {
+                               my $d = File::Spec->catfile($static, $self->{properties}{dist_name});
+                               mkpath($d, 1, 0755);
+                               foreach my $f (@statics) {
+                                       rename($f, File::Spec->catfile($d, basename($f)));
+                               }
+                       }
+               }
+       }
+);
+
+my $yaml_string = do {
+       open(my $fh, File::Spec->catfile(dirname(__FILE__), 'config.yaml'));
+       local $/;
+       <$fh>
+};
+$yaml_string =~ s/^(\s*)\*/$1App::\*/gm;
+my $yaml = Load($yaml_string);
+
+my $builder = $class->new(
+       dist_name           => $yaml->{name},
+    dist_author         => 'Movable Type ACME Plugin Project',
+    dist_version        => $yaml->{version},
+    module_name         => $yaml->{name} . '::App',
+    license             => 'MIT License',
+    add_to_cleanup      => [ $yaml->{name} . '-*' ],
+);
+
+$builder->create_build_script();
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..077f97b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,26 @@
+Lou - Wrapper module of Acme::Lou
+
+Copyright (c) 2008 Movable Type ACME Plugin Project, All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+
+Except for 'extlib/Acme/Lou.pm', and files below 'extlib/Acme/Lou/'.
+These files are licensed under the which own license.
+http://search.cpan.org/~tomita/Acme-Lou-0.03/
diff --git a/MANIFEST b/MANIFEST
new file mode 100644 (file)
index 0000000..5bbdad8
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,10 @@
+config.yaml
+extlib/Acme/Lou.pm
+extlib/Acme/Lou/Effect.pm
+extlib/Acme/Lou/lou-ja2kana.db
+lib/Lou.pm
+lib/Lou/L10N.pm
+lib/Lou/L10N/en_us.pm
+lib/Lou/L10N/ja.pm
+LICENSE
+tmpl/system_config.tmpl
diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP
new file mode 100644 (file)
index 0000000..ec6d23b
--- /dev/null
@@ -0,0 +1,48 @@
+^MANIFEST
+\bBuild.PL$
+#^Makefile
+#^META.yml$
+#^blib/
+#~$
+
+
+# Avoid version control files.
+\bRCS\b
+\bCVS\b
+,v$
+\B\.svn\b
+\B\.cvsignore$
+\B.git
+
+# Avoid Makemaker generated and utility files.
+\bMakefile$
+\bblib
+\bMakeMaker-\d
+\bpm_to_blib$
+\bblibdirs$
+^MANIFEST\.SKIP$
+
+# Avoid Module::Build generated and utility files.
+\bBuild$
+\bBuild.bat$
+\b_build
+
+# Avoid Devel::Cover generated files
+\bcover_db
+
+# Avoid temp and backup files.
+~$
+\.tmp$
+\.old$
+\.bak$
+\#$
+\.#
+\.rej$
+
+# Avoid OS-specific files/dirs
+#   Mac OSX metadata
+\B\.DS_Store
+#   Mac OSX SMB mount metadata files
+\B\._
+# Avoid archives of this distribution
+\bArchiveUploader-[\d\.\_]+
diff --git a/config.yaml b/config.yaml
new file mode 100644 (file)
index 0000000..dad838c
--- /dev/null
@@ -0,0 +1,45 @@
+# Copyright (c) 2008 Movable Type ACME Plugin Project, All rights reserved.
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+# plugin name
+name: Lou
+version: 0.0.1
+
+# about this plugin
+description: <__trans phrase="Wrapper module of Acme::Lou">
+author_name: <__trans phrase="Movable Type ACME Plugin Project">
+author_link: http://mt-acme.sourceforge.jp/
+plugin_link: http://mt-acme.sourceforge.jp/lou/
+doc_link: http://mt-acme.sourceforge.jp/lou/
+
+#Localization
+l10n_class: Lou::L10N
+
+system_config_template: system_config.tmpl
+settings:
+    mecab_charset:
+        Default: utf-8
+
+#tag
+tags:
+    help_url: http://mt-acme.sourceforge.jp/lou/tags#%t
+    modifier:
+        lou:
+            handler: Lou::_fltr_translate
diff --git a/extlib/Acme/Lou.pm b/extlib/Acme/Lou.pm
new file mode 100644 (file)
index 0000000..e64901e
--- /dev/null
@@ -0,0 +1,411 @@
+package Acme::Lou;
+use strict;
+our $VERSION = '0.03';
+
+use utf8;
+use Acme::Lou::Effect;
+use Carp;
+use DB_File;
+use Encode;
+use HTML::Parser;
+use Text::MeCab;
+
+sub new {
+    my $class = shift;
+    my $opt   = ref $_[0] eq 'HASH' ? shift : { @_ };
+    
+    my %self = (
+        mecab_charset => 'euc-jp',
+        mecab_option  => {},
+        dbpath => do {
+            my $file = $INC{ join '/', split '::', "$class.pm" };    
+            $file =~ s{\.pm$}{/lou-ja2kana.db};
+            $file;
+        },
+        format       => '%s',
+        is_html      => 0,
+        lou_rate     => 100,
+        html_fx_rate => 0,
+        %$opt,
+    );
+    
+    $self{dic} ||= do {
+        tie(my %db, 'DB_File', $self{dbpath}, O_RDONLY) 
+          or croak "Can't open $self{dbpath}: $!";
+        \%db;
+    };
+    
+    $self{mecab} ||= new Text::MeCab($self{mecab_option});
+     
+    bless \%self, $class;
+}
+
+sub mecab {
+    shift->{mecab};
+}
+
+sub dic {
+    my ($self, $word) = @_;
+    utf8::encode($word) if utf8::is_utf8($word);
+    decode('utf8', $self->{dic}->{$word} || "");
+}
+
+sub translate {
+    my ($self, $text, $opt) = @_;
+    return "" unless $text;
+    utf8::decode($text) unless utf8::is_utf8($text);
+    
+    $opt = {
+        format       => $self->{format},
+        is_html      => $self->{is_html},
+        lou_rate     => $self->{lou_rate},
+        html_fx_rate => $self->{html_fx_rate},
+        %{ $opt || {} },
+    };
+
+    if (!$opt->{lou_rate}) {
+        return $text;
+    } elsif ($opt->{is_html} || $opt->{html_fx_rate}) {
+        return $self->html_parse($text, $opt);
+    } else {
+        return $self->lou($text, $opt);
+    }
+}
+
+our %cform = (
+    '名詞-*' => '',
+    '感動詞-*' => '',
+    '接続詞-*' => '',
+    '連体詞-*' => '',
+    '動詞-仮定形' => 'すれ',
+    '動詞-仮定縮約1' => 'すれ',
+    '動詞-基本形' => 'する',
+    '動詞-体言接続' => 'する',
+    '動詞-体言接続特殊2' => 'す',
+    '動詞-文語基本形' => 'する',
+    '動詞-未然レル接続' => 'せ',
+   #'動詞-未然形' => '',
+   #'動詞-未然特殊'
+    '動詞-命令e' => '',     
+    '動詞-命令ro' => '',     
+    '動詞-命令yo' => '',     
+   #'動詞-連用タ接続' => '',
+    '形容詞-ガル接続' => '',
+    '動詞-連用形' => 'し',
+    '形容詞-仮定形' => 'なら',
+    '形容詞-仮定縮約1' => 'なら',
+    '形容詞-仮定縮約2' => 'なら',
+    '形容詞-基本形' => 'な',
+    '形容詞-体言接続' => 'な',
+    '形容詞-文語基本形' => '',
+    '形容詞-未然ウ接続' => 'だろ',
+    '形容詞-未然ヌ接続' => 'らしから',
+    '形容詞-命令e' => 'であれ',
+    '形容詞-連用ゴザイ接続' => '',
+    '形容詞-連用タ接続' => 'だっ',
+    '形容詞-連用テ接続' => 'っぽく',
+);
+
+sub lou {
+    my ($self, $text, $opt) = @_;
+
+    # tricks for mecab... Umm.. Do you have any good idea ?
+    $text =~ s/\r?\n/\r/g; # need \r
+    $text =~ s/ /\x{25a1}/g; # white space to "tofu"
+    
+    $text = encode($self->{mecab_charset}, $text);
+    my @out;
+    my $node = $self->mecab->parse($text);
+    while ($node = $node->next) {
+        
+        my $n = $self->decode_node($node); 
+        $n->{to} = $self->dic($n->{original});
+        $n->{class_type} = "$n->{class}-$n->{type}"; 
+        $n->{cform} = $cform{ $n->{class_type} }; 
+        
+        if ($n->{to} =~ s/\s//g >= 2) {
+            $n->{to} = "" if int(rand 3); # idiom in over 3 words.
+        }
+        if ($n->{class} =~ /接続詞|感動詞/) { # only "But" "Yes",... 
+            $n->{to} = "" if $n->{to} !~ /^[a-z]+$/i;
+        }
+        
+        if ($n->{to} && defined $n->{cform} && 
+            length $n->{original} > 1 &&
+            int(rand 100) < $opt->{lou_rate} 
+        ) {
+            if ($n->{prev}{class} eq '接頭詞' && 
+                $n->{prev}{original} =~ /^[ごお御]$/) {
+                pop @out;
+            }
+            if ($n->{class_type} eq '形容詞-基本形' && 
+                $n->{next}{class} =~ /助詞|記号/) {
+                $n->{cform} = "";
+            }
+            
+            $n->{to} = Acme::Lou::Effect::html_fx($n->{to})
+                if int(rand 100) < $opt->{html_fx_rate};
+            $n->{to} .= $n->{cform};
+
+            push @out, sprintf($opt->{format}, $n->{to}, $n->{surface});
+        } else {
+            push @out, $n->{surface};
+        }
+    }
+    $text = join "", @out;
+    $text =~ s/\r/\n/g;
+    $text =~ s/\x{25a1}/ /g;
+    $text;
+}
+
+sub decode_node {
+    my ($self, $node) = @_;
+    my $charset = $self->{mecab_charset};
+    
+    my $getf = sub {
+        my $csv = shift;
+        my %f; 
+        @f{qw( class class2 class3 class4 form type original yomi pron )} 
+            = split ",", $csv;
+        return \%f;
+    };
+     
+    my $n = $getf->(decode($charset, $node->feature));
+    $n->{surface} = decode($charset, $node->surface);
+    $n->{surface} = "" if !defined $n->{surface};
+    
+    for (qw( prev next )) {
+        next unless $node->$_;
+        $n->{$_} =  $getf->(decode($charset, $node->$_->feature));
+        $n->{$_}{surface} = decode($charset, $node->$_->surface);
+    }
+    
+    $n; 
+}
+
+sub html_parse {
+    my ($self, $html, $opt) = @_;
+    my $return = "";
+    
+    my $p = new HTML::Parser( api_version => 3 );
+    my %in;
+    
+    $p->handler( default => reverse 
+        'text,tagname,event' => sub {
+            my ($text, $tag, $event) = @_;
+            $return .= $text;
+            $tag ||= '';
+            $in{$tag}++ if $event eq 'start';
+            $in{$tag}-- if $event eq 'end';
+        }
+    );
+    
+    $p->handler( text => reverse 
+        'text' => sub {
+            my ($text) = @_;
+            if ($in{script} || $in{style}) {
+                $return .= $text;
+                return;
+            }
+            $return .= $self->lou($text, {
+                format       => $opt->{format},
+                lou_rate     => $opt->{lou_rate},
+                html_fx_rate => $in{title} ? 0 : $opt->{html_fx_rate},
+            });
+        }
+    );
+     
+    chomp $html;
+    $p->parse("$html\n") or croak "Parser failed. $!";
+    $p->eof;
+     
+    $return;
+}
+
+1;
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+Acme::Lou - Let's together with Lou Ohshiba 
+
+=head1 SYNOPSIS
+
+    use utf8;
+    use Acme::Lou;
+    
+    my $lou = new Acme::Lou;
+    
+    my $text = "「美しい国、日本」";
+    print $lou->translate($text); # 「ビューティフルな国、ジャパン」
+
+    print $lou->translate($text, {
+        lou_rate     =>  50,
+        html_fx_rate => 100,
+    })
+    # 「美しい国、<FONT color=#003399>ジャパン</FONT>」
+
+=head1 DESCRIPTION
+
+Mr. Lou Ohshiba is a Japanese comedian. This module translates 
+text or HTML into his style. 
+
+=head1 METHODS
+
+=over 4
+
+=item $lou = Acme::Lou->new([ \%options ])
+
+=item $lou = Acme::Lou->new([ %options ]) 
+
+Creates an Acme::Lou object.
+
+I<%options> can take...
+
+=over 4 
+
+=item * mecab_charset 
+
+Your MeCab dictionary charset. Default is C<euc-jp>. If you compiled 
+mecab with C<utf-8>,
+
+    my $lou = new Acme::Lou( mecab_charset => 'utf-8' );
+
+=item * mecab_option
+
+Optional. Arguments for L<Text::MeCab> instance.
+
+    my $lou = new Acme::Lou({ 
+        mecab_option => { dicdir => "/path/to/yourdicdir" },
+    });
+
+=item * mecab
+
+You can set your own Text::MeCab instance, if you want. Optional. 
+
+=item * format
+
+=item * is_html 
+
+=item * lou_rate
+
+=item * html_fx_rate
+
+These are global options for C<< $lou->translate() >> (See below).
+
+Defaults are 
+
+    format       => '%s',
+    is_html      => 0,
+    lou_rate     => 100,
+    html_fx_rate => 0,
+
+=back
+
+=item $lou->translate($text [, \%options ])
+
+Return translated text in Lou Ohshiba style. C<translate()> expect 
+utf-8 byte or utf-8 flagged text, and it return utf-8 flaged text.
+
+I<%options>: (overwrite global options)
+
+=over 4
+
+=item * format 
+
+Output format string for C<sprintf>. Default is C<%s>.
+It is taken as follows. 
+
+    sprintf(C<format>, "translated word", "original word")
+
+e.g.
+    
+    Default:
+    $lou->translate("考えておく");
+    # シンクアバウトしておく
+     
+    Idea 1: <ruby> tag
+    $lou->translate("考えておく", { 
+        format => '<ruby><rb>%s</rb><rp>(</rp><rt>%s</rt><rp>)</rp></ruby>',
+    });
+    # <ruby><rb>シンクアバウトし</rb><rp>(</rp><rt>考え</rt><rp>)</rp></ruby>ておく
+     
+    Idea 2: for English study (?!)
+    $lou->translate("考えておく", { 
+        format => '%2$s[%1$s]', # require perl v5.8
+    });
+    # 考え[シンクアバウトし]ておく
+
+C<format> option was added by version 0.03.
+
+=item * is_html
+
+Optional. If $text is a HTML, you should set true. Acme::Lou makes 
+a fine job with HTML::Parser mode. Default is false. 
+
+=item * lou_rate
+
+Set percentage of translating. 100 means full translating, 
+0 means do nothing.
+
+=item * html_fx_rate
+
+Set percentage of HTML style decoration. Default is 0. 
+When C<html_fx_rate> is set, using HTML::Parser automatically.
+(don't need to set C<is_html>)
+
+=back
+
+If using HTML::Parser, C<translate()> skips the text in C<< <script> >> 
+and C<< <style> >> tag and attribute values.
+
+And, C<html_fx_rate> skips the text in C<< <title> >> tag.
+
+    my $html = <<'HTML';
+    <html>
+    <head>新年のごあいさつ</head>
+    <body>
+    <img src="foo.jpg" alt="新年" />
+    今年もよろしく
+    お願いいたします。
+    </body>
+    </html>
+    HTML
+    ;
+     
+    print $lou->translate($html, {
+        lou_rate => 100, # translate all words that Acme::Lou knows.
+        html_fx_rate => 100, # and decorate all words.
+    });
+      
+    # <html>
+    # <head>ニューイヤーのごあいさつ</head>
+    # <body>
+    # <img src="foo.jpg" alt="新年" />
+    # <FONT color=#0000ff size=5>ディスイヤー</FONT>もよろしく
+    # <FONT color=#df0029 size=6><STRONG>プリーズ</STRONG></FONT>いたします
+    # </body>
+    # </html>
+
+HTML is not broken.
+
+=back
+
+=head1 AUTHOR
+
+Naoki Tomita E<lt>tomita@cpan.orgE<gt>
+
+Special thanks to Taku Kudo
+
+=head1 LICENSE
+
+This program is released under the following license: GPL
+
+=head1 SEE ALSO
+
+L<http://e8y.net/labs/lou_trans/>, L<http://mecab.sourceforge.jp/>, 
+L<Text::MeCab>
+
+=cut
diff --git a/extlib/Acme/Lou/Effect.pm b/extlib/Acme/Lou/Effect.pm
new file mode 100644 (file)
index 0000000..f1012af
--- /dev/null
@@ -0,0 +1,93 @@
+package Acme::Lou::Effect;
+use strict;
+use utf8;
+
+our @html_style = (
+'<FONT color=#000000 size=4>%s</FONT>',
+'<FONT color=#000000>%s</FONT>',
+'<FONT color=#0000cc size=5>%s</FONT>',
+'<FONT color=#0000cc size=7>%s</FONT>',
+'<FONT color=#0000cc>%s</FONT>',
+'<FONT color=#0000ff size=4>%s</FONT>',
+'<FONT color=#0000ff size=5><STRONG>%s</STRONG></FONT>',
+'<FONT color=#0000ff>%s</FONT>',
+'<FONT color=#0000ff><STRONG>%s</STRONG></FONT>',
+'<FONT color=#003399 size=5>%s</FONT>',
+'<FONT color=#003399>%s</FONT>',
+'<FONT color=#00683e size=4><STRONG>%s</STRONG></FONT>',
+'<FONT color=#00683e size=5>%s</FONT>',
+'<FONT color=#00683e>%s</FONT>',
+'<FONT color=#00683e><STRONG>%s</STRONG></FONT>',
+'<FONT color=#009f62 size=5>%s</FONT>',
+'<FONT color=#009f62><STRONG>%s</STRONG></FONT>',
+'<FONT color=#4352c2 size=6>%s</FONT>',
+'<FONT color=#4352c2>%s</FONT>',
+'<FONT color=#666666 size=5>%s</FONT>',
+'<FONT color=#666666>%s</FONT>',
+'<FONT color=#6a4f9a>%s</FONT>',
+'<FONT color=#800080 size=5>%s</FONT>',
+'<FONT color=#800080>%s</FONT>',
+'<FONT color=#92007b size=4>%s</FONT>',
+'<FONT color=#92007b size=5>%s</FONT>',
+'<FONT color=#92007b size=6>%s</FONT>',
+'<FONT color=#92007b>%s</FONT>',
+'<FONT color=#92007b><STRONG>%s</STRONG></FONT>',
+'<FONT color=#990033 size=5>%s</FONT>',
+'<FONT color=#df0029 size=4>%s</FONT>',
+'<FONT color=#df0029 size=4><STRONG>%s</STRONG></FONT>',
+'<FONT color=#df0029 size=5>%s</FONT>',
+'<FONT color=#df0029 size=5><EM>%s</EM></FONT>',
+'<FONT color=#df0029 size=6>%s</FONT>',
+'<FONT color=#df0029 size=7>%s</FONT>',
+'<FONT color=#df0029>%s</FONT>',
+'<FONT color=#df0029><STRONG>%s</STRONG></FONT>',
+'<FONT color=#e2007f size=4>%s</FONT>',
+'<FONT color=#e2007f size=4><STRONG>%s</STRONG></FONT>',
+'<FONT color=#e2007f size=5>%s</FONT>',
+'<FONT color=#e2007f size=6>%s</FONT>',
+'<FONT color=#e2007f size=6><EM>%s</EM></FONT>',
+'<FONT color=#e2007f>%s</FONT>',
+'<FONT color=#e2007f><STRONG>%s</STRONG></FONT>',
+'<FONT color=#e69c00 size=4>%s</FONT>',
+'<FONT color=#e69c00 size=5>%s</FONT>',
+'<FONT color=#e69c00>%s</FONT>',
+'<FONT color=#e7651a size=4>%s</FONT>',
+'<FONT color=#e7651a size=4><STRONG>%s</STRONG></FONT>',
+'<FONT color=#e7651a size=5>%s</FONT>',
+'<FONT color=#e7651a size=5>%s</FONT>',
+'<FONT color=#e7651a size=5><EM>%s</EM></FONT>',
+'<FONT color=#e7651a size=5><STRONG>%s</STRONG></FONT>',
+'<FONT color=#e7651a size=6>%s</FONT>',
+'<FONT color=#e7651a>%s</FONT>',
+'<FONT color=#e7651a><STRONG>%s</STRONG></FONT>',
+'<FONT face=魚石行書 color=#990033>%s</FONT>',
+'<FONT face=魚石行書 size=5>%s</FONT>',
+'<FONT face=HG正楷書体-PRO color=#00683e size=4>%s</FONT>',
+'<FONT face=HG正楷書体-PRO color=#df0029 size=5>%s</FONT>',
+'<FONT face=HG創英角ポップ体 color=#df0029 size=5>%s</FONT>',
+'<FONT face=HGP創英角ポップ体 color=#666666>%s</FONT>',
+'<FONT face=HGP創英角ポップ体 color=#0000ff size=5>%s</FONT>',
+'<FONT face=HGP創英角ポップ体 color=#92007b size=5><EM>%s</EM></FONT>',
+'<FONT face=HGP創英角ポップ体 size=5>%s</FONT>',
+'<FONT face=HGP創英角ポップ体 size=6 color=#009F62>%s</FONT>',
+'<FONT face=HGP創英角ポップ体 size=6 color=#666666>%s</FONT>',
+'<FONT face=HGP創英角ポップ体>%s</FONT>',
+'<FONT face=HGS創英角ポップ体 size=5>%s</FONT>',
+'<FONT face=HGS創英角ポップ体 color="#e2007f" size="4">%s</FONT>',
+'<FONT face=HGS創英角ポップ体>%s</FONT>',
+'<FONT size=2>%s</FONT>',
+'<FONT size=3>%s</FONT>',
+'<FONT size=4 color=#4352c2><STRONG>%s</STRONG></FONT>',
+'<FONT size=5 color=#800080>%s</FONT>',
+'<FONT size=5 color=#e2007f><EM><STRONG>%s</STRONG></EM></FONT>',
+'<FONT size=5 color=#e2007f><STRONG><EM>%s</EM></STRONG></FONT>',
+'<FONT size=6>%s</FONT>',
+'<FONT size=7>%s</FONT>',
+'<FONT style="BACKGROUND-COLOR: #bcdfff">%s</FONT>',
+);
+
+sub html_fx {
+    sprintf $html_style[ int rand @html_style ], shift || "";
+}
+
+1;
diff --git a/extlib/Acme/Lou/lou-ja2kana.db b/extlib/Acme/Lou/lou-ja2kana.db
new file mode 100644 (file)
index 0000000..83986e1
Binary files /dev/null and b/extlib/Acme/Lou/lou-ja2kana.db differ
diff --git a/lib/Lou.pm b/lib/Lou.pm
new file mode 100644 (file)
index 0000000..d3c2291
--- /dev/null
@@ -0,0 +1,53 @@
+# Copyright (c) 2008 Movable Type ACME Plugin Project, All rights reserved.
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+package Lou;
+use strict;
+
+use Acme::Lou;
+my $lou = undef;
+
+sub get_lou {
+    $lou if $lou;
+
+       my $plugin = MT->component('Lou');
+    $lou = new Acme::Lou(
+               mecab_charset =>
+        $plugin->get_config_value('mecab_charset') || 'utf-8'
+       );
+}
+
+sub _fltr_translate {
+    my ($str, $val, $ctx) = @_;
+
+       my $rate = int($val);
+       if ($rate <= 1 || $rate >= 100) {
+               $rate = 100;
+       }
+
+    my $lou = &get_lou;
+    $lou->translate($str, {
+               is_html      => 1,
+               lou_rate     => $rate,
+               html_fx_rate => 100,
+    });
+}
+
+1;
diff --git a/lib/Lou/L10N.pm b/lib/Lou/L10N.pm
new file mode 100644 (file)
index 0000000..49598b5
--- /dev/null
@@ -0,0 +1,25 @@
+# Copyright (c) 2008 Movable Type ACME Plugin Project, All rights reserved.
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+package Lou::L10N;
+use strict;
+use base 'MT::Plugin::L10N';
+
+1;
diff --git a/lib/Lou/L10N/en_us.pm b/lib/Lou/L10N/en_us.pm
new file mode 100644 (file)
index 0000000..54756a3
--- /dev/null
@@ -0,0 +1,29 @@
+# Copyright (c) 2008 Movable Type ACME Plugin Project, All rights reserved.
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+package Lou::L10N::en_us;
+
+use strict;
+
+use base 'Lou::L10N';
+use vars qw( %Lexicon );
+%Lexicon = ();
+
+1;
diff --git a/lib/Lou/L10N/ja.pm b/lib/Lou/L10N/ja.pm
new file mode 100644 (file)
index 0000000..a920d37
--- /dev/null
@@ -0,0 +1,31 @@
+# Copyright (c) 2008 Movable Type ACME Plugin Project, All rights reserved.
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+package Lou::L10N::ja;
+
+use strict;
+use base 'Lou::L10N::en_us';
+use vars qw( %Lexicon );
+
+%Lexicon = (
+       'Wrapper module of Acme::Lou' => 'Acme::Lou のラッパープラグインです',
+);
+
+1;
diff --git a/tmpl/system_config.tmpl b/tmpl/system_config.tmpl
new file mode 100644 (file)
index 0000000..e20e220
--- /dev/null
@@ -0,0 +1,8 @@
+<mtapp:setting
+       id="mecab_charset"
+       label="<__trans phrase="Charactor set of MeCab">"
+>
+<ul><li>
+<input id="mecab_charset" name="mecab_charset" value="<mt:Var name="mecab_charset" />" />
+</li></ul>
+</mtapp:setting>