如何link NE与它的依赖?
How to link NE with it's dependent?
我需要从文本中提取位置描述。现在,我正在尝试使用它的形容词修饰符来获取位置。
例如来自
In compact Durham you don't need transport to get around.
我想得到
compact Durham
我有 CoreEntityMention
和 SemanticGraph
我的句子。我可以获得 NE 令牌的索引以在 SemanticGraph
中找到 IndexedWord
,但 NE 可能包含多个令牌,所以我不知道如何构建 link。我看到 ,但不理解建议的解决方案。我需要检查每个令牌的依赖性吗?
这是我用 Kotlin 编写的方法(与 Java 没有太大区别):
val dependencies = mutableListOf<String>()
val depGraph = entityMention.sentence().dependencyParse()
for (token in entityMention.tokens()) {
val node = depGraph.getNodeByIndex(token.index())
for (dependence in depGraph.childPairs(node)) {
if (dependence.first.shortName == "amod") {
dependencies.add(dependence.second.toString())
}
}
}
这是正确且最简单的方法吗?
是的,目前我认为您能做的最好的事情是遍历实体提及的标记,因为标记之间存在依赖关系。
我会记下这个问题,也许我们可以添加一些代码,以便将来更容易。
我需要从文本中提取位置描述。现在,我正在尝试使用它的形容词修饰符来获取位置。
例如来自
In compact Durham you don't need transport to get around.
我想得到
compact Durham
我有 CoreEntityMention
和 SemanticGraph
我的句子。我可以获得 NE 令牌的索引以在 SemanticGraph
中找到 IndexedWord
,但 NE 可能包含多个令牌,所以我不知道如何构建 link。我看到
这是我用 Kotlin 编写的方法(与 Java 没有太大区别):
val dependencies = mutableListOf<String>()
val depGraph = entityMention.sentence().dependencyParse()
for (token in entityMention.tokens()) {
val node = depGraph.getNodeByIndex(token.index())
for (dependence in depGraph.childPairs(node)) {
if (dependence.first.shortName == "amod") {
dependencies.add(dependence.second.toString())
}
}
}
这是正确且最简单的方法吗?
是的,目前我认为您能做的最好的事情是遍历实体提及的标记,因为标记之间存在依赖关系。
我会记下这个问题,也许我们可以添加一些代码,以便将来更容易。