Entitree Helper
Super awesome helper function for Entitree projects. But anyone can use them.
Source Code:
https://github.com/codeledge/entitree-monorepo/tree/main/packages/entitree-helper
Prerequisites
This project requires NodeJS (version 8 or later) and NPM.
please use either:
$ npm install @entitree/helper
or
$ yarn add @entitree/helper
Table of contents
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Usage
useBasicFetch
import { getWikidataSparql } from "@entitree/helper";
let query = await getWikidataSparql(`#Goats
SELECT ?item ?itemLabel
WHERE
{
?item wdt:P31 wd:Q2934.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}`);
console.log(query);
getSimplifiedWikidataEntities
let query = await getSimplifiedWikidataEntities(["Q110903311"]));
console.log(query);
use constants instead of Wikidata IDS and properties
use WD_POSITION_HELD instead of "P39" to make your code look cleaner.
just type WD_ in your code editor to get suggestions.
getWikipediaArticle
let article = getWikipediaArticle("Germany", "en");
console.log(article);
Notes
How to sort by Wikidata ID
ORDER BY (xsd:integer(substr(str(?item),33)))
Any better idea?
Recreate constantsfile:
cd packages/entitree-helper/src/wikidata/scripts
ts-node-transpile-only createConstantsFile.ts
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Add your changes:
git add .
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request
😎
Credits
Versioning
Authors
Martin and Orlando
License
MIT License