Parse 'a dozen' and 'two dozen' as numbers
This commit is contained in:
1 parent
fc63a2350d
commit
48afa5de19
3 files changed
+25
No files matched your search
@@ -37,6 +37,15 @@ export default [
|
||||
tag: 'Value',
|
||||
reason: 'a-trillion',
|
||||
},
|
||||
// two [dozen] eggs
|
||||
{ match: '(a|#Cardinal) [dozen]', hook: 'dozen', group: 0, tag: ['Multiple', 'Cardinal'], reason: 'value-dozen' },
|
||||
// with [a] dozen eggs
|
||||
{
|
||||
match: '!once? [a] dozen', hook: 'dozen',
|
||||
group: 0,
|
||||
tag: 'Value',
|
||||
reason: 'a-dozen',
|
||||
},
|
||||
// ==== PhoneNumber ====
|
||||
// 1 800 555-1234
|
||||
{ match: '(1|+1) #Value #PhoneNumber', tag: 'PhoneNumber', reason: 'country-code' },
|
||||
|
||||
@@ -83,5 +83,6 @@ export default {
|
||||
sextillion: 1e21,
|
||||
septillion: 1e24,
|
||||
grand: 1000,
|
||||
dozen: 12,
|
||||
},
|
||||
}
|
||||
@@ -45,3 +45,18 @@ test('parse numbers', function (t) {
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('parse dozen', function (t) {
|
||||
const arr = [
|
||||
['a dozen', 12],
|
||||
['two dozen eggs', 24],
|
||||
['three dozen', 36],
|
||||
['i bought a dozen eggs', 12],
|
||||
['half a dozen eggs', 6],
|
||||
]
|
||||
arr.forEach(function (a) {
|
||||
const num = nlp(a[0]).numbers().get()[0]
|
||||
t.equal(num, a[1], here + a[0])
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
Reference in new issue
Block a user