'use strict';
const pos = require('./parts_of_speech');
const shouldLumpThree = function(a, b, c) {
if (!a || !b || !c) {
return false;
}
const lump_rules = [
{
condition: (a.pos.Noun && b.text === '&' && c.pos.Noun),
result: 'Person',
},
{
condition: (a.pos.Noun && b.text === 'N' && c.pos.Noun),
result: 'Person',
},
{
condition: (a.pos.Date && b.normal === 'the' && c.pos.Value),
result: 'Person',
},
{
condition: (a.is_capital() && b.normal === 'of' && c.is_capital()),
result: 'Noun',
},
{
condition: (a.text.match(/^["']/) && !b.text.match(/["']/) && c.text.match(/["']$/)),
result: 'Noun',
},
{
condition: (a.normal === 'will' && b.normal === 'have' && b.pos.Verb),
result: 'FutureTense',
},
];
for(let i = 0; i < lump_rules.length; i++) {
if (lump_rules[i].condition) {
return lump_rules[i].result;
}
}
return false;
};
const shouldLumpTwo = function(a, b) {
if (!a || !b) {
return false;
}
const lump_rules = [
{
condition: (a.pos.Person && b.pos.Honourific || a.pos.Honourific && b.pos.Person),
result: 'Person',
},
{
condition: (a.pos.Honourific && b.is_capital()),
result: 'Person',
},
{
condition: (a.pos.Person && b.is_capital()),
result: 'Person',
},
{
condition: (a.pos.Date && b.pos.Value),
result: 'Date',
},
{
condition: (a.pos.Value && b.pos.Noun),
result: 'Value',
},
{
condition: (a.is_capital() && b.pos['Organisation'] || b.is_capital() && a.pos['Organisation']),
result: 'Organisation',
},
{
condition: (a.text.match(/^["']/) && b.text.match(/["']$/)),
result: 'Noun',
},
{
condition: (a.normal === 'will' && b.pos.Verb),
result: 'PerfectTense',
},
{
condition: (a.normal.match(/^will ha(ve|d)$/) && b.pos.Verb),
result: 'PluperfectTense',
},
];
for(let i = 0; i < lump_rules.length; i++) {
if (lump_rules[i].condition) {
return lump_rules[i].result;
}
}
return false;
};
const fancy_lumping = function(terms) {
for(let i = 1; i < terms.length; i++) {
let a = terms[i - 1];
let b = terms[i];
let c = terms[i + 1];