Skip to content

Instantly share code, notes, and snippets.

@iaincollins
Last active August 29, 2015 14:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iaincollins/4ca7c10643e5611b7073 to your computer and use it in GitHub Desktop.
Save iaincollins/4ca7c10643e5611b7073 to your computer and use it in GitHub Desktop.
Combining UK Parliament data + NLP + BBC Things in node.js to tag Bills by topic
Tags for Employment Practices Bill:
{ 'Scottish Parliament':
{ label: 'Scottish Parliament',
hint: 'The Scottish Parliament is the devolved national, unicameral legislature of Scotland, located in the Holyrood area of the capital, Edinburgh. ',
uri: 'http://www.bbc.co.uk/things/59ab9b46-cb29-4394-bea7-59b2d6c74bc2#id',
properties: [Function] },
Wales:
{ label: 'Wales',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/00eb010f-568a-4b89-bbfe-799d5b812bed#id',
properties: [Function] },
'United Kingdom':
{ label: 'United Kingdom',
hint: 'United Kingdom',
uri: 'http://www.bbc.co.uk/things/2e91364c-5c77-4660-b76e-d76202785e64#id',
properties: [Function] } }
--
Tags for Online Safety Bill:
{ internet:
{ label: 'Internet',
hint: 'Interconnected computer networks.',
uri: 'http://www.bbc.co.uk/things/72d243a7-687b-4e7d-a022-1e36a138b0be#id',
properties: [Function] },
OFCOM:
{ label: 'Ofcom',
hint: 'The government-approved regulatory and competition authority for the broadcasting, telecommunications and postal industries of the United Kingdom.',
uri: 'http://www.bbc.co.uk/things/b875112e-d866-4ad2-8993-8038a54ac1f1#id',
properties: [Function] },
'United Kingdom':
{ label: 'United Kingdom',
hint: 'United Kingdom',
uri: 'http://www.bbc.co.uk/things/2e91364c-5c77-4660-b76e-d76202785e64#id',
properties: [Function] } }
--
Tags for Abortion Act 1967 (Amendment) Bill:
{ Abortion:
{ label: 'Abortion',
hint: 'Ending of pregnancy by the removal of a fetus from the uterus before viability.',
uri: 'http://www.bbc.co.uk/things/f16883ee-804f-43cd-8bc3-80d0fed59682#id',
properties: [Function] },
pregnancy:
{ label: 'Pregnancy',
hint: 'Period when a woman develops a baby in her womb. ',
uri: 'http://www.bbc.co.uk/things/bae407a9-57d7-473c-a2c7-e13d00bc38b1#id',
properties: [Function] } }
--
Tags for Deregulation Bill:
{ England:
{ label: 'England',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/9ba4d1e5-7cc7-48c0-9793-ad198403c54c#id',
properties: [Function] },
Wales:
{ label: 'Wales',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/00eb010f-568a-4b89-bbfe-799d5b812bed#id',
properties: [Function] } }
--
Tags for Serious Crime Bill:
{ Scotland:
{ label: 'Scotland',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/21628be8-a6f7-42d7-88f4-c3d85b148e09#id',
properties: [Function] },
'Northern Ireland':
{ label: 'Northern Ireland',
hint: 'National football team',
uri: 'http://www.bbc.co.uk/things/c1419a1e-ebc7-4c00-9073-12ed4f0e99de#id',
properties: [Function] },
Wales:
{ label: 'Wales',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/00eb010f-568a-4b89-bbfe-799d5b812bed#id',
properties: [Function] } }
--
Tags for High-cost Credit Agreements (Advertising Restrictions) Bill:
{ broadcast:
{ label: 'Broadcast',
hint: 'UK electronic music band on Warp Records',
uri: 'http://www.bbc.co.uk/things/b53a1518-50d6-474e-a044-9d2caad99dca#id',
properties: [Function] } }
--
Tags for Cohabitation Rights Bill:
{ Family:
{ label: 'Family',
hint: 'Group of people related by blood, through marriage or co-residence.',
uri: 'http://www.bbc.co.uk/things/184cb2f7-e305-4c46-ab4f-2e18f60b0293#id',
properties: [Function] } }
--
Tags for Divorce (Financial Provision) Bill:
{ family:
{ label: 'Family',
hint: 'Group of people related by blood, through marriage or co-residence.',
uri: 'http://www.bbc.co.uk/things/184cb2f7-e305-4c46-ab4f-2e18f60b0293#id',
properties: [Function] } }
--
Tags for Duchy of Cornwall Bill:
{ Cornwall:
{ label: 'Cornwall',
hint: 'England, Cornwall, GB',
uri: 'http://www.bbc.co.uk/things/c33bdab8-90e8-49f4-b945-1e96c57611a6#id',
properties: [Function] } }
--
Tags for Assisted Dying Bill:
{ medicine:
{ label: 'Medicine',
hint: 'Discovery, development and evaluation of medicines.',
uri: 'http://www.bbc.co.uk/things/918e9487-dc88-44e2-8168-057149670ec3#id',
properties: [Function] },
Wales:
{ label: 'Wales',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/00eb010f-568a-4b89-bbfe-799d5b812bed#id',
properties: [Function] } }
--
Tags for Land Value Tax Bill:
{ England:
{ label: 'England',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/9ba4d1e5-7cc7-48c0-9793-ad198403c54c#id',
properties: [Function] } }
--
Tags for Arbitration and Mediation Services (Equality) Bill:
{ 'domestic abuse':
{ label: 'Domestic Abuse',
hint: 'physical or mental abuse within families.',
uri: 'http://www.bbc.co.uk/things/22d5dbb6-b5f5-4a5b-be0f-ded92f7e6a2e#id',
properties: [Function] } }
--
Tags for Succession to Peerages Bill:
{ law:
{ label: 'Law',
hint: 'South Lanarkshire, Scotland, United Kingdom',
uri: 'http://www.bbc.co.uk/things/c5384b5a-a7c8-4daa-b5d8-5077c14d7684#id',
properties: [Function] } }
--
Tags for High Speed Rail (London - West Midlands) Bill:
{ infrastructure:
{ label: 'Infrastructure',
hint: 'Structures needed for the operation of a society or enterprise.',
uri: 'http://www.bbc.co.uk/things/d716fd26-4bcc-411e-93ab-3272db12ea6b#id',
properties: [Function] } }
--
Tags for Governance of Sport Bill:
{ Sport:
{ label: 'Sport',
hint: '',
uri: 'http://www.bbc.co.uk/things/4063f80f-cccc-44c8-9449-5ca44e4c8592#id',
properties: [Function] },
Advertising:
{ label: 'Advertising',
hint: 'Marketing communication used to encourage, persuade, or manipulate an audience.',
uri: 'http://www.bbc.co.uk/things/3d303e09-05ad-4f46-89fb-4ff9921219a7#id',
properties: [Function] },
trade:
{ label: 'Trade',
hint: 'the transfer of ownership of goods and services from one person or entity to another by getting something in exchange from the buyer',
uri: 'http://www.bbc.co.uk/things/cec5d136-f83d-4e00-a3be-d22a7b89401f#id',
properties: [Function] } }
--
Tags for European Union (Information, etc.) Bill:
{ 'European Union':
{ label: 'European Union',
hint: 'an economic and political union of 28 member states',
uri: 'http://www.bbc.co.uk/things/9a18805c-fb88-40ba-9763-bcc121d5d55c#id',
properties: [Function] } }
--
Tags for Small Business, Enterprise and Employment Bill:
{ Employment:
{ label: 'Employment',
hint: 'Work, including internships, apprenticeships and the labour market.',
uri: 'http://www.bbc.co.uk/things/ee4d5541-afdc-4511-9ba6-a42823b19429#id',
properties: [Function] },
Business:
{ label: 'Business',
hint: 'commercial activity of an organisation or individual',
uri: 'http://www.bbc.co.uk/things/2f2db234-3c2d-40a4-b4ac-eea661faadd0#id',
properties: [Function] } }
--
Tags for National Insurance Contributions Bill:
{ employment:
{ label: 'Employment',
hint: 'Work, including internships, apprenticeships and the labour market.',
uri: 'http://www.bbc.co.uk/things/ee4d5541-afdc-4511-9ba6-a42823b19429#id',
properties: [Function] } }
--
Tags for European Union (Referendum) Bill:
{ 'European Union':
{ label: 'European Union',
hint: 'an economic and political union of 28 member states',
uri: 'http://www.bbc.co.uk/things/9a18805c-fb88-40ba-9763-bcc121d5d55c#id',
properties: [Function] },
Gibraltar:
{ label: 'Gibraltar',
hint: 'Gibraltar',
uri: 'http://www.bbc.co.uk/things/64c5e95e-0254-49fb-b6b1-94d17a2f4c4f#id',
properties: [Function] },
law:
{ label: 'Law',
hint: 'South Lanarkshire, Scotland, United Kingdom',
uri: 'http://www.bbc.co.uk/things/c5384b5a-a7c8-4daa-b5d8-5077c14d7684#id',
properties: [Function] } }
--
Tags for Wild Animals in Circuses Bill:
{ justice:
{ label: 'Justice',
hint: 'French electro house, Gaspard Augé & Xavier de Rosnay',
uri: 'http://www.bbc.co.uk/things/c441aada-23ee-4476-a915-581143c6a769#id',
properties: [Function] } }
--
Tags for Defence Expenditure (NATO Target) Bill:
{ 'United Kingdom':
{ label: 'United Kingdom',
hint: 'United Kingdom',
uri: 'http://www.bbc.co.uk/things/2e91364c-5c77-4660-b76e-d76202785e64#id',
properties: [Function] },
NATO:
{ label: 'Nato',
hint: 'an intergovernmental military alliance based on the North Atlantic Treaty',
uri: 'http://www.bbc.co.uk/things/b330e2a5-9d88-4e62-a688-c6d5f4987708#id',
properties: [Function] },
March:
{ label: 'March',
hint: 'Cambridgeshire, England, United Kingdom',
uri: 'http://www.bbc.co.uk/things/39e6c90c-1f26-4bc1-81aa-c9f8a690e3e7#id',
properties: [Function] } }
--
Tags for Welfare of Cats Bill:
{ 'Queen Elizabeth II':
{ label: 'Queen Elizabeth II',
hint: 'Monarch of 16 Commonwealth countries, including the UK',
uri: 'http://www.bbc.co.uk/things/1ff657f2-0bc9-4172-a198-fda306e611f4#id',
properties: [Function] } }
--
Tags for Pavement Parking Bill:
{ infrastructure:
{ label: 'Infrastructure',
hint: 'Structures needed for the operation of a society or enterprise.',
uri: 'http://www.bbc.co.uk/things/d716fd26-4bcc-411e-93ab-3272db12ea6b#id',
properties: [Function] },
England:
{ label: 'England',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/9ba4d1e5-7cc7-48c0-9793-ad198403c54c#id',
properties: [Function] },
Wales:
{ label: 'Wales',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/00eb010f-568a-4b89-bbfe-799d5b812bed#id',
properties: [Function] } }
--
Tags for Recall of Elected Representatives Bill:
{ 'Northern Ireland':
{ label: 'Northern Ireland',
hint: 'National football team',
uri: 'http://www.bbc.co.uk/things/c1419a1e-ebc7-4c00-9073-12ed4f0e99de#id',
properties: [Function] } }
--
Tags for EU Membership (Audit of Costs and Benefits) Bill:
{ Benefits:
{ label: 'Benefits',
hint: 'welfare payments such as Universal Credit, Child Benefit, Unemployment Benefit, etc',
uri: 'http://www.bbc.co.uk/things/128555c7-c736-4e5d-b8aa-e016bd44a251#id',
properties: [Function] },
'European Union':
{ label: 'European Union',
hint: 'an economic and political union of 28 member states',
uri: 'http://www.bbc.co.uk/things/9a18805c-fb88-40ba-9763-bcc121d5d55c#id',
properties: [Function] },
trade:
{ label: 'Trade',
hint: 'the transfer of ownership of goods and services from one person or entity to another by getting something in exchange from the buyer',
uri: 'http://www.bbc.co.uk/things/cec5d136-f83d-4e00-a3be-d22a7b89401f#id',
properties: [Function] } }
--
Tags for Specialist Printing Equipment and Materials (Offences) Bill:
{ 'United Kingdom':
{ label: 'United Kingdom',
hint: 'United Kingdom',
uri: 'http://www.bbc.co.uk/things/2e91364c-5c77-4660-b76e-d76202785e64#id',
properties: [Function] },
Wales:
{ label: 'Wales',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/00eb010f-568a-4b89-bbfe-799d5b812bed#id',
properties: [Function] },
England:
{ label: 'England',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/9ba4d1e5-7cc7-48c0-9793-ad198403c54c#id',
properties: [Function] } }
--
Tags for House of Lords (Maximum Membership) Bill:
{ peer:
{ label: 'Peer',
hint: '',
uri: 'http://www.bbc.co.uk/things/2e7d10c6-47cd-4b6a-bd71-9aaafa79bf83#id',
properties: [Function] } }
--
Tags for Affordable Homes Bill:
{ disability:
{ label: 'Disability',
hint: 'Impairments that may be physical, cognitive, mental, sensory, emotional or developmental.',
uri: 'http://www.bbc.co.uk/things/a1c14222-e7ab-45a2-a074-3cdc1045607c#id',
properties: [Function] },
law:
{ label: 'Law',
hint: 'South Lanarkshire, Scotland, United Kingdom',
uri: 'http://www.bbc.co.uk/things/c5384b5a-a7c8-4daa-b5d8-5077c14d7684#id',
properties: [Function] } }
--
Tags for Freedom of Information (Amendment) Bill:
{ NHS:
{ label: 'NHS',
hint: 'Publicly funded healthcare system within the United Kingdom. ',
uri: 'http://www.bbc.co.uk/things/90a7bae1-8eda-4f6d-b2fe-41a301a93ebb#id',
properties: [Function] } }
--
Tags for Health and Social Care (Safety and Quality) Bill:
{ Healthcare:
{ label: 'Healthcare',
hint: 'Provision of medical care.',
uri: 'http://www.bbc.co.uk/things/27a675ec-1a68-4f13-b498-a77ee2bacbdc#id',
properties: [Function] },
'Social Care':
{ label: 'Social care',
hint: 'Provision of care arising from illness, disability, old age or poverty',
uri: 'http://www.bbc.co.uk/things/ea752b0c-c27c-4498-8cba-bc962f1b14b1#id',
properties: [Function] },
England:
{ label: 'England',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/9ba4d1e5-7cc7-48c0-9793-ad198403c54c#id',
properties: [Function] } }
--
Tags for Road Traffic Regulation (Temporary Closure for Filming) Bill:
{ infrastructure:
{ label: 'Infrastructure',
hint: 'Structures needed for the operation of a society or enterprise.',
uri: 'http://www.bbc.co.uk/things/d716fd26-4bcc-411e-93ab-3272db12ea6b#id',
properties: [Function] },
Wales:
{ label: 'Wales',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/00eb010f-568a-4b89-bbfe-799d5b812bed#id',
properties: [Function] },
England:
{ label: 'England',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/9ba4d1e5-7cc7-48c0-9793-ad198403c54c#id',
properties: [Function] } }
--
Tags for Football Governance Bill:
{ Football:
{ label: 'Football',
hint: 'Sports discipline',
uri: 'http://www.bbc.co.uk/things/ba6e1118-f874-054e-b159-b797c16e9250#id',
properties: [Function] },
England:
{ label: 'England',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/9ba4d1e5-7cc7-48c0-9793-ad198403c54c#id',
properties: [Function] } }
--
Tags for International Development (Official Development Assistance Target) Bill:
{ 'United Kingdom':
{ label: 'United Kingdom',
hint: 'United Kingdom',
uri: 'http://www.bbc.co.uk/things/2e91364c-5c77-4660-b76e-d76202785e64#id',
properties: [Function] } }
--
Tags for Off-patent Drugs Bill:
{ Healthcare:
{ label: 'Healthcare',
hint: 'Provision of medical care.',
uri: 'http://www.bbc.co.uk/things/27a675ec-1a68-4f13-b498-a77ee2bacbdc#id',
properties: [Function] },
steps:
{ label: 'Steps',
hint: 'Music Group',
uri: 'http://www.bbc.co.uk/things/59e2f080-be9f-4826-b712-65f69a7a7758#id',
properties: [Function] } }
--
Tags for Local Government (Religious etc. Observances) Bill:
{ Healthcare:
{ label: 'Healthcare',
hint: 'Provision of medical care.',
uri: 'http://www.bbc.co.uk/things/27a675ec-1a68-4f13-b498-a77ee2bacbdc#id',
properties: [Function] },
England:
{ label: 'England',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/9ba4d1e5-7cc7-48c0-9793-ad198403c54c#id',
properties: [Function] },
Transport:
{ label: 'Transport',
hint: 'System or means of transport.',
uri: 'http://www.bbc.co.uk/things/d5d64ac6-fffe-4ae1-9491-38bcadac2563#id',
properties: [Function] },
Wales:
{ label: 'Wales',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/00eb010f-568a-4b89-bbfe-799d5b812bed#id',
properties: [Function] },
London:
{ label: 'London',
hint: 'EU Constituency',
uri: 'http://www.bbc.co.uk/things/d9b3c9c1-3004-42c9-8b09-2eb9c6453882#id',
properties: [Function] },
Temple:
{ label: 'Temple',
hint: 'Midlothian, Scotland, United Kingdom',
uri: 'http://www.bbc.co.uk/things/05596aec-c785-4334-8582-74ace0501b70#id',
properties: [Function] } }
--
Tags for Armed Forces (Prevention of Discrimination) (No. 2) Bill:
{ family:
{ label: 'Family',
hint: 'Group of people related by blood, through marriage or co-residence.',
uri: 'http://www.bbc.co.uk/things/184cb2f7-e305-4c46-ab4f-2e18f60b0293#id',
properties: [Function] } }
--
Tags for Zero Hours Contracts Bill:
{ refused:
{ label: 'Refused',
hint: 'Music Group',
uri: 'http://www.bbc.co.uk/things/5e0450cb-9295-4bcf-a20a-0395a3acb7e7#id',
properties: [Function] } }
--
Tags for Benefit Entitlement (Restriction) Bill:
{ 'European Union':
{ label: 'European Union',
hint: 'an economic and political union of 28 member states',
uri: 'http://www.bbc.co.uk/things/9a18805c-fb88-40ba-9763-bcc121d5d55c#id',
properties: [Function] } }
--
Tags for Low Pay Commission (National Minimum Wage) Bill:
{ economy:
{ label: 'Economy',
hint: 'The global economy and economics',
uri: 'http://www.bbc.co.uk/things/ca170ae3-99c1-48db-9b67-2866f85e7342#id',
properties: [Function] } }
--
Tags for Counter-Terrorism and Security Bill:
{ 'United Kingdom':
{ label: 'United Kingdom',
hint: 'United Kingdom',
uri: 'http://www.bbc.co.uk/things/2e91364c-5c77-4660-b76e-d76202785e64#id',
properties: [Function] } }
--
Tags for Counsellors and Psychotherapists (Regulation) Bill:
{ Healthcare:
{ label: 'Healthcare',
hint: 'Provision of medical care.',
uri: 'http://www.bbc.co.uk/things/27a675ec-1a68-4f13-b498-a77ee2bacbdc#id',
properties: [Function] },
children:
{ label: 'Children',
hint: 'Childcare, childhood, education, development, child welfare.',
uri: 'http://www.bbc.co.uk/things/992e096e-28e6-412d-b6a1-652f78be63c7#id',
properties: [Function] } }
--
Tags for Tenancies (Reform) Bill:
{ England:
{ label: 'England',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/9ba4d1e5-7cc7-48c0-9793-ad198403c54c#id',
properties: [Function] } }
--
Tags for United Kingdom Parliament (Sovereignty and Jurisdiction over Borders) Bill:
{ 'European Union':
{ label: 'European Union',
hint: 'an economic and political union of 28 member states',
uri: 'http://www.bbc.co.uk/things/9a18805c-fb88-40ba-9763-bcc121d5d55c#id',
properties: [Function] },
'United Kingdom':
{ label: 'United Kingdom',
hint: 'United Kingdom',
uri: 'http://www.bbc.co.uk/things/2e91364c-5c77-4660-b76e-d76202785e64#id',
properties: [Function] },
'Queen Elizabeth II':
{ label: 'Queen Elizabeth II',
hint: 'Monarch of 16 Commonwealth countries, including the UK',
uri: 'http://www.bbc.co.uk/things/1ff657f2-0bc9-4172-a198-fda306e611f4#id',
properties: [Function] } }
--
Tags for Self-build and Custom Housebuilding Bill:
{ England:
{ label: 'England',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/9ba4d1e5-7cc7-48c0-9793-ad198403c54c#id',
properties: [Function] } }
--
Tags for Control of Horses Bill:
{ England:
{ label: 'England',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/9ba4d1e5-7cc7-48c0-9793-ad198403c54c#id',
properties: [Function] },
infrastructure:
{ label: 'Infrastructure',
hint: 'Structures needed for the operation of a society or enterprise.',
uri: 'http://www.bbc.co.uk/things/d716fd26-4bcc-411e-93ab-3272db12ea6b#id',
properties: [Function] },
Animals:
{ label: 'Animals',
hint: 'Domestic and wild animals. ',
uri: 'http://www.bbc.co.uk/things/14745d1f-885d-4b9f-b28a-24540e7beb15#id',
properties: [Function] } }
--
Tags for Regulation of Political Opinion Polling Bill:
{ 'United Kingdom':
{ label: 'United Kingdom',
hint: 'United Kingdom',
uri: 'http://www.bbc.co.uk/things/2e91364c-5c77-4660-b76e-d76202785e64#id',
properties: [Function] },
'Northern Ireland Assembly':
{ label: 'Northern Ireland Assembly',
hint: 'The Northern Ireland Assembly is the devolved legislature of Northern Ireland.',
uri: 'http://www.bbc.co.uk/things/ff29164c-bdbe-47d9-8dab-7fba71287964#id',
properties: [Function] },
'Scottish Parliament':
{ label: 'Scottish Parliament',
hint: 'The Scottish Parliament is the devolved national, unicameral legislature of Scotland, located in the Holyrood area of the capital, Edinburgh. ',
uri: 'http://www.bbc.co.uk/things/59ab9b46-cb29-4394-bea7-59b2d6c74bc2#id',
properties: [Function] } }
--
Tags for Corporation Tax (Northern Ireland) Bill:
{ 'Northern Ireland':
{ label: 'Northern Ireland',
hint: 'National football team',
uri: 'http://www.bbc.co.uk/things/c1419a1e-ebc7-4c00-9073-12ed4f0e99de#id',
properties: [Function] },
trade:
{ label: 'Trade',
hint: 'the transfer of ownership of goods and services from one person or entity to another by getting something in exchange from the buyer',
uri: 'http://www.bbc.co.uk/things/cec5d136-f83d-4e00-a3be-d22a7b89401f#id',
properties: [Function] } }
--
Tags for Local Government (Review of Decisions) Bill:
{ England:
{ label: 'England',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/9ba4d1e5-7cc7-48c0-9793-ad198403c54c#id',
properties: [Function] } }
--
Tags for Working Time Directive (Limitation) Bill:
{ 'Northern Ireland':
{ label: 'Northern Ireland',
hint: 'National football team',
uri: 'http://www.bbc.co.uk/things/c1419a1e-ebc7-4c00-9073-12ed4f0e99de#id',
properties: [Function] },
England:
{ label: 'England',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/9ba4d1e5-7cc7-48c0-9793-ad198403c54c#id',
properties: [Function] } }
--
Tags for Medical Innovation Bill:
{ law:
{ label: 'Law',
hint: 'South Lanarkshire, Scotland, United Kingdom',
uri: 'http://www.bbc.co.uk/things/c5384b5a-a7c8-4daa-b5d8-5077c14d7684#id',
properties: [Function] } }
--
Tags for Overseas Voters Bill:
{ internet:
{ label: 'Internet',
hint: 'Interconnected computer networks.',
uri: 'http://www.bbc.co.uk/things/72d243a7-687b-4e7d-a022-1e36a138b0be#id',
properties: [Function] },
cast:
{ label: 'Cast',
hint: 'British indie band',
uri: 'http://www.bbc.co.uk/things/b594f5a4-b651-45cb-a8da-546fadf3c3a5#id',
properties: [Function] } }
--
Tags for Lords Spiritual (Women) Bill:
{ England:
{ label: 'England',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/9ba4d1e5-7cc7-48c0-9793-ad198403c54c#id',
properties: [Function] } }
--
Tags for National Health Service (Amended Duties and Powers) Bill:
{ NHS:
{ label: 'NHS',
hint: 'Publicly funded healthcare system within the United Kingdom. ',
uri: 'http://www.bbc.co.uk/things/90a7bae1-8eda-4f6d-b2fe-41a301a93ebb#id',
properties: [Function] },
'Social Care':
{ label: 'Social care',
hint: 'Provision of care arising from illness, disability, old age or poverty',
uri: 'http://www.bbc.co.uk/things/ea752b0c-c27c-4498-8cba-bc962f1b14b1#id',
properties: [Function] },
England:
{ label: 'England',
hint: 'a nation of the United Kingdom of Great Britain and Northern Ireland',
uri: 'http://www.bbc.co.uk/things/9ba4d1e5-7cc7-48c0-9793-ad198403c54c#id',
properties: [Function] } }
--
var request = require('request'),
BBCThings = require('bbc-things'),
gramophone = require('gramophone'),
request = require('request'),
Q = require('q');
request({ url: 'http://public-scrutiny-office.org/bills.json', timeout: 2000 }, function(error, response, body) {
var bills = JSON.parse(body);
for (var bill in bills) {
getTagsForBill(bills[bill])
.then(function(bill) {
if (Object.keys(bill.tags).length == 0) {
return;
}
});
}
});
function getTagsForBill(bill) {
var deferred = Q.defer();
var promise = request(bill.textUrl, function (error, response, body) {
var deferred2 = Q.defer();
var text = bill.name+" "+bill.description+" "+body;
// Get tags from text
var gramophoneOptions = { score: false,
stopWords: ['bill', 'parliament', 'paragraph', 'a', 'b', 'c', 'act', 'sheet'],
limit: 50,
ngrams: [1,2,3],
stem: true
};
var entities = gramophone.extract(text, gramophoneOptions);
entities.forEach(function(entity, i) {
// Overrides for common tag mis-matches
if (entity.match(/^health$/i))
entities[i] = "Healthcare";
if (entity.match(/^(pavement|street|highway|bridge|traffic)$/i))
entities[i] = "infrastructure";
if (entity.match(/^queen$/i))
entities[i] = "Queen Elizabeth II";
});
var promise2 = BBCThings.search(entities,true)
.then(function(things) {
var entities = [];
var validThings = {};
if (things) {
for (var thing in things) {
entities.push(thing);
if (things[thing].length > 0)
validThings[thing] = things[thing][0];
}
}
bill.tags = validThings;
bill.rawTags = entities;
if (Object.keys(bill.tags).length > 0) {
console.log("Tags for "+bill.name+" Bill:");
console.log(bill.tags);
console.log('--');
}
deferred2.resolve(bill);
});
return deferred2.promise;
});
deferred.resolve(promise);
return deferred.promise;
}
@iaincollins
Copy link
Author

This snippet shows how you can combine the 'bbc-things' NPM package with something like 'gramophone' to identify potential tags for content (in this case, Bills in the UK Parliament).

This approach does not attempt disambiguation bearing in mind the context of the text, so it will often suggest inappropriate "things". There are a couple of problems that often come up in particular:

  • There are large number of entities in BBC Things for (often obscure) music bands with names that are also common relative words (e.g. "Pavement" or "Street").
  • There are some entities that have labels that exactly match names of countries or places. e.g. there is a Thing with the label "Russia" (the national football team) as well as "Russia" (the country).

I'm interested in seeing if there are any quick and dirty approaches to disambiguation for common howlers that might improve behaviour when "best guessing" what appropriate tags might be when there is ambiguity. This may include a mix of whitelisting, blacklisting and/or scoring.

Note: The attempt here is not to re-invent something like the BBC R&D tool Mango automated tagging system (which is much more sophisticated), but to see if it's possible to have a "poor mans Mango" for prototyping and experimenting quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment