- Search for Dbpedia entries by keyword or prefix (e.g. autocompleter)
- Use SPARQL via Ruby RDFs great sparql-client to query Dbpedia
Simply add it to your Gemfile:
gem "dbpedia"
gem "sparql-client" # if you want to use sparql
# Default search is by keyword:
Dbpedia.search('Ham').collect(&:label)
Dbpedia.search('Ham', method: 'keyword').collect(&:label)
#=> ["West Ham United F.C.", "Ham", "West Ham", "East Ham", "Hamarkameratene"]
# To perform a prefix-search (which is usefull for autocompleter) pass `method`:
Dbpedia.search('Ham', method: 'prefix').collect(&:label)
#=> ["Hamburg", "Hampshire", "Hamlet (place)", "Hamlet", "Hamilton, Ontario"]
results = Dbpedia.search('Hamburg')
puts results.first.label #=> "Hamburg"
puts results.first.categories.count #=> 15
puts results.first.categories.first.label #=> Populated places established in the 9th century"
[results] (SearchResult)
|-- label
|-- uri
|-- description
+-- [categories] (SearchResult::Category)
| |-- label
| |-- uri
+-- [classes] (SearchResult::Klass)
|-- label
|-- uri
Marke sure you've installed sparql-client!
Dbpedia.sparql.select.whatever
- Implement
find
for known resources - Gemify
Run $ bundle exec rspec -c
Copyright © 2013 Roman Ernst, released under CC BY-SA 3.0 license
.. without warranty of any kind!