Giter Site home page Giter Site logo

data-packs's Introduction

A repository to host data packs for use in Describo. A data pack is simply a pre-defined array of JSON-LD objects that can be used as the value of a property.

Github: https://github.com/describo/data-packs

For users

Install the package

npm install --save @describo/data-packs

Loading the data packs into elastic search

For development you can start a local elastic search service with:

docker compose up -d ; docker compose logs -f ; docker compose stop ; docker compose rm -f

Then in your application you can trigger a load of all of the data packs:

const { IndexDataPacks } = require('@describo/data-packs')
const index = new IndexDataPacks({ elasticUrl: "http://localhost:9200" });
await index.load();

Or to do it once somewhere outside of your app with something like the script ./bin/index-data-packs.js

Working with the package

const { DataPack } = require('@describo/data-packs')
let datapack = new DataPack({ dataPacks: ['Austlang', 'Glottolog'], indexFields: ['@id', 'name']})
await datapack.load()


let language = datapack.get({
  field: "name",
  value: "Nyaki Nyaki / Njaki Njaki",
});

Returns a JSON-LD snippet if a match is found.

If you only want a subset of the properties try:

const { DataPack } = require('@describo/data-packs')
let datapack = new DataPack({ dataPacks: ['Austlang', 'Glottolog'], indexFields: ['@id', 'name']})
await datapack.load()


let language = datapack.get({
  field: "name",
  value: "Nyaki Nyaki / Njaki Njaki",
  properties: ['name', 'languageCode']
});

And you will get only those (along with @id and @type which are always returned).

For Developers

Working on the package - writing tests

  • start elastic search docker container: docker compose up
  • Run the tests in watch mode: npm run test:watch

Updating the JSDoc documentation

  • npm run generate-docs
  • Then commit the docs and push to github

Adding a data pack to this repository

  • add a folder in the data-packs top level folder named as your data pack.
  • create an update script inside that folder named like: create-data-pack.js.
    • Your script should be self contained and retrieve the data it needs. That is, don't check a datasource into this repo if you can avoid it. Get it from the web so that the data pack is updated from the main version online. Whatever, and wherever, that is.
  • add a reference to that script in update-all-packages.sh so that your data pack is updated when the others are.
  • document the data structure by adding a file in your data pack folder called: datapack-entry-format.js. Follow the example in languages/datapack-entry-format.js.

Building and publishing an update

  • bash ./update_all_packages.sh
  • npm run generate-docs
  • Commit all of the changes
  • Bump the version: npm version minor
  • Push to github: git push origin master --tags
  • Publish npm publish

data-packs's People

Contributors

marcolarosa avatar supertyp 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.