0
1

More than 1 year has passed since last update.

Ginza の使い方

Last updated at Posted at 2021-11-26

GiNZA - Japanese NLP Library
の使い方です。

インストール

pip install -U ginza ja-ginza

パスを通す

export PATH=$PATH:/home/uchida/.local/bin

固有名詞の抽出を行いました。
こちらと同じプログラムです。
ubuntu 21.10 に mecab をインストール

pickup_propn.py
#! /usr/bin/python
#
#   pickup_propn.py
#                   Nov/26/2021
#
import spacy
nlp = spacy.load('ja_ginza')
text_in = "特急はくたかで富山に向かいます。それから、金沢に行って、兼六園に行きます。"
doc = nlp(text_in)
for sent in doc.sents:
    for token in sent:
        if token.pos_ == "PROPN":
            print(token.orth_, token.tag_)
#

実行結果

$ ./pickup_propn.py 
富山 名詞-固有名詞-地名-一般
金沢 名詞-固有名詞-地名-一般
0
1
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
0
1