使用python使用wordnet消除YAGO类的歧义

问题描述 投票:0回答:1

YAGO知识图中的类的形式为wordnet_XXX_YYY,其中XXX是类的名称,而YYY是wordnet中的同义词集ID。因此,例如,类机场的URI为http://yago-knowledge.org/resource/wordnet_airport_102692232

因此,由于单词的含义不同,根据含义,YAGO可能具有许多具有相同XXX和不同YYY的类。

如何根据YYY查找单词的定义?在他们的网站https://www.mpi-inf.mpg.de/departments/databases-and-information-systems/research/yago-naga/yago/faq/上,它说YYY是同义词集ID,但该工具返回airport.n.01作为同义词集ID。

我想念什么?

python wordnet id
1个回答
0
投票

您必须使用YAGO指南在计算机中运行SPARQL查询,以从YAGO本体中提取信息。对于您的问题,我希望以下python代码能为您提供所需的结果。

```
from SPARQLWrapper import SPARQLWrapper, JSON
sparql.setQuery("""
    select  *
where {
        <http://yago-knowledge.org/resource/wordnet_XXX_YYY> <http://yago-knowledge.org/resource/hasGloss> ?GlossValues.
      } 
    """)
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
#print(results)

for result in results["results"]["bindings"]:
    print(result)
```
© www.soinside.com 2019 - 2024. All rights reserved.