@entitree/helper
v0.8.0
Published
> Super awesome helper function for Entitree projects. But anyone can use them.
Downloads
337
Readme
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/helperor
$ yarn add @entitree/helperTable 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.tsContributing
- 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 :sunglasses:
Credits
Versioning
Authors
Martin and Orlando
License
MIT License
