Giter Club home page Giter Club logo

wikidata.jl's Introduction

Wikidata

Build Status Build Status Codecov Coveralls

This is a project to implement a Wikidata Client in Julia. For the moment, I am using this project to get used to Julia.

Usage

#load a Wikidata-Entity (Douglas Adams) 
adams = Wikidata.WikidataEntity("Q42")
println(Wikidata.label(adams))

#check if place of birth exists for this entity:
if(Wikidata.hasproperty(adams, "P19"))
  placeofbirth = Wikidata.getproperty(adams, "P19")
  # print Adams' place of birth: Cambridge
  println(Wikidata.label(placeofbirth[1]))
end

Example

How to extract birthplaces and their coordinates for all presidents (head of governement) of the US (or any other country)

using Wikidata
using DataFrames

function getPresidentsBirthPlaces(x::String)
    df = DataFrame(Name = String[], birthplace= String[], birthplace_lat = BigFloat[], birthplace_lon = BigFloat[])
    country = Wikidata.WikidataEntity(x)
    #head of government is found under Property P6
    presidents_Entities = Wikidata.getproperty(country, "P6")
    for president in presidents_Entities
       try
       #P19 is the place-of-birth property 
       birthplace_Entity = Wikidata.getproperty(president, "P19")
       #P625 is the coordinate location property 
       birthplace_latlon = Wikidata.getproperty(birthplace_Entity[1], "P625")[1]
       push!(df, (Wikidata.label(president), Wikidata.label(birthplace_Entity[1]),birthplace_latlon[1], birthplace_latlon[2]))
        catch
            println("Data not found")
        end
    end
    df
 end
 df = getPresidentsBirthPlaces("Q30") #Q30 is the identifier for the US, Q183 is the identifier of Germany etc.

wikidata.jl's People

Contributors

kimbue avatar

Stargazers

ebigram avatar Kusti Skytén avatar Josua Grawitter avatar  avatar

Watchers

 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.