Comments (11)
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.
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.
@linuxjain Duckling is now in Haskell. ;) I'll try to see if I can get it going this week.
from duckling.
Thank u.
from duckling.
@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.
@linuxjain What do you mean to only parse dates? Can you provide more context on what you are trying to do?
from duckling.
@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.
@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.
@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.
@linuxjain We still need to update duckling.wit.ai
to use the Haskell library (it's still running the Clojure version).
from duckling.
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)
- Support Persian(fa) Languages HOT 4
- [Persian][Numeral] Extract incorrect number from text
- ghc: panic! when stack build.
- Error building on MacOS with M1 Pro HOT 4
- Can't build Docker image HOT 2
- [it_IT] add time corpus/rules
- Default log files are created even if different paths are provided via options
- [ERROR] Network.Socket.sendBuf: resource vanished HOT 1
- Time intervals are too large by one grain HOT 1
- [Question] Which elements are relevant for Test-Failures? HOT 3
- Will not run on new Macbook HOT 1
- Reject common phrases like "guten morgen"
- Up Text and Hashable constraints
- Ne dimension is not working. HOT 1
- Custom Dimension doesn't return the actual value!
- Intervals with leap year dates return incorrect years
- how can I detect the date and time separately? anyone knows?
- Inconsistent date range parsing HOT 1
- Incorrect abbreviation of 'millions' in locale DE HOT 1
- overalaping body in the extracted entities
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from duckling.