在spacy中获取名词块有一个couple of现有的问题,这就是relatively straightforward。
我感兴趣的是在句子中预先指定的ngram之上复制依赖关系解析。如下面的示例所示,来自this spacy talk,其中Alex Smith
和East London
在依赖项解析中被视为单个令牌。
发布于 2019-05-17 20:51:21
这可能是通过指定"collapse_phrases" : True
的options
参数完成的
详情请访问https://spacy.io/api/top-level#options-dep
创建可在浏览器中打开的svg文件的示例
import spacy
from spacy import displacy
from pathlib import Path
nlp = spacy.load('en_core_web_sm', parse=True, tag=True, entity=True)
doc = nlp("Alex Smith was fatally stabbed in East London")
print(doc.ents)
options = {"color": "white", "collapse_phrases" : True, "bg": "#000000"}
svg = displacy.render(doc, style="dep", options=options)
output_path = Path("dependency_plot.svg")
output_path.open("w", encoding="utf-8").write(svg)
https://stackoverflow.com/questions/56173627
复制相似问题