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

Timex function for hasFullDate and hasValidHour builtin-functions #3780

Merged
merged 7 commits into from
May 3, 2020

Conversation

cosmicshuai
Copy link
Contributor

@cosmicshuai cosmicshuai commented Apr 21, 2020

closes: #2869
Now we have 7 timex related functions:
HasFullDate, HasValidTime, HasValidDuration, HasValidDate, HasValidTimeRange, HasValidDateRange, IsPresent

@cosmicshuai cosmicshuai marked this pull request as ready for review April 23, 2020 12:01
return (value, error);
},
ReturnType.Boolean,
expr => ValidateArityAndAnyType(expr, 1, 1, ReturnType.Object)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ValidateArityAndAnyType(expr, 1, 1, ReturnType.Object) [](start = 28, length = 54)

You can validate to object | string, right? Numbers or arrays are not allowed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these two functions can have a string or a TimexProperty as an argument.
Here ReturnType.Object represents a base type which includes string, number and boolean, etc.
The actual type checking is in the body of functions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our ReturnType.Object today actually works like a any not a object, so object | number won't be able to reject number or array, so we probably can refine the type checking types later.

return (value, error);
},
ReturnType.Boolean,
expr => ValidateArityAndAnyType(expr, 1, 1, ReturnType.Object)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alidateArityAndAnyType(expr, 1, 1, ReturnType.Object)), [](start = 29, length = 55)

same comment

Copy link
Contributor

@chrimc62 chrimc62 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕐

@chrimc62
Copy link
Contributor

Why not hasValidX for other things like month/day/year/minute/duration? If I said "when do you want to leave" and got a response of "the 30th", I might want to check for not having a month for example.


In reply to: 399361646 [](ancestors = 399361646)

@tomlm tomlm added the changes required Reviews has requested changes to be made before approval label Apr 24, 2020
@cosmicshuai
Copy link
Contributor Author

@vishwacsena
Based on Chris' comment above, maybe we can add a 'hasValidTimexProperty' function, which is simillar to addToTime. The signature of this function is hasValidTimexProperty(timex, property).
timex is either a TimexProperty or a string,
property is a string, like year, month, day, hour, duration, etc.

@vishwacsena
Copy link
Contributor

@cosmicshuai yes, we can always take that as an additive change. Are you suggesting we do it instead of this one? If so, I'd only be concerned about scoping it (which is what the trimmed proposal here was supposed to be). My vote would be for us to add these now and add the generic function to the backlog. Ok?

@cosmicshuai
Copy link
Contributor Author

@vishwacsena
Sure. I will add the generic function in another PR.

@chrimc62
Copy link
Contributor

I'm not sure I buy this. While it lessens the risk for now, it comes at the cost of adding more functions which overlap--doesn't seem like a good tradeoff to me.


In reply to: 618771234 [](ancestors = 618771234)

@cosmicshuai
Copy link
Contributor Author

cosmicshuai commented Apr 28, 2020

@chrimc62 @vishwacsena
As I found some references about timex inference functions,
https://github.com/microsoft/Recognizers-Text/blob/master/.NET/Microsoft.Recognizers.Text.DataTypes.TimexExpression/TimexInference.cs
I rewrote timex prebuilt functions. Now we have 7 related functions,
HasFullDate, HasValidTime, HasValidDuration, HasValidDate, HasValidTimeRange, HasValidDateRange, IsPresent
The functionalities are identical to those in TimexInference.
Do you have any idea or suggestion? Should we keep the same naming as the TimexInference library?

@chrimc62
Copy link
Contributor

I like keeping the names the same.


In reply to: 620470357 [](ancestors = 620470357)

Copy link
Contributor

@chrimc62 chrimc62 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@cosmicshuai cosmicshuai merged commit 6b7542d into master May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes required Reviews has requested changes to be made before approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Adaptive] [CEL] TIMEX prebuilt functions
5 participants