All Projects → freearhey → wikidata

freearhey / wikidata

Licence: MIT license
A PHP client for working with Wikidata API.

Programming Languages

PHP
23972 projects - #3 most used programming language

Labels

Projects that are alternatives of or similar to wikidata

Word2vec
訓練中文詞向量 Word2vec, Word2vec was created by a team of researchers led by Tomas Mikolov at Google.
Stars: ✭ 48 (-9.43%)
Mutual labels:  wikidata
Hyte
EMNLP 2018: HyTE: Hyperplane-based Temporally aware Knowledge Graph Embedding
Stars: ✭ 130 (+145.28%)
Mutual labels:  wikidata
Citation.js
Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.
Stars: ✭ 171 (+222.64%)
Mutual labels:  wikidata
Mundaneum
A clojure wrapper around WikiData
Stars: ✭ 54 (+1.89%)
Mutual labels:  wikidata
Wikipedia Tools For Google Spreadsheets
Wikipedia Tools for Google Spreadsheets — Install:
Stars: ✭ 96 (+81.13%)
Mutual labels:  wikidata
Wikidata Graph Builder
Visualize Wikidata items using d3.js
Stars: ✭ 137 (+158.49%)
Mutual labels:  wikidata
Entities Search Engine
Scripts and microservice to feed an ElasticSearch with Wikidata and Inventaire entities, and keep those up-to-date
Stars: ✭ 39 (-26.42%)
Mutual labels:  wikidata
Agriculture Knowledgegraph Data
对知识库Wikidata的爬虫以及数据处理脚本 将三元组关系对齐到语料库的脚本 获取知识图谱数据的脚本
Stars: ✭ 198 (+273.58%)
Mutual labels:  wikidata
Scholia
Wikidata scholarly profiles
Stars: ✭ 115 (+116.98%)
Mutual labels:  wikidata
Wikibase Cli
read and edit a Wikibase instance from the command line
Stars: ✭ 148 (+179.25%)
Mutual labels:  wikidata
Openrefine
OpenRefine is a free, open source power tool for working with messy data and improving it
Stars: ✭ 8,531 (+15996.23%)
Mutual labels:  wikidata
Vglist
A video game library tracking web app built in Rails and powered by Wikidata.
Stars: ✭ 78 (+47.17%)
Mutual labels:  wikidata
Primarysources
Approve or reject statements from third-party datasets
Stars: ✭ 139 (+162.26%)
Mutual labels:  wikidata
Wikibase Edit
a lib to edit Wikibase from NodeJS
Stars: ✭ 48 (-9.43%)
Mutual labels:  wikidata
Cnn Re Tf
Convolutional Neural Network for Multi-label Multi-instance Relation Extraction in Tensorflow
Stars: ✭ 190 (+258.49%)
Mutual labels:  wikidata
Bbw
Semantic annotator: Matching CSV to a Wikibase instance (e.g., Wikidata) via Meta-lookup
Stars: ✭ 42 (-20.75%)
Mutual labels:  wikidata
Opentapioca
Entity linking system for Wikidata updated by your edits in real time
Stars: ✭ 136 (+156.6%)
Mutual labels:  wikidata
Wikibase Sdk
JS utils functions to query a Wikibase instance and simplify its results
Stars: ✭ 251 (+373.58%)
Mutual labels:  wikidata
Wikidata
Wikidata client library for Python
Stars: ✭ 191 (+260.38%)
Mutual labels:  wikidata
Benmaps.fr
Web maps that don't track you.
Stars: ✭ 147 (+177.36%)
Mutual labels:  wikidata

wikidata

Wikidata Build Status

Wikidata provides a API for searching and retrieving data from wikidata.org.

Installation

composer require freearhey/wikidata

Usage

First we need to create an instance of Wikidata class and save it to some variable, like this:

require_once('vendor/autoload.php');

use Wikidata\Wikidata;

$wikidata = new Wikidata();

after that we can use one of the available methods to access the Wikidata database.

Available Methods

search()

The search() method give you a way to find Wikidata entity by it label.

$results = $wikidata->search($query, $lang, $limit);

