情感词在否定的语义范围内表现出很大的不同。我想用一个稍微修改过的版本
Das and Chen (2001)
它们能检测出诸如
,
不
,和
然后在否定和从句级标点符号之间出现的每个单词后面加一个“neg”后缀。
我想从spaCy创建类似的依赖解析。
import spacy
from spacy import displacy
nlp = spacy.load('en')
doc = nlp(u'$AAPL is óóóóópen to âTalkâ about patents with GOOG definitely not the treatment #samsung got:-) heh')
options = {'compact': True, 'color': 'black', 'font': 'Arial'}
displacy.serve(doc, style='dep', options=options)
可视化的依赖关系路径:
很好,在依赖标记方案中存在一个否定修饰符;
NEG
为了识别否定,我使用以下方法:
negation = [tok for tok in doc if tok.dep_ == 'neg']
现在我要检索否定的范围。
import spacy
from spacy import displacy
import pandas as pd
nlp = spacy.load("en_core_web_sm")
doc = nlp(u'AAPL is óóóóópen to Talk about patents with GOOG definitely not the treatment got')
print('DEPENDENCY RELATIONS')
print('Key: ')
print('TEXT, DEP, HEAD_TEXT, HEAD_POS, CHILDREN')
for token in doc:
print(token.text, token.dep_, token.head.text, token.head.pos_,
[child for child in token.children])
这将产生以下输出:
DEPENDENCY RELATIONS
Key:
TEXT, DEP, HEAD_TEXT, HEAD_POS, CHILDREN
AAPL nsubj is VERB []
is ROOT is VERB [AAPL, óóóóópen, got]
óóóóópen acomp is VERB [to]
to prep óóóóópen ADJ [Talk]
Talk pobj to ADP [about, definitely]
about prep Talk NOUN [patents]
patents pobj about ADP [with]
with prep patents NOUN [GOOG]
GOOG pobj with ADP []
definitely advmod Talk NOUN []
not neg got VERB []
the det treatment NOUN []
treatment nsubj got VERB [the]
got conj is VERB [not, treatment]
不
,所以
got
它正在定位?