Text::...b::Dict(3pm)

๐Ÿ’– Text::MeCab::Dict โ€” the manual, but make it cute ๐Ÿ’–

okay bestie, sit down, hydrate, and let me tell you about Text::MeCab::Dict โ€” that's the Text::MeCab::Dict page from the User Contributed Perl Documentation, and she's a Utility To Work With MeCab Dictionary. literally that's the NAME, no notes. โœจ


๐ŸŒธ SYNOPSIS ๐ŸŒธ

here's the whole vibe in one go, direct from the source, don't touch anything:

  use Text::MeCab::Dict;

  my $dict = Text::MeCab::Dict->new(
    dict_source => "/path/to/mecab-ipadic-source"
  );
  $dict->add(
    surface      => $surface,        # ่กจๅฑคๅฝข
    left_id      => $left_id,        # ๅทฆๆ–‡่„ˆID
    right_id     => $right_id,       # ๅณๆ–‡่„ˆID
    cost         => $cost,           # ใ‚ณใ‚นใƒˆ
    pos          => $part_of_speech, # ๅ“่ฉž
    category1    => $category1,      # ๅ“่ฉž็ดฐๅˆ†้กž1
    category2    => $category2,      # ๅ“่ฉž็ดฐๅˆ†้กž2
    category3    => $category3,      # ๅ“่ฉž็ดฐๅˆ†้กž3

    # XXX this below two parameter names need blessing from a knowing
    # expert, and is subject to change
    inflect      => $inflect,        # ๆดป็”จๅฝข
    inflect_type => $inflect_type,   # ๆดป็”จๅž‹

    original     => $original,       # ๅŽŸๅฝข
    yomi         => $yomi,           # ่ชญใฟ
    pronounce    => $pronounce,      # ็™บ้Ÿณ
    extra        => \@extras,        # ใƒฆใƒผใ‚ถใƒผ่จญๅฎš
  );
  $dict->write('foo.csv');
  $dict->rebuild();
๐Ÿซถ heads up: those two parameter names inflect and inflect_type are literally flagged in the source as needing blessing from a knowing expert, and they're subject to change. so don't build your whole personality around them, okay? ๐Ÿ™ˆ

๐ŸŽ€ METHODS ๐ŸŽ€

โœจ new

Creates a new instance of Text::MeCab::Dict. new instance, new me, main character energy ๐Ÿ‘‘

The path to the source of mecab-ipadic is required, bestie, you can't skip it:

  my $dict = Text::MeCab::Dict->new(
    dict_source => "/path/to/mecab-ipadic-source"
  );

and if you're in an environment where mecab-config is NOT available, you also have to specify libexecdir, which is where mecab-dict-index is installed:

  my $dict = Text::MeCab::Dict->new(
    dict_source => "/path/to/mecab-ipadic-source",
    libexecdir  => "/path/to/mecab/libexec/",
  );

that's it, that's the whole constructor. no cap. ๐Ÿ’…

๐ŸŒˆ add

Adds a new entry to be appended to the dictionary. Please see SYNOPSIS for arguments โ€” yeah, go look up there, I already laid them all out for you, you're welcome ๐Ÿ’–

๐Ÿฆ‹ write

Writes out the entries that were added via add() to the specified file location. ๐ŸŒธ

and here's the lil plot twist: if the file name does not look like an absolute path, the name will be treated relatively from dict_source. so like, know where you're standing, girlie. โœจ

โญ rebuild

Rebuilds the index. ๐Ÿ”ฅ

โš ๏ธ This usually requires that you are have root privileges โ€” yes that's exactly how the original says it and I'm not fixing it, it's iconic. go get your sudo, bestie.

๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

go read it, it's giving documentation, iykyk ๐Ÿงš


and that's the tea, bestie ๐Ÿ“ this whole page came to you courtesy of perl v5.42.3 and the date 2026-08-20, filed under Text::MeCab::Dict(3pm). slay, go add some dictionary entries, periodt ๐Ÿ’…โœจ๐Ÿ’œ

๐Ÿ“ฆ where this page comes from