🎁 Get the FREE AI Skills Starter Guide β€” Subscribe β†’
BytesAgainBytesAgain
πŸ¦€ ClawHub

Query DBpedia using Natural Language

by @kidehen

Transform natural language questions into SPARQL queries for DBpedia and generate beautiful HTML results pages. Query the DBpedia knowledge graph using plain...

Versionv1.0.0
Downloads1,043
TERMINAL
clawhub install query-dbpedia

πŸ“– About This Skill


name: dbpedia-query-skill description: Transform natural language questions into SPARQL queries for DBpedia and generate beautiful HTML results pages. Query the DBpedia knowledge graph using plain English prompts.

DBpedia Query Skill

When to Use This Skill

Use this skill when users want to:

  • Query DBpedia using natural language
  • Ask questions about people, places, movies, books, organizations, etc.
  • Get structured data from Wikipedia via DBpedia
  • Create visualizations of DBpedia query results
  • Generate HTML reports from SPARQL queries
  • Core Capabilities

    βœ… Natural Language to SPARQL: Convert user questions into valid SPARQL queries βœ… Query Execution: Execute queries against DBpedia endpoint βœ… HTML Generation: Create beautiful, interactive HTML result pages βœ… Multiple Output Formats: JSON, Markdown tables, or HTML βœ… Error Handling: Graceful handling of malformed queries or no results

    DBpedia Endpoint

    SPARQL Endpoint: https://dbpedia.org/sparql Format: JSON results (format=json) Method: HTTP GET with URL-encoded query

    Common DBpedia Prefixes

    PREFIX dbo: 
    PREFIX dbr: 
    PREFIX dbp: 
    PREFIX rdfs: 
    PREFIX rdf: 
    PREFIX foaf: 
    PREFIX dct: 
    

    Query Conversion Workflow

    When a user provides a natural language prompt:

    1. Analyze the Question

  • Identify the subject (who/what is being asked about)
  • Identify the predicate (what information is requested)
  • Determine if filtering, sorting, or limiting is needed
  • 2. Map to DBpedia Properties

    Common mappings:

  • "directed by" β†’ dbo:director
  • "release date" β†’ dbp:date or dbo:releaseDate
  • "budget" β†’ dbo:budget
  • "born in" β†’ dbo:birthPlace
  • "population" β†’ dbo:populationTotal
  • "capital of" β†’ dbo:capital
  • "written by" β†’ dbo:author
  • "starring" β†’ dbo:starring
  • 3. Construct SPARQL Query

    Template:

    PREFIX dbo: 
    PREFIX dbr: 
    PREFIX rdfs: 

    SELECT DISTINCT ?variable ?label WHERE { ?variable ; rdfs:label ?label . FILTER(LANG(?label) = 'en') } ORDER BY LIMIT

    4. Execute Query

    Use curl to execute against DBpedia:

    curl -s -G "https://dbpedia.org/sparql" \
      --data-urlencode "query=" \
      --data-urlencode "format=json"
    

    5. Generate Output

    Options:

  • JSON: Raw query results
  • Markdown Table: Formatted for terminal display
  • HTML Page: Interactive, styled results page
  • Example Query Patterns

    Pattern 1: Films by Director

    User: "Show me movies directed by Christopher Nolan"

    SPARQL:

    PREFIX dbo: 
    PREFIX dbr: 
    PREFIX rdfs: 

    SELECT DISTINCT ?film ?title ?releaseDate WHERE { ?film dbo:director dbr:Christopher_Nolan ; a dbo:Film ; rdfs:label ?title . OPTIONAL { ?film dbo:releaseDate ?releaseDate } FILTER(LANG(?title) = 'en') } ORDER BY DESC(?releaseDate)

    Pattern 2: Population Queries

    User: "What are the 10 most populous cities in France?"

    SPARQL:

    PREFIX dbo: 
    PREFIX dbr: 
    PREFIX rdfs: 

    SELECT ?city ?name ?population WHERE { ?city dbo:country dbr:France ; a dbo:City ; rdfs:label ?name ; dbo:populationTotal ?population . FILTER(LANG(?name) = 'en') } ORDER BY DESC(?population) LIMIT 10

    Pattern 3: Person Information

    User: "Tell me about Albert Einstein - when was he born and where?"

    SPARQL:

    PREFIX dbo: 
    PREFIX dbr: 
    PREFIX rdfs: 

    SELECT ?birthDate ?birthPlace ?placeLabel WHERE { dbr:Albert_Einstein dbo:birthDate ?birthDate ; dbo:birthPlace ?birthPlace . ?birthPlace rdfs:label ?placeLabel . FILTER(LANG(?placeLabel) = 'en') }

    HTML Template Generation

    When generating HTML results:

    Required Elements

    1. Title: Question or query description 2. Statistics: Number of results, query execution time 3. Table: Results with hyperlinked DBpedia URIs 4. SPARQL Query Display: Show the executed query 5. Footer: Link to DBpedia, data source attribution

    Styling Guidelines

  • Use gradient backgrounds
  • Responsive design (mobile-friendly)
  • Hover effects on table rows
  • Hyperlink all DBpedia resources
  • Color-code different data types
  • Include icons for visual appeal
  • HTML Template Structure

    
    
    
        
        [Query Description] - DBpedia
        
    
    
        

    [Question/Title]

    [Results count]
    [Results]
    [Query code]

    Error Handling

    No Results

    If query returns 0 results:
  • Inform user clearly
  • Suggest alternative phrasings
  • Check for typos in entity names
  • Query Errors

    If SPARQL syntax error:
  • Display error message
  • Show attempted query
  • Offer to reformulate
  • Timeout

    If query times out:
  • Add LIMIT clause
  • Simplify query complexity
  • Suggest narrowing criteria
  • Output Preferences

    Always ask the user:

    "Would you like the results as:
    1. JSON (raw data)
    2. Markdown table (terminal display)
    3. HTML page (interactive visualization)"
    

    Best Practices

    1. Always use DISTINCT: Avoid duplicate results 2. Filter by language: Use FILTER(LANG(?label) = 'en') 3. Add LIMIT: Default to LIMIT 100 unless specified 4. Use OPTIONAL: For properties that may not exist 5. Order results: Make results meaningful with ORDER BY 6. Hyperlink in HTML: All DBpedia URIs should be clickable

    Example Session

    User: "List books written by J.K. Rowling with publication dates"

    Assistant: "I'll query DBpedia for books authored by J.K. Rowling.

    Executing SPARQL query against DBpedia endpoint..."

    [Constructs and executes query]

    "Found 15 books! Would you like the results as: 1. JSON 2. Markdown table 3. HTML page"

    User: "HTML page"

    Assistant: [Generates beautiful HTML page with results]

    "βœ“ HTML page generated and saved to: ./jk_rowling_books.html βœ“ 15 books found with publication dates"

    Scope

    This skill handles:

  • Queries about entities in DBpedia
  • Structured data extraction
  • Result formatting and visualization
  • This skill does NOT handle:

  • Text search (use DBpedia Lookup API instead)
  • Data modification (read-only queries)
  • Real-time data (DBpedia updates periodically)

  • Version: 1.0.0 Endpoint: https://dbpedia.org/sparql Data Source: DBpedia (Wikipedia structured data)

    πŸ“‹ Tips & Best Practices

    1. Always use DISTINCT: Avoid duplicate results 2. Filter by language: Use FILTER(LANG(?label) = 'en') 3. Add LIMIT: Default to LIMIT 100 unless specified 4. Use OPTIONAL: For properties that may not exist 5. Order results: Make results meaningful with ORDER BY 6. Hyperlink in HTML: All DBpedia URIs should be clickable

    BytesAgain
    Discover the best AI agent skills for your workflow.
    Β© 2026 BytesAgain. All rights reserved.
    BytesAgain is an independent skill directory. We index and link to third-party content (ClawHub, GitHub, LobeHub, Dify, etc.) for informational purposes only. All trademarks, skill names, and content are the property of their respective owners. BytesAgain does not claim ownership of any indexed content.