- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
情感词在否定语义范围内的表现非常不同。我想使用 Das and Chen (2001) 的稍微修改版本它们检测诸如 no、not 和 never 之类的单词,然后将“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]
如何仅过滤掉not的token.head.text,以便got
并且正在定位?有人可以帮我吗?
最佳答案
您可以简单地定义并循环您找到的否定标记的头标记:
negation_tokens = [tok for tok in doc if tok.dep_ == 'neg']
negation_head_tokens = [token.head for token in negation_tokens]
for token in negation_head_tokens:
print(token.text, token.dep_, token.head.text, token.head.pos_, [child for child in token.children])
它会打印出got
的信息。
关于python - 使用 spaCy 进行否定和依赖解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54849111/
这个问题在这里已经有了答案: Tempered Greedy Token - What is different about placing the dot before the negative l
我想做与THIS相反的事情。换句话说,我该怎么做: SELECT * FROM table1 WHERE col1, col2 NOT IN (SELECT col1, col2
嗨,假设我有这个字符串: var text = "Jackie Chan | Jack Frost | Capt.Jack Sparrow" 我想找到除 Jack Frost 之外的所有 /Jack/
我只想在运行低于 iOS8 操作系统的设备上执行代码块。我做不到: if #available(iOS 8.0, *) == false { doFoo() } 我目前使用的解决方案是: if
我使用 htaccess 来解析对 seo 友好的请求。早些时候我的 htaccess 有这些字符串来解析像 /some/request/ 这样的请求 RewriteCond %{REQUEST_UR
我只想在运行低于 iOS8 操作系统的设备上执行代码块。我做不到: if #available(iOS 8.0, *) == false { doFoo() } 我目前使用的解决方案是: if
我的一个考试题目是: ! ( ! ( a != b) && ( b > 7 ) ) 选择: a) (a != b) || (b 7) 最初,我以为是 D。这是不正确的,我知道为什么。我不明白逻辑
我很难在 Prolog 中寻找关于否定的明确答案,所以如果这是一个明显的问题,我深表歉意: 我正在尝试编写一个简单的代码,从逻辑上说“如果 X 喜欢 Y 并且只喜欢 Y,则 X 和 Y 彼此相爱。”我
假设我有以下字符串: 邮寄至 电话:+358123456 http://www.google.fi 邮箱:foo@bar.fi Hello World 电话 大象 一分钱 链接 猫头鹰 如何在 RE2
如何在 RE2 中为“匹配字符串不以 4 或 5 开头”编写正则表达式? 在 PCRE 中,我会使用 ^(?!4)但 RE2 doesn't support that syntax . 最佳答案 您可
假设我有一个谓词 is_foo?/1在 Elixir 我想在一个将谓词作为参数的函数中使用它,但被否定了。 Elixir 有没有办法简单地做到这一点? 最佳答案 &(!is_foo? &1)应该这样做
假设我想制作一个描述所有整数的 RE。根据定义,表达式为: (+|-)?[0-9]+ 但定义也匹配这些数字:+0, -0, 0045 0045 情况可能可以使用回溯表达式来解决,但是我如何才能从关于。
作为 Javascript 的初学者,我有一个看起来有点奇怪的问题。我正在使用我在网上找到的外部库,我在其中找到了以下代码: if('useHoles' in c){ this.config.u
否定 MySQL 查询的最佳方法是什么,也就是说,无论条件如何,强制它不返回任何记录。 我使用了 AND 1=0 ,它似乎有效,但我有兴趣知道是否有这样的标准。 最佳答案 只需添加一个false条件
我有一个问题:我必须获取所有未在指定时间表中安排的司机姓名。我可以使用以下查询获取指定时间表中安排的所有司机姓名,但我无法否定它。请给我指示如何去做。谢谢。 select drivername fro
我正在做功能测试,刚刚发现了 assert_difference,如: assert_difference('Account.count') do post :create, :account =
考虑这个模式:*.py。它匹配所有以 py 扩展名结尾的路径。现在,是否有可能找到一个匹配其他一切的模式? 我认为这样可以做到:*[!.][!p][!y],但显然 fnmatch.fnmatch总是返
我有以下正则表达式模式:[^\u0001-\u00FF]。这样我就可以验证用户输入不包含“€”等无效字符。 var utfRegex: RegExp = new RegExp('[^\u0001-\u
我尝试使用 vector::erase 和 std::remove_if 从 vector 中删除对象。我有一个外部 namespace 来进行选择: template bool Namespace:
是否有可能/可以实现否定 boost 过滤适配器,例如 std::vector v = {1, 2, 3, 4, 5}; for(auto i : v | !filtered(is_even))
我是一名优秀的程序员,十分优秀!