Compromise: Number parsing exceptions

Created on 8 Mar 2018  Â·  7Comments  Â·  Source: spencermountain/compromise

So far I've had pretty good results using this library to parse numbers. Unfortunately, I've started to see some odd edge cases with verbose pronunciations like:

const nlp = require('compromise')

// works
nlp('fifty five').values().toNumber().out() // 55

// doesn't work
nlp('forty eight').values().toNumber().out() // 40 8

Preventing me from using this in production... :sob:

bug next-release priority

All 7 comments

I wrote this for this very reason: https://www.npmjs.com/package/english2number

On Mar 8, 2018, at 1:29 PM, Hugh Boylan notifications@github.com wrote:

So far I've had pretty good results using this library to parse numbers. Unfortunately, I've started to see some odd edge cases with verbose pronunciations like:

const nlp = require('compromise')

// works
nlp('fifty five').values().toNumber().out() // 55

// doesn't work
nlp('forty eight').values().toNumber().out() // 40 8
Preventing me from using this in production... 😭

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Solid suggestion. This issue appears to only occur in the 40s range... Trying to figure out how to add a custom lexicon to patch this locally for now.

hey Hugh! whoa nice bug. Surprised that one got through.
I'll take a look.

hey @TSavo nice work!

hahaha
image
oops!

Ha, awesome! Wondered if that might be the case since I made the same typo a couple times.

Really appreciate you looking at this so quickly Spencer!

fixed in 11.5.3, lemme know if you see something else.
https://runkit.com/spencermountain/5aa1fbac3edbab0012da29e2
cheers

Confirmed! You're the man! :100:

nlp('forty two').values().toNumber().out() // 42
Was this page helpful?
0 / 5 - 0 ratings

Related issues

fhoffa picture fhoffa  Â·  4Comments

josephrocca picture josephrocca  Â·  5Comments

charles-toller picture charles-toller  Â·  3Comments

zeke picture zeke  Â·  3Comments

douglance picture douglance  Â·  4Comments