Git Product home page Git Product logo

Comments (3)

brandonhorst avatar brandonhorst commented on June 17, 2024

This is an issue that I struggle with myself. Lacona Output is designed primarily to describe an interface, not necessarily raw data... so testing it is not always natural.

For https://github.com/lacona/lacona-phrase-datetime, assume that for each "complete" input, there is one "correct" output. That is, if the user has entered a full phrase, there should be no ambiguity there. Because I make that assumption, I just

  1. Filter out all of the outputs that have placeholder words in them, because these are not complete.
  2. Verify that there is only one output
  3. Compare result value
  4. Compare the raw text of the output to make sure that it is the same as the input, using
function text (input) {
  return _.map(input.words, 'text').join('')
}

Example here

Of course, this has some issues. It doesn't work to test what lacona outputs as the user is typing. And it doesn't work for cases like yours, where a valid input "10 mi" could be the initial substring of another valid input "10 mile".

In your case, I would actually modify your phrase and add a limit to your <choice>, maybe something like this.

<sequence>
  <Number />
  <literal text=' ' />
  <choice>
    <choice limit={1}>
      <literal text='m' />
      <literal text='meters' />
    </choice>
    <choice limit={1}>
      <literal text='mi' />
      <literal text='miles' />
    </choice>
  </choice>
</sequence>

With this, Lacona will never "miles" for the input of "mi", because one of the choices matched already. So

'10 m'   suggests '10 m' and '10 mi'
'10 me'  suggests '10 meters'
'10 mi'  suggests '10 mi'
'10 mil' suggests '10 miles'

That's possibly a better interface for the user, because it won't be making multiple suggestions that are functionally identical. It has the side effect of making your testing easier!

from elliptical.

PhantomPayne avatar PhantomPayne commented on June 17, 2024

Thanks. That makes a lot of sense. I'll try it out this weekend and let you know how it goes.

from elliptical.

brandonhorst avatar brandonhorst commented on June 17, 2024

Closing this for now, please let me know how your trial goes.

from elliptical.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.