1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ginzaでエラーが出たらランタイムを再起動(Colaboratory)

Posted at

リクルートと国立国語研究所が共同で日本語の自然言語処理(NLP)ライブラリ「GiNZA」を出しましたが、GoogleColaboratoryで使おうとするとエラーが出たので、同じ状況に陥った人のために解決法を。

インストールからのエラー

GiNZAを以下でインストールします。

GiNZAインストール
!pip install "https://github.com/megagonlabs/ginza/releases/download/v1.0.2/ja_ginza_nopn-1.0.2.tgz" 

以下のようにコンソールから使う場合は問題なく処理できます

python -m spacy.lang.ja_ginza.cli

が、次のようにPythonで使おうとするとエラーが出ます。

エラー!
import spacy
nlp = spacy.load('ja_ginza_nopn')
doc = nlp('これじゃエラーが出ちゃう。')
for sent in doc.sents:
    for token in sent:
        print(token.i, token.orth_, token.lemma_, token.pos_, token.dep_, token.head.i)

ランタイムを再起動する

GiNZAをインストールしたあと、ランタイムを再起動。これで私の場合は解決しました。
理由はわかりません。知っている方がいらっしゃれば、ご教授いただければ幸いです。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?