Giter Club home page Giter Club logo

ldstars's Introduction

ld-stars

This is no longer maintained, use @scienceai/ui instead.


Rate (as in five stars linked data) a schema.org document in JSON-LD.


Background

Developed by Tim Berners-Lee, the purpose of the 5-star rating system is to encourage adoption of best linked open data practices. Here are the requirements, taken from his original proposal:

★ Available on the web (whatever format) but with an open licence, to be Open Data

★★ Available as machine-readable structured data (e.g. excel instead of image scan of a table)

★★★ as (2) plus non-proprietary format (e.g. CSV instead of excel)

★★★★ All the above plus, Use open standards from W3C (RDF and SPARQL) to identify things, so that people can point at your stuff

★★★★★ All the above, plus: Link your data to other people’s data to provide context

API

import * as ldstars from 'ldstars';

ldstars.rate(doc [, opts])

Rates a schema.org CreativeWork JSON-LD document.

opts include string: true.

returns a rating object.

{
  ol: true,
  of: true,
  re: true,
  uri: true,
  ld: true
}
  • ol: open license
  • of: open format
  • re: machine readable
  • uri: uniform resource identifiers
  • ld: linked data

ldstars.toString(rating)

Converts a rating object to a string:

ldstars.toString({ ol: false, of: false, re: true, uri:false, ld: true })

returns 're-ld'.

ldstars's People

Contributors

adamdonahue avatar callahanchris avatar sballesteros avatar transcranial avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

sato-shi

ldstars's Issues

undefined is not a function

index.js line 99 uses forEach() to iterate over different types of resources in a package. This throws an error unless pkg[*resoureName*] is an array.

expose `toNumber` function as part of API

In using this package, I've found that a common use case is simply getting a number rating. As such, I've wound up writing this similar code a number of times:

var ldstars = require('ldstars');
var ldVerbose = ldstars.rate(encoding);
var ldRating = Object.keys(ldVerbose).reduce(function(prev, curr) {
  return (ldVerbose[curr] && (prev + 1)) || prev;
}, 0);

It seems reasonable enough to expose this as part of the ldstars API. I imagine it would look something like this:

var ldstars = require('ldstars');
var ldRating = ldstars.toNumber(ldstars.rate(encoding));

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.