title: DBpedia getting page category using sparql
body: <p>I am using DBpedia to getting page category using SPARQL in R. However, there are having some problems on it. Source code I am using:</p>
  
  <pre><code>PREFIX dcterms: &lt;http://purl.org/dc/terms/&gt;
  PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;  
  SELECT ?categoryUri ?categoryName WHERE {
      &lt;http://dbpedia.org/resource/xxx&gt; dcterms:subject ?categoryUri.
           ## xxx are random words (e.g. Agree, Film, Work, Plan...)
      ?categoryUri rdfs:label ?categoryName.
      FILTER (lang(?categoryName) = "en")
  }
  </code></pre>
  
  <p>The problems are:</p>
  
  <ol>
  <li><p>Category cannot be retrieved if the words need to be redirected (e.g. Agree -> Agreement)</p></li>
  <li><p>Disambiguation pages cannot be used from the above source code, because there are so many sub-pages within the category of word (e.g. Work)</p></li>
  </ol>
  
  <p>So, how can I resolve the above problems? I am really appreciate if anyone can offer your help!!!</p>