Skip to content

Instantly share code, notes, and snippets.

@fasiha
Last active December 23, 2023 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fasiha/fffa8914d25660859ad97da1eafd92cb to your computer and use it in GitHub Desktop.
Save fasiha/fffa8914d25660859ad97da1eafd92cb to your computer and use it in GitHub Desktop.
J.DepP usage and output example

Example output

➜ echo あの壁にかかっている絵はきれいですね | mecab -d /usr/local/lib/mecab/dic/unidic | jdepp 2> /dev/null | to_tree.py
# S-ID: 1; J.DepP
  0:         あの━━┓
  1:   壁に━━┓     ┃
  2:  かかっている━━┓  ┃
  3:         絵は━━┫
  4:        きれいですねEOS
➜ echo あの壁にかかっている絵はきれいですね | mecab -d /usr/local/lib/mecab/dic/unidic | jdepp 2> /dev/null | to_chunk.py
# S-ID: 1; J.DepP
あの │ 壁 に │ かかっ て いる │ 絵 は │ きれい です ね EOS

Download and install instructions on Naoki Yoshinaga's website: http://www.tkl.iis.u-tokyo.ac.jp/~ynaga/jdepp/#dl

@MeikyuuTrader
Copy link

I think you're right. When I ran make clean && ./configure | grep python it spits out checking for python... no

I tried installing via pyenv like yourself and python local returns 2.7.14, however, that checking for python...no exists. I'll try to install python normally and see what happens. Perhaps because I can't use python in the command line, it acts as if it doesn't exist?

@fasiha
Copy link
Author

fasiha commented Jan 16, 2022

Hmm, pyenv does do a lot of path shenanigans so you might need to close your terminal and reopen it to ascertain that when you run python it loads Python 2 from pyenv (which you can confirm with which python)? I'm sure I've always had Python available before installing jdepp so never encountered this issue before 😢 best of luck.

@MeikyuuTrader
Copy link

MeikyuuTrader commented Jan 16, 2022

@fasiha THANK YOU for all your help, I don't think I would get bloody J.DepP without you noticing ./configure assigned python to no when it didn't exist. The woes of thinking a critical dependency would fail the script :). I was trying to install and get older gcc versions to run makefiles xD

Despite having pyenv, it always returned no python. Which python never returned anything. I think you could get it working with pyenv, you'd need to make sure which python returns python 2.7.

I'm using Ubuntu so I outright installed python with apt-get and then set python2.7 to the be main version. After that, running make clean && ./configure showed checking for python... /usr/bin/python

Also got file permission error when running make install due to /usr/bin/install: cannot create regular file '/usr/local/bin/jdepp': Permission denied ran as sudo to fix that.

Actually was so damned hard to get J.DepP installed.

Notes for anyone else

  • Install python 2.7 (run which python and if there's no ouput, it won't show). Check this in the ./configure script, if checking for python = no, the model training won't work.
  • You may get permission errors when trying to create a folder in /usr/local/bin when running make install so run it as sudo make install
  • Homebrew is the easiest way to install MeCab and the mecab-unidic
  • Use the linked KNBC in the first post, it's the EUC_JP version, the UTF-8 version will fail in training the model due to the script trying to convert to UTF-8.

@fasiha
Copy link
Author

fasiha commented Jan 16, 2022

Glad it's working, what an ordeal 😭!

Just because even the thought of using a system-wide python gives me anxiety, I did want to risk annoying you by asking if you noticed the stupidly complicated installation instructions for pyenv: in the macOS section it says "Then follow the rest of the post-installation steps under Basic GitHub Checkout, starting with #2 ("Configure your shell's environment for Pyenv")", and in that section it tells you how to futz with your .bashrc or .bash_profile to make it work.

I use oh-my-zsh and I just have the following line in ~/.zshrc: eval "$(pyenv init -)".

Again, totally feel free to ignore me! I'm just going on because I can't imagine life without pyenv/conda to keep my python sanity 🙃.

jdepp is also pretty interesting and unusual. I really like it but had to think about what exactly it was doing, what bunsetsu were, how to take advantage of bunsetsu and their inter-dependencies. Feel free to reach out if you want to check notes on it!

@MeikyuuTrader
Copy link

I was actually only using jdepp to create "words" and then I'd search the definition. More or less copying your method from the stackoverlfow post. So more advance stuff isn't going to be touched.

It's unfortunate that you can't get rid of the extra dependencies, like particles, to get the real word.

@fasiha
Copy link
Author

fasiha commented Dec 23, 2023

@MeikyuuTrader have you seen Ichiran? https://ichi.moe and https://github.com/tshatrov/ichiran its a very nice way (and an alternative to MeCab + JDepP) to find particles, etc. but via a totally different technique.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment