Commit Graph

361 Commits

Author SHA1 Message Date
Julien Odent
cdda637d7c Time/EN_US: EMS week and EMSC day
Summary: 3rd full week in May, starting on a Sunday.

Reviewed By: chinmay87

Differential Revision: D7896050

fbshipit-source-id: aaae50b605a8d199b7134e90896da1de8785a11c
2018-05-07 12:00:50 -07:00
Ziyang Liu
aa3f9d08a6 Add Administrative Professionals' Day in EN_{AU,CA,NZ,US,ZA}
Summary:
* CA, US: Wednesday of the last full week of April
* AU: First Friday of May
* NZ: Third Wednesday of April
* ZA: First Wednesday of September

Closes https://github.com/facebook/duckling/pull/192

Reviewed By: chinmay87

Differential Revision: D7894777

Pulled By: patapizza

fbshipit-source-id: 4401c8a09758173965f08129a9b830a369a38941
2018-05-07 12:00:50 -07:00
Ziyang Liu
c84166d708 Add Quantity/ZH
Summary:
Fixes #181.
Closes https://github.com/facebook/duckling/pull/182

Reviewed By: patapizza

Differential Revision: D7891288

Pulled By: haoxuany

fbshipit-source-id: faa505dbf149c728545a92579cb2e92a89cd5cb8
2018-05-07 09:45:32 -07:00
Julien Odent
ccab5533c7 Time/EN_AU: Ekka
Summary:
Starts on the first Friday of August if it's not before August 5th,
otherwise on the second Friday of August.
10-day event, holiday on the Wednesday.

Reviewed By: chinmay87

Differential Revision: D7891529

fbshipit-source-id: 44edb3285851fc76e0de99f1581d8edf08ea9e7c
2018-05-07 01:15:26 -07:00
Julien Odent
5dbdc48047 Time/EN: Earth Hour
Summary:
Last Saturday of March unless it falls on Holy Saturday,
in which case it's the Saturday before, between 8:30pm and 9:30pm.

Reviewed By: chinmay87

Differential Revision: D7891433

