我正在做一个问答任务。我计划使用依存关系解析来查找从段落到查询的候选答案。然而,我不确定如何才能找到查询的依存关系树和段落中的句子之间的相似性。下面是可重现的代码。
import spacy
from spacy import displacy
nlp = spacy.load('en_core_web_sm')
doc1 = nlp('Wall Street Journal just published an interesting piece on crypto currencies')
doc2 = nlp('What did Wall Street Journal published')
displacy.render(doc1, style='dep', jupyter=True, options={'distance': 90})
displacy.render(doc2, style='dep', jupyter=True, options={'distance': 90})
发布于 2019-03-14 21:10:25
这可能是你想要找的:
https://github.com/tomkwiat/dependency-graph-similarity-measure
它是基于Java的,但应该很容易移植到Python。
您可能会研究的另一件事是关于内核图相似性的论文。
https://stackoverflow.com/questions/55155728
复制相似问题