Giter Site home page Giter Site logo

Comments (11)

patapizza avatar patapizza commented on April 20, 2024

Hi @linuxjain,

You're right, Duckling doesn't fully parse 2nd of this month:

ghc> debug (makeLocale EN $ Just US) "2nd of this month" [This Time]
this|last|next <cycle> (this month)
-- regex (this)
-- month (grain) (month)
-- -- regex (month)
[Entity {dim = "time", body = "this month", value = Object (fromList [("values",Array [Object (fromList [("value",String "2013-02-01T00:00:00.000-02:00"),("grain",String "month"),("type",String "value")])]),("value",String "2013-02-01T00:00:00.000-02:00"),("grain",String "month"),("type",String "value")]), start = 7, end = 17}]

However, it does parse on the 2nd of this month:

ghc> debug (makeLocale EN $ Just US) "on the 2nd of this month" [This Time]
on <date> (on the 2nd of this month)
-- regex (on)
-- intersect by ",", "of", "from", "'s" (the 2nd of this month)
-- -- the <day-of-month> (ordinal) (the 2nd)
-- -- -- regex (the)
-- -- -- ordinal (digits) (2nd)
-- -- -- -- regex (2nd)
-- -- regex (of)
-- -- this|last|next <cycle> (this month)
-- -- -- regex (this)
-- -- -- month (grain) (month)
-- -- -- -- regex (month)
[Entity {dim = "time", body = "on the 2nd of this month", value = Object (fromList [("values",Array [Object (fromList [("value",String "2013-02-02T00:00:00.000-02:00"),("grain",String "day"),("type",String "value")])]),("value",String "2013-02-02T00:00:00.000-02:00"),("grain",String "day"),("type",String "value")]), start = 0, end = 24}]
it :: [Entity]

And the 2nd of this month:

ghc> debug (makeLocale EN $ Just US) "the 2nd of this month" [This Time]
intersect by ",", "of", "from", "'s" (the 2nd of this month)
-- the <day-of-month> (ordinal) (the 2nd)
-- -- regex (the)
-- -- ordinal (digits) (2nd)
-- -- -- regex (2nd)
-- regex (of)
-- this|last|next <cycle> (this month)
-- -- regex (this)
-- -- month (grain) (month)
-- -- -- regex (month)
[Entity {dim = "time", body = "the 2nd of this month", value = Object (fromList [("values",Array [Object (fromList [("value",String "2013-02-02T00:00:00.000-02:00"),("grain",String "day"),("type",String "value")])]),("value",String "2013-02-02T00:00:00.000-02:00"),("grain",String "day"),("type",String "value")]), start = 0, end = 21}]
it :: [Entity]

To parse, 2nd of this month we would need to update a bit the rules.
Can you try to get a look at it?

from duckling.

saurabhhssaurabh avatar saurabhhssaurabh commented on April 20, 2024

I have tried to look at the code but problem is I am not familiar with Clojure. I was facing problem in understanding functions definition and duckling flow. I will be needed guidance from a person who understands clojure well.

from duckling.

patapizza avatar patapizza commented on April 20, 2024

@linuxjain Duckling is now in Haskell. ;) I'll try to see if I can get it going this week.

from duckling.

saurabhhssaurabh avatar saurabhhssaurabh commented on April 20, 2024

Thank u.

from duckling.

saurabhhssaurabh avatar saurabhhssaurabh commented on April 20, 2024

@patapizza I have updated issue with more failure cases. Can we load duckling only to parse date, not time? Currently if I load duckling it parses hour, minute and second along with year, month and day.

from duckling.

patapizza avatar patapizza commented on April 20, 2024

@linuxjain What do you mean to only parse dates? Can you provide more context on what you are trying to do?

from duckling.

saurabhhssaurabh avatar saurabhhssaurabh commented on April 20, 2024

@patapizza currently duckling parses a phrase and gives output as 2017-11-17T13:00:00.000+05:30 where 2017-11-17 represents date, 13:00:00.000 represents time and +05:30 represents time zone. So if I query like "show all movies released on 23.", 23 is parsed as time i.e 11 PM (23:00:00). So is there any flag or something else so that I can tell duckling to parse only date not time and time zone.

from duckling.

patapizza avatar patapizza commented on April 20, 2024

@linuxjain I can't repro this - it doesn't return any Time for show all movies released on 23.. It does return a Time entity on on the 23th.

from duckling.

saurabhhssaurabh avatar saurabhhssaurabh commented on April 20, 2024

@patapizza Ran this query on duckling demo page, It is considering 23 as hour (11 PM)-> Tuesday, 21 November 2017 at 23:00:00 -0800 (-08:00) :hour.

from duckling.

patapizza avatar patapizza commented on April 20, 2024

@linuxjain We still need to update duckling.wit.ai to use the Haskell library (it's still running the Clojure version).

from duckling.

chessai avatar chessai commented on April 20, 2024

This is no longer an issue.

> debug (makeLocale EN Nothing) "2nd of this month" [Seal Time]
<day-of-month> (ordinal or number) of <month> (2nd of this month)
-- ordinal (digits) (2nd)
-- -- regex (2nd)
-- regex (of)
-- this|last|next <cycle> (this month)
-- -- regex (this)
-- -- month (grain) (month)
-- -- -- regex (month)
[Entity {dim = "time", body = "2nd of this month", value = RVal Time (TimeValue (SimpleValue (InstantValue {vValue = 2013-02-02 00:00:00 -0200, vGrain = Day})) [SimpleValue (InstantValue {vValue = 2013-02-02 00:00:00 -0200, vGrain = Day})] Nothing), start = 0, end = 17, latent = False, enode = Node {nodeRange = Range 0 17, token = Token Time TimeData{latent=False, grain=Day, form=Nothing, direction=Nothing, holiday=Nothing, hasTimezone=False}, children = [Node {nodeRange = Range 0 3, token = Token Ordinal (OrdinalData {value = 2}), children = [Node {nodeRange = Range 0 3, token = Token RegexMatch (GroupMatch ["2","nd"]), children = [], rule = Nothing}], rule = Just "ordinal (digits)"},Node {nodeRange = Range 4 6, token = Token RegexMatch (GroupMatch [""]), children = [], rule = Nothing},Node {nodeRange = Range 7 17, token = Token Time TimeData{latent=False, grain=Month, form=Nothing, direction=Nothing, holiday=Nothing, hasTimezone=False}, children = [Node {nodeRange = Range 7 11, token = Token RegexMatch (GroupMatch ["this","",""]), children = [], rule = Nothing},Node {nodeRange = Range 12 17, token = Token TimeGrain Month, children = [Node {nodeRange = Range 12 17, token = Token RegexMatch (GroupMatch []), children = [], rule = Nothing}], rule = Just "month (grain)"}], rule = Just "this|last|next <cycle>"}], rule = Just "<day-of-month> (ordinal or number) of <month>"}}]
❯ curl -XPOST http://0.0.0.0:5406/parse --data 'locale=en_US&text=2nd of this month' | jq
[
  {
    "body": "2nd of this month",
    "start": 0,
    "value": {
      "values": [
        {
          "value": "2021-04-02T00:00:00.000-07:00",
          "grain": "day",
          "type": "value"
        }
      ],
      "value": "2021-04-02T00:00:00.000-07:00",
      "grain": "day",
      "type": "value"
    },
    "end": 17,
    "dim": "time",
    "latent": false
  }
]

from duckling.

Related Issues (20)

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.