为DBPedia构建一个简单的SPARQL查询

时间:2018-04-02 20:02:04

标签: sparql dbpedia

我有兴趣使用DBPedia和SPARQL查询疾病到医学专业的映射。我想编写一个返回疾病名称的查询,以及相关的医学专业名称。

我知道我可以通过此查询获得疾病列表:

PREFIX dbo: <http://dbpedia.org/ontology/>

SELECT ?disease WHERE {
    ?disease a dbo:Disease .
}

ORDER BY ?disease

我如何获得相关的医学专业?我是SPARQL和DBPedia的新手!

1 个答案:

答案 0 :(得分:1)

我测试了它here;以下查询应该提供您想要的内容:

PREFIX dbo: <http://dbpedia.org/ontology/>

SELECT ?disease ?med_spec WHERE {
    ?disease a dbo:Disease .
    ?disease dbp:field ?med_spec .
}

产生(仅举几个例子):

http://dbpedia.org/resource/Dengue_fever    http://dbpedia.org/resource/Infectious_disease_(medical_specialty)
http://dbpedia.org/resource/Dermatitis  http://dbpedia.org/resource/Dermatology
http://dbpedia.org/resource/Diabetes_insipidus  http://dbpedia.org/resource/Endocrinology
http://dbpedia.org/resource/Diabetic_ketoacidosis   http://dbpedia.org/resource/Endocrinology
http://dbpedia.org/resource/Diabetic_retinopathy    http://dbpedia.org/resource/Ophthalmology
http://dbpedia.org/resource/Diarrhea    http://dbpedia.org/resource/Gastroenterology
http://dbpedia.org/resource/Diarrhea    http://dbpedia.org/resource/Infectious_disease_(medical_specialty)