smcameron / space-nerds-in-space

Multi-player spaceship bridge simulator game. Captain your starship through adventures with your friends. See https://smcameron.github.io/space-nerds-in-space
GNU General Public License v2.0
724 stars 73 forks source link

spelled_numbers.c doesn't always get the right answer #360

Open smcameron opened 2 weeks ago

smcameron commented 2 weeks ago

This is an old known bug, just documenting it here.

spelled_numbers.c converts things like "one hundred" to the integer 100. It is needed because speech recognition of spoken things like "set the warp drive to 100%" results in a string like "set the warp drive to one hundred percent", and we need to extract the number out of that.

There are several test cases in spelled_numbers.c that fail:

Failed: input = 'nineteen fifty six'
    output = '75'
  expected = '1956'
Failed: input = 'it was a different time, nineteen fifty seven, fifty eight.'
    output = 'it was a different time, 76, 58.'
  expected = 'it was a different time, 1957, 58.'
Failed: input = 'twentyfour'
    output = 'twentyfour'
  expected = '24'
Failed: input = 'one hundred and ten thousand'
    output = '1000000'
  expected = '110000'

Luckily, such numbers don't often come up in the context of telling your spacecraft computer what you want it to do.