[PYTHON] Add user dictionary to MeCab

environment

Create a dictionary

vi user_dic.csv

How to use,-1,-1,1,noun,General,*,*,*,*,*,*,*,mydic
instruction manual,-1,-1,1,noun,General,*,*,*,*,*,*,*,mydic
...

Compiling user dictionaries

$ /usr/local/Cellar/mecab/0.996/libexec/mecab/mecab-dict-index \
-d /usr/local/lib/mecab/dic/ipadic \
-u user.dic \
-f utf-8 \
-t utf-8 user.csv

--Meaning of option --- d DIR: Directory with system dictionary --- u FILE: Create a user file called FILE --- f charset: CSV character code --- t charset: Character code of binary dictionary

Because it is said that

/usr/local/Cellar/mecab/0.996/libexec/mecab/mecab-dict-index \
-d /usr/local/lib/mecab/dic/ipadic \
-u user_dic.dic \
-f utf-8 \
-t utf-8 \
user_dic.csv 

You now have user_dic.dic.

Add dictionary

vi /usr/local/etc/mecabrc

userdic = /Users/.../user_dic.dic

I was able to add it.

Operation check

$ mecab
instruction manual
Instruction manual noun,General,*,*,*,*,*,*,*,mydic
EOS

It looks like it's done.

Other

Adding a verb seems to be a hassle. http://www.mwsoft.jp/programming/nlp/mecab_dictionary_customize.html

reference

-Adding words to MeCab user dictionary -Add mecab user dictionary -Add user dictionary to MeCab -Blog of an engineer who likes Tachikoma

Recommended Posts

Add user dictionary to MeCab
Add a dictionary to MeCab
MeCab: Add new words to user-defined dictionary (Windows)
[Morphological analysis] How to add a new dictionary to Mecab
Add words to MeCab's user dictionary on Ubuntu for use in Python
Add convolution to MNIST
How to use dictionary {}
Access to dictionary fields
[Caution] Specify system dictionary or user dictionary with mecab [Windows]
Introduction to dictionary lookup algorithm
Add / remove kernel to JupyterLab
Use MeCab to fetch readings
Add page number to PDF
Add Linux user, how to use useradd command (password specification)
Add System to pyenv-win versions
To add a C module to MicroPython ...
Add fields to features with ArcPy
Add cumulative ratio to matplotlib histogram
Add Python 2.7 Japanese documentation to Dash.app
How to add sudo when debugging
Add parameters to Django's custom commands
Metaclass (wip) to generate a dictionary
Add TRACE log level to Python ...?