Question

I'm using the DBPediaSpotLight library and trying to get uri for each word in dbpedia like:

Word: teach

the URI is: http//dbpedia.org/resource/Teacher

the Category: /business/job_title

and I want to get all sub-categories for the word "teach" (3) levels.. I'm try to look for query in sparql but I didn't find what I want.

Was it helpful?

Solution

http://dbpedia.org/resource/Teacher (abbreviated dbpedia:Teacher) isn't a category in DBpedia, so it doesn't really make sense to ask for subcategories of it. However, http://dbpedia.org/resource/Category:Teaching is a category, and does have sub-categories. DBpedia organizes categories using the skos:broader property. Each supercategory is skos:broader than its subcategories. To get its subcategories, up to three levels deep, you can use a query like this:

select distinct ?subcategory where {
  category:Teaching skos:broader?/skos:broader?/skos:broader ?subcategory
}

SPARQL results

A property path with a / means one property path followed by another. A question mark after a property path means 0 or 1 occurrence of the path. Thus the path

skos:broader?/skos:broader?/skos:broader

means (0 or 1 broader)/(0 or 1 broader)/broader, which means that you'll find links between Teaching and subcategories 1, 2, or 3 broader links away.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top