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

Parse a relative time from a specific referenceTime #37

Closed
amenella opened this issue Jun 2, 2017 · 6 comments
Closed

Parse a relative time from a specific referenceTime #37

amenella opened this issue Jun 2, 2017 · 6 comments

Comments

@amenella
Copy link

amenella commented Jun 2, 2017

Hi everyone,

Would it be possible to parse a time from a specific referenceTime ?
As i understood (let me know if i'm wrong) for now referenceTime is only based on the given timezone.

What I would like to do is to give as input a specific datetime, and get a result from that specific datetime.

For example if my inputs are

input: {
  referenceTime: '2017-06-08T15:00:00+02:00',
  text: 'next monday at 8am',
}

I would like to get next monday at 8am from the 8th of june 2017, that means 2017-06-12T08:00:00+02:00

Would it be possible ?

Thanks !

@patapizza
Copy link
Contributor

Hi @amenella,

This is possible using fromZonedTime from Duckling.Resolve.

Example running a REPL session: st repl --no-load.

> :l Duckling.Core
> import qualified Data.Time as Time
> d = Time.fromGregorian 2017 6 8
> tod = Time.TimeOfDay 0 0 0
> lt = Time.LocalTime d tod
> tz = Time.TimeZone 120 False "hmm"
> zt = Time.ZonedTime lt tz
> duckt = fromZonedTime zt
> parse "next monday at 8am" Context {referenceTime = duckt, lang = EN} [This Time]
[Entity {dim = "time", body = "next monday at 8am", value = "{\"values\":[{\"value\":\"2017-06-12T08:00:00.000+02:00\",\"grain\":\"hour\",\"type\":\"value\"}],\"value\":\"2017-06-12T08:00:00.000+02:00\",\"grain\":\"hour\",\"type\":\"value\"}", start = 0, end = 18}]

Let me expose fromZonedTime in Duckling.Core.

@amenella
Copy link
Author

amenella commented Jun 2, 2017

Thanks for the reply @patapizza

if i'm not missing anything here, after having exposed fromZonedTime in Duckling.Core, we have to get our custom post param on the server side in ExampleMain.hs and then pass it to the context as referenceTime.

Am I right ?

Please forgive me if my question are meaningless, I'm just a beginner in haskell...

facebook-github-bot pushed a commit that referenced this issue Jun 2, 2017
Summary: See #37

Reviewed By: JonCoens

Differential Revision: D5172801

fbshipit-source-id: bf63303
@patapizza
Copy link
Contributor

Yes that's right. :)

Curious about why do timezones not work for you?

@amenella
Copy link
Author

amenella commented Jun 3, 2017

Timezones are good but in a discussion, context always differs, especially when you're talking about time.
Take this example of conversation (referenceTime is thursday 1st of june 2017)

  1. Are you free next tuesday ? (tuesday 6th of june 2017)
  2. No, but I am on the friday. (friday 9th of june 2017)

You can note that in 2. friday refers to friday after the next tuesday, so we have to update the referenceTime to the next tuesday's date, that means tesday 6th of june 2017, which was not possible until your commit @patapizza

Hope it's fullfilling your curiosity ! :)

Thanks again !

@amenella amenella closed this as completed Jun 3, 2017
@ydshieh
Copy link

ydshieh commented Oct 8, 2018

Thanks for the reply @patapizza

if i'm not missing anything here, after having exposed fromZonedTime in Duckling.Core, we have to get our custom post param on the server side in ExampleMain.hs and then pass it to the context as referenceTime.

Am I right ?

Please forgive me if my question are meaningless, I'm just a beginner in haskell...

Hi, at the current version, can we directly specify referencetime as augument in the request url? For example, curl -XPOST http://0.0.0.0:8000/parse --data 'locale=en_GB&referencetime=XXX&text=tomorrow at eight'

@patapizza
Copy link
Contributor

@chiapas: Yes using reftime.

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

No branches or pull requests

3 participants