Changeset 4339 for lang/perl/Text-MeCab
- Timestamp:
- 01/10/08 11:38:13 (5 years ago)
- Location:
- lang/perl/Text-MeCab/trunk/lib/Text
- Files:
-
- 2 modified
-
MeCab.pm (modified) (1 diff)
-
MeCab/Dict.pm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Text-MeCab/trunk/lib/Text/MeCab.pm
r4253 r4339 270 270 =head2 MECAB_UNK_DIC 271 271 272 =head2 MECAB_CONFIG 273 274 Path to mecab-config, if available. 275 272 276 =head1 SEE ALSO 273 277 -
lang/perl/Text-MeCab/trunk/lib/Text/MeCab/Dict.pm
r4337 r4339 31 31 $libexecdir = $args{libexecdir}; 32 32 } else { 33 $libexecdir = Path::Class::Dir->new(`$config --libexecdir`); 33 $libexecdir = `$config --libexecdir`; 34 chomp $libexecdir; 34 35 } 35 36 … … 37 38 die "You must specify dict_source and libexecdir"; 38 39 } 40 $dict_source = Path::Class::Dir->new($dict_source); 41 $libexecdir = Path::Class::Dir->new($libexecdir); 39 42 40 43 my $self = bless { … … 82 85 83 86 $file = Path::Class::File->new($file); 87 if (! $file->is_absolute) { 88 $file = $self->dict_source->file( $file ); 89 } 90 84 91 my $fh = $file->open(">>"); 85 $fh->print(join("\n", @output ));92 $fh->print(join("\n", @output, "")); 86 93 $fh->close; 87 94 … … 107 114 foreach my $cmd (@cmds) { 108 115 if (system(@$cmd) != 0) { 109 die "Failed to execute '@$cmd' ";116 die "Failed to execute '@$cmd': $!"; 110 117 } 111 118 } … … 152 159 use Text::MeCab::Dict; 153 160 154 my $dict = Text::MeCab::Dict->new(); 161 my $dict = Text::MeCab::Dict->new( 162 dict_source => "/path/to/mecab-ipadic-source" 163 ); 155 164 $dict->add( 156 165 surface => $surface, # 表層形 … … 178 187 =head1 METHODS 179 188 189 =head2 new 190 191 Creates a new instance of Text::MeCab::Dict. 192 193 The 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 199 If you are in an environment where mecab-config is NOT available, you must 200 also 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 209 Adds a new entry to be appended to the dictionary. Please see SYNOPSIS for 210 arguments. 211 212 =head2 write 213 214 Writes out the entries that were added via add() to the specified file 215 location. If the file name does not look like an absolute path, the name 216 will be treated relatively from dict_source 217 180 218 =head2 rebuild 181 219
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)