Arguments:

  • $query: term to search (required)
  • $lang: specify the results language (default: 'en')
  • $limit: set a custom limit (default: 10)

Example:

$results = $wikidata->search('car', 'fr', 5);

/*
  Collection {
    #items: array:5 [
      0 => SearchResult {
        id: "Q1759802"
        lang: "fr"
        label: "autocar"
        wiki_url: "https://fr.wikipedia.org/wiki/autocar"
        description: "transport routier pouvant accueillir plusieurs voyageurs pour de longues distances"
        aliases: array:1 [
          0 => "car"
        ]
      }
      1 => SearchResult {
        id: "Q224743"
        lang: "fr"
        label: "Car"
        wiki_url: "https://fr.wikipedia.org/wiki/Car"
        description: "page d'homonymie d'un projet Wikimédia"
        aliases: []
      }
      ...
    ]
  }
*/

The search() method always returns Illuminate\Support\Collection class with results. This means you can use all the methods available in Laravel's Collections.

searchBy()

The searchBy help you to find Wikidata entities by it properties value.

$results = $wikidata->searchBy($propId, $entityId, $lang, $limit);

Arguments:

  • $propId: id of the property by which to search (required)
  • $entityId: id of the entity (required)
  • $lang: specify the results language (default: 'en')
  • $limit: set a custom limit (default: 10)

Example:

// List of people who born in city Pomona, US
$results = $wikidata->searchBy('P19', 'Q486868');

/*
  Collection {
    #items: array:10 [
      0 => SearchResult {
        id: "Q92638"
        lang: "en"
        label: "Robert Tarjan"
        wiki_url: "https://en.wikipedia.org/wiki/Robert_Tarjan"
        description: "American computer scientist"
        aliases: array:2 [
          0 => "Robert E. Tarjan"
          1 => "Robert Endre Tarjan"
        ]
      }
      1 => SearchResult {
        id: "Q184805"
        lang: "en"
        label: "Tom Waits"
        wiki_url: "https://en.wikipedia.org/wiki/Tom_Waits"
        description: "American singer-songwriter and actor"
        aliases: []
      }
      ...
    ]
  }
*/

The searchBy() method always returns Illuminate\Support\Collection class with results. This means you can use all the methods available in Laravel's Collections.

get()

The get() returns Wikidata entity by specified ID.

$entity = $wikidata->get($entityId, $lang);

Arguments:

  • $entityId: id of the entity (required)
  • $lang: specify the results language (default: 'en')

Example:

// Get all data about Steve Jobs
$entity = $wikidata->get('Q19837');

/*
  Entity {
    id: "Q19837"
    lang: "en"
    label: "Steve Jobs"
    wiki_url: "https://en.wikipedia.org/wiki/Steve_Jobs"
    aliases: array:2 [
      0 => "Steven Jobs",
      1 => "Steven Paul Jobs"
    ]
    description: "American entrepreneur and co-founder of Apple Inc."
    properties: Collection { ... }
  }
*/


// List of all properties as an array
$properties = $entity->properties->toArray();

/*
  [
    "P1006" => Property {
      id: "P1006"
      label: "NTA ID"
      values: Collection {
        #items: array:6 [
          0 => Value {
            id: "Q5593916"
            label: "Grammy Trustees Award"
            qualifiers: Collection {
              #items: array:1 [
                0 => Qualifier {
                  id: "P585"
                  label: "point in time"
                  value: "2012-01-01T00:00:00Z"
                }
              ]
            }
          },
          ...
        ]
      }
    },
    ...
  ]
 */

Upgrade Guide

Upgrade to 3.2._ from 3.1._

The main changes in the new version have occurred in the way property values are stored. Now each property can have more than one value. In this regard, the attribute value in the Property object was replaced with the attribute values.

Also, values are now presented not as a string, but as an Value object. This allowed us to save along with each value not only its string representation but also a list of its qualifiers. Detailed information on what qualifiers is can be found here.

Testing

vendor/bin/phpunit

Contribution

If you find a bug or want to contribute to the code or documentation, you can help by submitting an issue or a pull request.

License

Wikidata is licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].