UNPKG

psuk-parliament

Version:

A library by PublicScrutiny.UK to make it easier to get information from the UK Parliament

45 lines (40 loc) 1.25 kB
var parliament = require('./index'); util = require('util'), BBCThings = require('bbc-things'), gramophone = require('gramophone'); // Get all bills from Parliament parliament.bills.getBills() .then(function(bills) { bills.forEach(function(bill, index, array) { bill.getFullBill() .then(function(fullBill) { // Not all Bills have text published (some are pending) if (!fullBill.text) return; // Get tags from bill text var gramophoneOptions = { score: false, stopWords: [], limit: 20, ngrams: [1,2,3], stem: true }; var entities = gramophone.extract(bill.name+" "+bill.description+" "+fullBill.text, gramophoneOptions); // Find corresponding BBC Things with the same name as entities BBCThings.search(entities,true) .then(function(things) { if (things) { var tags = {}; for (var thing in things) { if (things[thing].length > 0) tags[thing] = things[thing]; } if (Object.keys(tags).length > 0) { console.log("Tags for "+bill.name+":"); console.log(tags); } } }); }); }); });