2017-09-12 23 views
0

次のTweet spacy dependency taggerでは、中断(VB)が医療市場(NN)のdobjであると記載されています。これらの2つの用語が結びついているので、それらを1つのフレーズとして抽出したいと思います。私は単語のdobjを抽出することができますので、構文解析ツリーをナビゲートする方法はありますか?私はfolllowingをすれば、私はspacyでdobjを取得する方法

from spacy.en import English 
from spacy.symbols import nsubj, VERB,dobj 

nlp = English() 
doc = nlp('Juniper Research: AI start-ups set to disrupt healthcare market, with $800 million to be spent on CAD Systems by 2022') 

for possible_subject in doc: 
if possible_subject.dep == dobj: 
    print(possible_subject.text) 

答えて

0

あなたは名詞チャンクを使用して以下のようにこれを行うことができ、市場ではなく、「heathcare市場」を取得

for np in doc.noun_chunks: 
    if np.root.dep == dobj: 
     print(np.root.text) 
     print(np.text) 
関連する問題