spacy NLP如何提取本案例中的信息

2024-09-28 19:33:28 发布

您现在位置:Python中文网/ 问答频道 /正文

请看一下这个箱子。 我想用Spacy、NLP和Python从这句话中提取意图

noun -> gaming
adj -> super perfect

noun -> everyday use
adj -> super perfect

这句话的信息

this is super perfect for gaming and everyday use

this (DET) nsubj is
is (AUX) ROOT is
super (ADV) advmod perfect
perfect (ADJ) acomp is
for (ADP) prep perfect
gaming (NOUN) pobj for
and (CCONJ) cc gaming
everyday (ADJ) advmod use
use (NOUN) conj gaming

我试过了

noun= "NOUN"
adj = "ADJ"

for token in doc:    
    add_neg_pfx = False
    if(token.dep_ == "pobj"):
        noun+= token.text

    if(token.dep_ == "prep"):
        adj += token.head.text

但这段代码似乎没有那么具体


Tags: andtokenforisusethisnounsuper