I'm sorry, I'm a beginner to post to Qiita, so I think the layout is strange. I would be grateful if you could give me some advice on layout and writing.
Procedure for adding a new word (user dictionary) to MeCab
Mac OS X
userdic = /usr/local/lib/mecab/dic/ipadic/user.dic(left;Erase)
1.create_dic.py (Program for creating newword_dic.csv from newword_list.txt for Python 3.X)
create_dic.py
if __name__ == "__main__":
fin = open("newword_list.txt")
fout = open("newword_dic.csv","w")
for line in fin:
line=line.rstrip('\n')
word = line.split(',')
cost = int(max(-36000, -400*len(word[0])**1.5))
fout.write("%s,-1,-1,%d,noun,General,*,*,*,*,*,*,%s,%s\n" % (word[0],cost,word[1],word[1]))
fin.close()
fout.close()
2.newword_list.txt (list containing new words. Basically only this text file can be edited)
Sword Art Online, Sword Art Online Mankind has declined, mankind has declined Magical Girl Lyrical Nanoha, Magical Girl Lyrical Nanoha Artificial intelligence, artificial intelligence
python create_dic.py
sudo /usr/local/libexec/mecab/mecab-dict-index -d /usr/local/lib/mecab/dic/ipadic -u user.dic -f utf8 -t utf8 newword_dic.csv
sudo mv user.dic /usr/local/lib/mecab/dic/ipadic
If so, the user dictionary is correctly added to MeCab
http://tseiya.hatenablog.com/entry/2012/09/19/191114
Recommended Posts