fbshipit-source-id: e21ce54c865e8ee5280a374c8e8fd36571a2e550
2018-05-07 01:15:26 -07:00
Julien Odent
c6b0646493 Time/EN: Vesak
Summary:
According to Wikipedia (https://en.wikipedia.org/wiki/Vesak), Vesak
is celebrated differently across the globe.
As a first stab, taking the day of the full moon in May in the Gregorian
calendar.
Used https://eclipse.gsfc.nasa.gov/SKYCAL/SKYCAL.html to find the full moon in
May.

Reviewed By: chinmay87

Differential Revision: D7881429

fbshipit-source-id: b9897aa0dd32b01a569c8a040749df59cf78ce54
2018-05-06 11:00:34 -07:00
Julien Odent
662935fe64 Time/EN: Global Youth Service Day
Summary: and National variant for US

Reviewed By: chinmay87

Differential Revision: D7879055

fbshipit-source-id: d1db9fb5a3c4a00cb7332979ec12bb2d9935ca4e
2018-05-06 11:00:34 -07:00
Julien Odent
e9f4f21b21 Time/EN_US: Siblings Day
Summary: April 10, year over year.

Reviewed By: haoxuany

Differential Revision: D7878392

fbshipit-source-id: ed26b31d964b54805fc237c69ab1b5c680bac80b
2018-05-04 12:45:27 -07:00
Julien Odent
d81056dd0d Fix build
Reviewed By: haoxuany

Differential Revision: D7878218

fbshipit-source-id: f5a37ea3d4bb56e5053e854222f5804b2eca8488
2018-05-04 10:30:30 -07:00
Chinmay Deshmukh
a7f83ffe6a Time/EN: Make partial meridies latent
Summary: Make partial meridies latent to not flag spans like "A4 A5"

Reviewed By: patapizza

Differential Revision: D7866300

fbshipit-source-id: 2254750d643ca28474a5340731f9786617dcbadf
2018-05-03 15:45:33 -07:00
RIAN DOUGLAS
f328821bbc Add support for using 'grand' to refer to 1,000's of currency in EN
Summary: Added support for ",number> grand" and "a grand" to result in thousands of currency amount

Reviewed By: haoxuany

Differential Revision: D7688809

fbshipit-source-id: 72a81c7a1c48329f85c9f525b72b00c479a9edb0
2018-05-03 14:45:25 -07:00
Julien Odent
1976fd4543 Time/EN_US: Tax Day
Summary:
The first weekday on or after April 15 not falling on Emancipation
Day. Otherwise, the weekday after that.

Reviewed By: chinmay87

Differential Revision: D7745651

fbshipit-source-id: c215d903c250bac5ebc265192794fd324efda812
2018-04-30 13:45:25 -07:00
Julien Odent
94a0fb3f63 Warn against incomplete patterns
Summary:
Added GHC option to warn against incomplete patterns.
This is useful to drive the implementation for new languages, and make sure we're not missing anything.

Reviewed By: haoxuany

Differential Revision: D7782889

fbshipit-source-id: 09d92ca37974eed56a22c0edb9e8f74412f7e3f6
2018-04-26 16:31:02 -07:00
Julien Odent
b4c0f6ebd6 Time/EN_US: Fix Emancipation Day
Summary: Observed is the first weekday closest to April 16.

Reviewed By: haoxuany

Differential Revision: D7735190

fbshipit-source-id: f046dfb5c067464b83764f97114ccf9c805069d0
2018-04-24 11:01:27 -07:00
Julien Odent
d6143e98d7 Time/EN: Fix before/after/until/since + <year>
Summary: Reusing existing rules to be consistent.

Reviewed By: haoxuany

Differential Revision: D7735684

fbshipit-source-id: dd1699e095a2ae9754ec71e5d622c9378c308f17
2018-04-24 10:00:32 -07:00
Julien Odent
00d46b18f2 Time/EN: Absorb "since" before month/year
Summary:
since 2009, since February, etc.

https://github.com/wit-ai/wit/issues/1056

Reviewed By: haoxuany

Differential Revision: D7729314

fbshipit-source-id: a635cdab4ee5f077c77ef0c01180c805675cd0a7
2018-04-23 10:45:29 -07:00
Julien Odent
17dd70ffe5 Update old github links
Summary: facebookincubator -> facebook

Reviewed By: haoxuany

Differential Revision: D7729114

fbshipit-source-id: 4786b40060e873900c50e3af20be180a573a19ce
2018-04-23 10:15:33 -07:00
Pavlo Kerestey
7b6cbf0ddb Support '2 thursdays ago|back'
Summary:
I have seen the Call for participation for #175 in Haskell News and thought I would give it a try and exercise in contributing to unknown haskell code.

As I am new to the project, I have probably done a mistake of committing the classifiers. The commit got reverted but it is still associated with the issue. Lesson learned: don't tag commit messages wit the issue numbers.
Closes https://github.com/facebook/duckling/pull/180

Reviewed By: patapizza

Differential Revision: D7717445

Pulled By: haoxuany

fbshipit-source-id: d818f351d03b6c8b3d77984b2060a0a14230696f
2018-04-20 16:45:33 -07:00
Ziyang Liu
a3b35880e5 Change value in Entity to typed value instead of JSON
Summary:
Modified `Entity` to use the new `ResolvedVal` data type. Other changes follow naturally. Related issues: https://github.com/facebook/duckling/issues/121 and https://github.com/facebook/duckling/issues/172

Now one can pattern match on the output value, for instance:

```
{-# LANGUAGE GADTs #-}

import Data.Text
import Duckling.Core
import Duckling.Testing.Types
import qualified Duckling.PhoneNumber.Types as PN

parsePhoneNumber :: Text -> Text
parsePhoneNumber input =
  case value entity of
    (RVal PhoneNumber (PN.PhoneNumberValue v)) -> v
    where
    (entity:_) = parse input testContext testOptions [This PhoneNumber]
```

Reviewed By: patapizza

Differential Revision: D7502020

fbshipit-source-id: 76ba7b315cfd0d2c61ff95c855b7c95efc0a401c
2018-04-20 14:18:47 -07:00
Panagiotis Vekris
e679a7e32c version bump to 0.1.5.0
Summary: Bumping version before hackage release

Reviewed By: patapizza

Differential Revision: D7712566

fbshipit-source-id: 8dd55487ec2ce89ad84d8c79ae5baa3b94016508
2018-04-20 12:30:36 -07:00
Julien Odent
e15efc4336 Time/EN: Vasant Panchami, Holika Dahan, Holi
Summary: Moar Hindu holidays.

Reviewed By: chinmay87

Differential Revision: D7704148

fbshipit-source-id: 90fc611021389585c35b667d822cbe67e281d48d
2018-04-19 18:45:29 -07:00
Ziyang Liu
5460d8df0e Support custom dimensions
Summary:
Support custom dimensions

Had to move the definition of `Dimension` from `Duckling.Dimensions.Types` to `Duckling.Types` to avoid cyclic imports between these two modules.

A sample custom dimension is in `exe/CustomDimensionExample.hs`.

Limitations of custom dimensions:

- All rules for a custom dimension must be in the same module with the definition of the custom dimension. Otherwise there will be cyclic imports, because the definition of the dimension and the rules refer to each other.
- The custom dimension must be specified when using `parse`, since there's no way to get all the existing custom dimensions.

Reviewed By: patapizza

Differential Revision: D7630360

fbshipit-source-id: 30e12dcb33611f5692c4f5949de377bf61b75e1e
2018-04-19 15:30:51 -07:00
Julien Odent
eccf5c8f24 Time/EN: More Hindu holidays
Summary:
* Raksha Bandhan
* Pongal
* Onam

Reviewed By: chinmay87

Differential Revision: D7662179

fbshipit-source-id: f29f9bdadb70455956ddf8c65afc34309e7e25d0
2018-04-19 11:00:50 -07:00
Julien Odent
9c8619cbc9 Time/EN: Navaratri holidays
Summary: Added Navaratri-related holidays from 2000 to 2030.

Differential Revision: D7661419

fbshipit-source-id: ab5cf5c4fe9a4019cf51e9569692a03321667bf4
2018-04-19 11:00:50 -07:00
Julien Odent
1f1837c47b Time/EN: Diwali holidays
Summary: Adding Diwali-related holidays from 2000 to 2030.

Reviewed By: chinmay87

Differential Revision: D7660326

fbshipit-source-id: aff8de97b266f797ff759655982252e7e259e87f
2018-04-19 11:00:50 -07:00
Quan
c166179d89 Use comma "," as decimal separator for VI
Summary:
In Vietnam, we use comma "," as decimal separator instead of dot "."
Closes https://github.com/facebook/duckling/pull/176

Reviewed By: patapizza

Differential Revision: D7601328

Pulled By: panagosg7

fbshipit-source-id: 7f5725006f9054fe45a24757ec2abc36b7aa6605
2018-04-18 23:15:30 -07:00
Aaron Yue
4df76289bc Implement AmountOfMoney
Summary: implement AmountOfMoney rules and corpus for ZH

Reviewed By: patapizza

Differential Revision: D7508507

fbshipit-source-id: 3591b399a9880c5278587979c6576720343cc123
2018-04-17 16:45:32 -07:00
Aaron Yue
babe317723 fix intersect rule to work with negative numbers
Summary:
Numerals that require intersection with negative numbers don't work, since the negative sign gets parsed
before the intersect rules happen. This fixes it by adding a guard in for positive in the intersection rule.

Reviewed By: patapizza

Differential Revision: D7592225

fbshipit-source-id: 2bc9c708cadeea4012c1f3ef487c61a144325f2a
2018-04-13 19:45:40 -07:00
Chinmay Deshmukh
17e1845e12 Time/EN_CA, EN_US: Add "Groundhogs day" in regex for "Groundhog Day"
Summary: Modify regex to add "Groundhogs day" in regex for "Groundhog Day" in US and CA

Reviewed By: patapizza

Differential Revision: D7605031

fbshipit-source-id: 0cbb45d4edde3345437872f2e5b366c39f6a8b54
2018-04-13 12:15:31 -07:00
Julien Odent
de977fe5cc Duration: Move composite duration rule to English
Summary: "and" is language-specific.

Reviewed By: chinmay87

Differential Revision: D7605874

fbshipit-source-id: 59adcee4784baebe3b9eb775b6763bf3bba8ef8d
2018-04-12 15:15:29 -07:00
RIAN DOUGLAS
fd267ee80b Time/EN: Make "may" latent
Summary: Extended method for making months from a pair, to take a 3-tuple, including a flag indicating whether to make the result latent. Implement the previous mkRuleMonths method in terms of this.

Reviewed By: patapizza

Differential Revision: D7491037

fbshipit-source-id: 4d4c41b46dc0390e17b521480f3daf8306f23834
2018-04-12 14:00:29 -07:00
Aaron Yue
fe0807dced Use lambda-case for Rule production
Summary: change Rule production functions to lambda-case

Reviewed By: patapizza

Differential Revision: D7424413

fbshipit-source-id: edac0290d310578f633ff0208434d1eca038ad9c
2018-04-12 10:15:57 -07:00
Aaron Yue
4ef255e577 Generalize and expand digit specifier usage for hanzi
Summary:
generalize chinese digit specifier (十百千万亿) parsing, and add hanzi tests
These digits specifiers can be parsed as (<num><speci>)<num>,
by using the multiplicater value <num><speci>, and a connect function that adds them together
(two cases, skipping digits [which requires a 零 in between], and digits in consecutive locations).
Note that 个 is technically a digit specifier,
but in Chinese it is never used directly as a numeral specifier, and always as a counter.

Reviewed By: zliu41

Differential Revision: D7424249

fbshipit-source-id: 20a85a7df1f908ee9879e92b904178fa26a9a5e5
2018-04-12 10:00:33 -07:00
Chinmay Deshmukh
f355abacc5 Time/EN: time + n years ago/in n years
Summary:
Add support for things like -
"mlk day three years ago"
"mlk day in three years"
"Labor Day one year from now"

"Thanksgiving in one year"
"Thanksgiving in 2013"

"january in a year"
"january 3 years ago"

Reviewed By: patapizza

Differential Revision: D7581591

fbshipit-source-id: 6f37a83c5acbff28672c2e8a958eaf37c679cab3
2018-04-12 01:10:17 -07:00
Julien Odent
c539ba2f55 Time/EN: Tu BiShvat
Summary: Added precomputed Jewish holiday `Tu BiShvat`.

Reviewed By: chinmay87

Differential Revision: D7596389

fbshipit-source-id: ed770dfa0eca982d5d1896dacff6443ee0fa2d30
2018-04-11 20:15:42 -07:00
Julien Odent
443caeb096 Time/EN_AU: Reconciliation Day
Summary:
First Monday on or after May 27th:
https://publicholidays.com.au/reconciliation-day/

Reviewed By: chinmay87

Differential Revision: D7596237

fbshipit-source-id: 5ad4effb30d1e09a988c93fdb85f9dc60d0a1e54
2018-04-11 20:15:42 -07:00
Souvik Ghosh
ced73dcdcb AmountOfMoney NL Support
Summary:
Hello,
I have added new directory for AmountOfMoney NL Support
Added two files
- Duckling/AmountOfMoney/NL/Corpus.hs
- Duckling/AmountOfMoney/NL/Rules.hs

Updated File
- Duckling/Rules/NL.hs

Added test cases
- tests/Duckling/AmountOfMoney/NL/Tests.hs

Updated Test file
- tests/Duckling/AmountOfMoney/Tests.hs

Updated
duckling.cabal

Thanks for the review and the latest merge. Looking forward

Regards
Closes https://github.com/facebook/duckling/pull/173

Reviewed By: JonCoens

Differential Revision: D7592192

Pulled By: patapizza

fbshipit-source-id: 5895c29bf7f1033e4ffd791d5915a16d230e9375
2018-04-11 17:15:30 -07:00
Julien Odent
120f569ed0 Time/EN: Fix "in" + year
Summary: Now that years are latent, let's absorb the "in" and make them not latent.

Reviewed By: zliu41

Differential Revision: D7587599

fbshipit-source-id: 61a19ac389244df491591d78c28f0301f9124439
2018-04-11 11:00:30 -07:00
Lucas Hosseini
528fea9ad4 Make all years latent
Summary: Make all years latent to prevent any four digit number to be considered a year.

Reviewed By: patapizza

Differential Revision: D7559843

fbshipit-source-id: f3a8625dd7d74edfffb13401278d6b4a5110359a
2018-04-11 05:15:31 -07:00
Julien Odent
944e8d73c2 Time/EN: Islamic holidays
Summary:
Islamic holidays from a few pre-computed reference times, based on the Umm al-Qura Calendar of Saudi Arabia.
http://www.staff.science.uu.nl/~gent0113/islam/ummalqura.htm
http://www.staff.science.uu.nl/~gent0113/islam/ummalqura_principal.htm

Reviewed By: chinmay87

Differential Revision: D7578193

fbshipit-source-id: b9e4428ad91058c24495ce27a0ae945b91291d4f
2018-04-10 16:15:26 -07:00
Chinmay Deshmukh
c567abea1c Time/EN: Rule <Day of month> of month
Summary:
Rule to resolve things like:
"27th of next month"
"15th of last month"
"3rd of this month"

Reviewed By: patapizza

Differential Revision: D7543740

fbshipit-source-id: 20bdc194ed7d1466e2ca42c87b73a04ace7c29ab
2018-04-09 16:45:37 -07:00
Danny Su
1c6ebffb46 Time/ES: use mkRuleSeasons
Summary:
- removed ruleSeason, ruleSeason2, ruleSeason3, ruleSeason4
- replaced above with ruleSeasons and use the `mkRuleSeasons` helper

Reviewed By: patapizza

Differential Revision: D7545455

fbshipit-source-id: 57842f52ab3ab954ba31a200942970b6d0bd040e
2018-04-09 12:30:37 -07:00
Oleksii Dykan
e0e2338dd1 Add proper EOY and EOM rules
Summary: Added rules to cover EOY, EOM, BOY, BOM

Reviewed By: zliu41

Differential Revision: D7492089

fbshipit-source-id: fb0c787d709146534980ccc53e240ae88740a553
2018-04-09 08:15:33 -07:00
Julien Odent
18934b81e2 Time/EN: Fix computed past series + Jewish holidays
Summary:
* Fixed computed past series
* Added a few Jewish holidays, pre-computed and built upon.

Reviewed By: chinmay87

Differential Revision: D7511694

fbshipit-source-id: c66a34e6634a9f86101fb2fd3b4a372d75ba5711
2018-04-06 19:15:25 -07:00
Ziyang Liu
c819dcb665 add Discovery Day in EN/CA
Summary: add Discovery Day in EN/CA

Reviewed By: patapizza

Differential Revision: D7527814

fbshipit-source-id: 053e70b59c121e6853f743cd5b9a2b1a4a45e38c
2018-04-06 13:45:50 -07:00
Ziyang Liu
3547fa3472 Add Boss's Day (closest working day to Oct 16) in EN
Summary: Add Boss's Day (closest working day to Oct 16) in EN

Reviewed By: patapizza

Differential Revision: D7512241

fbshipit-source-id: c8a4a14b77677ed34edebfeb48bfce1019bb059d
2018-04-05 18:00:49 -07:00
Rajesh Shenoy
7a76c938da Add distance to SV
Summary: Earlier distance was implemented, but it was not defined

Reviewed By: patapizza

Differential Revision: D7524341

fbshipit-source-id: e1e8342a6eff5a523a0db31bf301870ae27c513e
2018-04-05 16:00:33 -07:00
Aaron Yue
e542ff5b50 Distribute ruleUnitAmount to all languages
Summary:
enforce units are checked in ruleUnitAmount and ruleAmountUnit, and distribute ruleUnitAmount to all
languages, since in some languages this doesn't work (such as for ZH, where value units must succeed amounts)

Reviewed By: patapizza

Differential Revision: D7509840

fbshipit-source-id: 3a79b39721850f9d0289442925fbc02cf69abefb
2018-04-05 10:45:35 -07:00
Aaron Yue
878bcb9277 Show input for ambiguous parse failures
Summary: show the input that an ambiguous parse is failing at

Reviewed By: patapizza

Differential Revision: D7502191

fbshipit-source-id: 9f0fbf8301413d9007236ba5b6af1f4b41c20269
2018-04-04 10:30:32 -07:00
Aaron Yue
3629fbd503 Prompt ambiguous parses in corpus tests
Summary:
During ranking, due to how candidates are ordered, it is completely possible to have multiple correct candidates
have the exact same rank (equal range and exact equal score). In this case `analyze` returns all of them, which gets
misinterpreted as having multiple tokens in output rather than multiple solutions. Checks this case and gives the
correct prompt for ambiguous parses.

Reviewed By: patapizza

Differential Revision: D7489391

fbshipit-source-id: b66947e37bddb3ac6273843dd79b559aff9d0083
2018-04-03 17:00:27 -07:00