npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bbc-things

v1.0.4

Published

An unoffical client for the BBC Things Linked Data Platform

Downloads

4

Readme

BBC Things

http://www.bbc.co.uk/things/

This is an unoffical client for the BBC Things Linked Data Platform.

You can pass a string (or an array of strings) and get back matching Things from a search query. You can then fetch extended properties for any Thing.

You might want to combine it with something like the npm module gramophone to do entity extraction on bodies of text and find relevant Things to tag content with.

Passing a string

var BBCThings = require('bbc-things');
var text = "David Cameron";
BBCThings.search(text)
.then(function(things) {
    console.log(things);
});

Example response object

[ { label: 'David Cameron',
    hint: 'Politician',
    uri: 'http://www.bbc.co.uk/things/ed9d1ef3-eded-4f81-b158-be49cfc1ea8f#id',
    properties: [Function] } ]

Passing an array of strings

var BBCThings = require('bbc-things');
var arrayOfStrings = ["Kenya", "Nairobi"];
BBCThings.search(arrayOfStrings)
.then(function(things) {
    console.log(things);
});

Example response object

{ Kenya: 
   [ { label: 'Kenya',
       hint: 'Kenya',
       uri: 'http://www.bbc.co.uk/things/7d7c35fa-f724-4b36-90a0-21f71d99857d#id',
       properties: [Function] },
     { label: 'Jomo Kenyatta',
       hint: 'Politician',
       uri: 'http://www.bbc.co.uk/things/d760ca99-2b63-499e-9be5-8aab0b64ca6e#id',
       properties: [Function] },
     { label: 'Uhuru Kenyatta',
       hint: 'Kenyan politician.',
       uri: 'http://www.bbc.co.uk/things/f9e4f58f-cb89-46b6-ab75-e44e84229404#id',
       properties: [Function] } ],
  Nairobi: 
   [ { label: 'Nairobi',
       hint: 'Kenya',
       uri: 'http://www.bbc.co.uk/things/bfe2de9d-fde7-4781-89ca-1735ede10982#id',
       properties: [Function] } ] 
}

Additional properties

You can access additional information by calling .properties() on a Thing.

The properties vary depending on the entity (e.g. places have lat/lon properties).

var BBCThings = require('bbc-things');
BBCThings.search("Ed Miliband")
.then(function(things) {
    thing[0].properties()
    .then(function(properties) {
        console.log ( properties );        
    });
});

Example .properties() response object

[ { label: 'Ed Miliband',
    hint: 'Politician',
    uri: 'http://www.bbc.co.uk/things/b13fa1f6-2799-404f-bfae-91632ec66b10#id',
    properties: [Function] } ]
{ '@id': 'http://www.bbc.co.uk/things/b13fa1f6-2799-404f-bfae-91632ec66b10#id',
  '@type': 
   [ 'owl:Thing',
     'ManagedThing',
     'Thing',
     'Person',
     'rdfs:Resource',
     'tagging:TagConcept',
     'tag:TagConcept' ],
  disambiguationHint: 'Politician',
  label: 'Ed Miliband',
  preferredLabel: 'Ed Miliband',
  primaryTopicOf: 
   [ 'http://en.wikipedia.org/wiki/Ed_Miliband',
     'http://news.bbc.co.uk/democracylive/hi/representatives/profiles/40791.stm',
     'http://www.edmiliband.org',
     'http://www.guardian.co.uk/politics/person/8711/' ],
  sameAs: 
   [ 'http://dbpedia.org/resource/Ed_Miliband',
     'http://rdf.freebase.com/ns/m.04qdjv',
     'http://www.wikidata.org/entity/Q216594' ] }

Requesting exact matches only

If if you want to return Things who's labels are exact matches only (ignoring case sensitivity) then you can pass 'true' as the second parameter to instruct it to return 'exact matches only'.

For example, if you want to get the Thing for "Kenya", but were not interested in the data for Kenyan Politican "Uhuru Kenyatta" returned you could do this:

var BBCThings = require('bbc-things');
BBCThings.search("Kenya", true)
.then(function(things) {
    console.log(things);
});

Contributions and thanks

This is a very simple library and is entirely unoffical and was not created by the folks who've created the excellent BBC Things site which it uses.

It was created to make it easier to do experiments with linked data and to try out different approaches to entity extraction.