Git Product home page Git Product logo

wikidata-rank-hdt's Introduction

danker-hdt-docker

Example showing a screenshot of universities ranked by Wikidata PageRank

Quickstart:

$ VERSION="2022-11-10"
$ wget https://danker.s3.amazonaws.com/"$VERSION".allwiki.links.rank.hdt.bz2 && \
       bunzip2 "$VERSION".allwiki.links.rank.hdt.bz2 && \
       mv "$VERSION".allwiki.links.rank.hdt rank.hdt
$ docker-compose up -d

# open http://localhost in browser.

Example queries:

# Rankings of castles in Switzerland

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX vrank: <http://purl.org/voc/vrank#>

SELECT * WHERE {
  SERVICE <https://query.wikidata.org/sparql> {
    SELECT DISTINCT ?castle ?castleLabel WHERE {
      ?castle wdt:P17/wdt:P279* wd:Q39.
      ?castle wdt:P31/wdt:P279* wd:Q23413.
      SERVICE wikibase:label {
        bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
      }
    }
  }
  ?castle vrank:pagerank ?rank.

}
ORDER BY DESC(?rank)

# Universities by PageRank

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX vrank: <http://purl.org/voc/vrank#>

SELECT * WHERE {
  {
    SERVICE <https://query.wikidata.org/sparql> {
      SELECT DISTINCT ?uni ?uniLabel WHERE {
        ?uni wdt:P31/wdt:P279* wd:Q3918.
        SERVICE wikibase:label {
          bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
        }
      }
    }
  }
  ?uni vrank:pagerank ?rank.

} ORDER BY DESC(?rank)
# Top 50 items by PageRank (optionally links to English Wikipedia) 

PREFIX vrank: <http://purl.org/voc/vrank#>
PREFIX schema: <http://schema.org/>

SELECT ?item ?article ?rank WHERE {
  {
    {
      SELECT * WHERE {
        ?item vrank:pagerank ?rank.
      } ORDER BY DESC(?rank) LIMIT 50
    }
  }
  SERVICE <https://query.wikidata.org/sparql> {
    OPTIONAL {
      ?article schema:about ?item .
      ?article schema:inLanguage "en" .
      ?article schema:isPartOf <https://en.wikipedia.org/> .
    }
  }
}
# Universities by PageRank (DBpedia URIs)

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX vrank: <http://purl.org/voc/vrank#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX schema: <http://schema.org/>

SELECT * WHERE {
  {
    SELECT DISTINCT ?uni (URI(REPLACE(str(?article), "https://en.wikipedia.org/wiki", "http://dbpedia.org/resource")) as ?dbpedia) WHERE {
      SERVICE <https://query.wikidata.org/sparql> {
        ?uni wdt:P31/wdt:P279* wd:Q3918.
        ?article schema:about ?uni .
        ?article schema:inLanguage "en" .
        ?article schema:isPartOf <https://en.wikipedia.org/> .
      }
    }
  }
  ?uni vrank:pagerank ?rank.
} ORDER BY DESC(?rank) LIMIT 50
# 27 Club by PageRank

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX vrank: <http://purl.org/voc/vrank#>

SELECT DISTINCT * WHERE {
  {
    SERVICE <https://query.wikidata.org/sparql> {
      SELECT ?artist ?artistLabel ?dob ?dod {
        {
          SELECT ?artist ?dod ?dob WHERE {
            ?artist wdt:P106/wdt:P279* wd:Q483501 ;
                      wdt:P569 ?dob ;
                      wdt:P570 ?dod .
            BIND(FLOOR((?dod - ?dob) / 365.2425) AS ?age).
            FILTER (?age = 27)
          }
        }
        SERVICE wikibase:label {
          bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
        }
      }
    }
  }
  ?artist vrank:pagerank ?rank.
} ORDER BY DESC(?rank)

Additional information

https://github.com/athalhammer/danker

Used docker images:

wikidata-rank-hdt's People

Contributors

athalhammer avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.