Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some values match but are not included in result when using any #28

Open
kueblc opened this issue Dec 2, 2019 · 2 comments
Open

Some values match but are not included in result when using any #28

kueblc opened this issue Dec 2, 2019 · 2 comments
Labels

Comments

@kueblc
Copy link

kueblc commented Dec 2, 2019

Consider the following examples

// ecolect 0.6.0
const ecolect = require('ecolect')
const en = require('ecolect/language/en')
const { any, dateTime } = require('ecolect/values')

const intents = ecolect.intentsBuilder(en)
	.intent('schedule:when')
		.value('when', dateTime())
		.value('remainder', any())
		.add('{when} {remainder}')
		.add('{remainder} {when}')
		.done()
	.build()

// "1s test" matches but only contains "remainder"
// "test 1s" matches with both "remainder" and "when"
// ecolect 0.7.0-beta.6
const { newPhrases, timeValue, anyTextValue } = require('ecolect')
const { en } = require('ecolect/language/en')

const matcher = newPhrases()
	.value('when', timeValue())
	.value('remainder', anyTextValue())
	.phrase('{when} {remainder}')
	.phrase('{remainder} {when}')
	.toMatcher(en)

// same as in 0.6.0
// "1s test" matches but only contains "remainder"
// "test 1s" matches with both "remainder" and "when"

Not just dateTime but number, enumeration, and possibly others seem to be effected when followed by an any value.

@kueblc
Copy link
Author

kueblc commented Dec 2, 2019

Another example, with enumeration, using 0.6.0

// ecolect 0.6.0
const ecolect = require('ecolect')
const en = require('ecolect/language/en')
const { any, enumeration } = require('ecolect/values')

const greetings = "hey,hi,hello".split(",")

const intents = ecolect.intentsBuilder(en)
	.intent('pleasantry:greeting')
		.value('greeting', enumeration(greetings))
		.value('remainder', any())
		.add('{greeting}')
		.add('{greeting} {remainder}')
		.done()
	.build()

// "hello test" matches but only includes "remainder"
// "hello" matches and includes "greeting"

@aholstenson aholstenson added the bug label Dec 6, 2019
@aholstenson
Copy link
Owner

Thanks for reporting this! I'll add a test case for this and hopefully look at and solve it during December for 0.7.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants