Changeset 4339

Show
Ignore:
Timestamp:
01/10/08 11:38:13 (5 years ago)
Author:
daisuke
Message:

lang/perl/Text-MeCab?; more small fixes, docs

Location:
lang/perl/Text-MeCab/trunk/lib/Text
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Text-MeCab/trunk/lib/Text/MeCab.pm

    r4253 r4339  
    270270=head2 MECAB_UNK_DIC 
    271271 
     272=head2 MECAB_CONFIG 
     273 
     274Path to mecab-config, if available. 
     275 
    272276=head1 SEE ALSO 
    273277 
  • lang/perl/Text-MeCab/trunk/lib/Text/MeCab/Dict.pm

    r4337 r4339  
    3131        $libexecdir = $args{libexecdir}; 
    3232    } else { 
    33         $libexecdir = Path::Class::Dir->new(`$config --libexecdir`); 
     33        $libexecdir = `$config --libexecdir`; 
     34        chomp $libexecdir; 
    3435    } 
    3536 
     
    3738        die "You must specify dict_source and libexecdir"; 
    3839    } 
     40    $dict_source = Path::Class::Dir->new($dict_source); 
     41    $libexecdir = Path::Class::Dir->new($libexecdir); 
    3942 
    4043    my $self  = bless { 
     
    8285 
    8386    $file = Path::Class::File->new($file); 
     87    if (! $file->is_absolute) { 
     88        $file = $self->dict_source->file( $file ); 
     89    } 
     90 
    8491    my $fh = $file->open(">>"); 
    85     $fh->print(join("\n", @output)); 
     92    $fh->print(join("\n", @output, "")); 
    8693    $fh->close; 
    8794 
     
    107114        foreach my $cmd (@cmds) { 
    108115            if (system(@$cmd) != 0) { 
    109                 die "Failed to execute '@$cmd'"; 
     116                die "Failed to execute '@$cmd': $!"; 
    110117            } 
    111118        } 
     
    152159  use Text::MeCab::Dict; 
    153160 
    154   my $dict = Text::MeCab::Dict->new(); 
     161  my $dict = Text::MeCab::Dict->new( 
     162    dict_source => "/path/to/mecab-ipadic-source" 
     163  ); 
    155164  $dict->add( 
    156165    surface      => $surface,        # 表層形 
     
    178187=head1 METHODS 
    179188 
     189=head2 new 
     190 
     191Creates a new instance of Text::MeCab::Dict.  
     192 
     193The path to the source of mecab-ipadic is required: 
     194 
     195  my $dict = Text::MeCab::Dict->new( 
     196    dict_source => "/path/to/mecab-ipadic-source" 
     197  ); 
     198 
     199If you are in an environment where mecab-config is NOT available, you must 
     200also specify libexecdir, which is where mecab-dict-index is installed: 
     201 
     202  my $dict = Text::MeCab::Dict->new( 
     203    dict_source => "/path/to/mecab-ipadic-source", 
     204    libexecdir  => "/path/to/mecab/libexec/", 
     205  ); 
     206 
     207=head2 add 
     208 
     209Adds a new entry to be appended to the dictionary. Please see SYNOPSIS for 
     210arguments. 
     211 
     212=head2 write 
     213 
     214Writes out the entries that were added via add() to the specified file 
     215location. If the file name does not look like an absolute path, the name 
     216will be treated relatively from dict_source 
     217 
    180218=head2 rebuild 
    181219