Commit Graph

37 Commits

Author SHA1 Message Date
Julien Odent
03c6197283 Time: Don't accept negative years
Summary:
In theory, years can be negative. In practice, this is rarely seen and when it is, it's usually with the B.C. postfix.
Updating `ruleYearLatent` to not accept negative years for all languages.

Reviewed By: codyohl

Differential Revision: D33895871

fbshipit-source-id: 818000104da825aab91be7fa2a72704aa350a91a
2022-02-02 05:34:31 -08:00
Maurice Döpke
75af12524f adds german time rule for expressions like: Montag in 3 Wochen (#332)
Summary:
closes https://github.com/facebook/duckling/issues/331

Pull Request resolved: https://github.com/facebook/duckling/pull/332

Reviewed By: girifb

Differential Revision: D26283481

Pulled By: chessai

fbshipit-source-id: 054c6467a69896ff3ebbd1f9bc0734aadf1b6dbe
2021-02-09 14:33:37 -08:00
Maurice Döpke
998b13bceb Adds german times rules like "Übernächste Woche" (week after next) (#330)
Summary:
fixes https://github.com/facebook/duckling/issues/329  and allows for recognizing of terms like übernächste woche

Pull Request resolved: https://github.com/facebook/duckling/pull/330

Reviewed By: girifb

Differential Revision: D26284196

Pulled By: chessai

fbshipit-source-id: 160e73668b835c83adb0fd1c396a8a2977e86516
2021-02-09 10:48:32 -08:00
Christoph Flick
d0a6f8114c Improve german time approximation (#435)
Summary:
Improves the recognition of German time approximation language and removes a single error in the rule of <time-of-day> approximately.

Pull Request resolved: https://github.com/facebook/duckling/pull/435

Reviewed By: patapizza

Differential Revision: D24934281

Pulled By: chessai

fbshipit-source-id: 641bcb6a7e5c26e66c735fe13bccae9b7a8909ae
2020-11-19 13:48:42 -08:00
Julien Odent
3d5e1c3bad Time/DE: Don't parse "so"
Summary:
"so" is an adverb in German: https://github.com/wit-ai/wit/issues/1860
It's also a short form for "Sonntag" (Sunday); making the dot mandatory.

Reviewed By: haoxuany

Differential Revision: D22900791

fbshipit-source-id: 8dc873f79a21ca2add074f9c664e84fae56f1e67
2020-08-03 12:34:49 -07:00
Julien Odent
a6b7253aa4 Duration/EN: Leverage TimeGrain for number.number hours
Summary: also kill redundant `isGrain` helper from `Time`.

Reviewed By: dwhit, haoxuany

Differential Revision: D18937649

fbshipit-source-id: ed658cc3bac70e6592dabae536a31a4c2da8a578
2019-12-11 12:38:17 -08:00
Michael Voegele
4218897f64 Translated all computed holidays from English into German and added HolidayHelpers to reduce code duplication.
Summary: Added German langauage support for all computed holidays currently supported in English. Also created HolidayHelpers, which contains more complex holiday calculations used across languages.

Reviewed By: patapizza

Differential Revision: D17386163

fbshipit-source-id: 9dd88f8b0d699e5d7254a5ba7114bfa01b15176a
2019-09-20 18:32:13 -07:00
Julien Odent
bf89e34365 Relicense to BSD3
Reviewed By: JoelMarcey

Differential Revision: D15439223

fbshipit-source-id: c5af3cb06318748142fe503945b38beffadfc28a
2019-05-22 10:46:39 -07:00
Jens Persson
d85c7ee926 Add 'the day before yesterday' rule for German, and a test for it. Al… (#324)
Summary:
Add 'the day before yesterday' rule for German, and a test for it. Also another test
Pull Request resolved: https://github.com/facebook/duckling/pull/324

Reviewed By: patapizza

Differential Revision: D13931961

Pulled By: haoxuany

fbshipit-source-id: 11d9ebd879be3e4d28a762d5638ee300a4132445
2019-02-13 13:31:26 -08:00
Martin Heuschober
c0e4c8c926 fix issue #249 (wrong parsing of yyyy-mm-dd dates in DE) (#282)
Summary:
- took regex from EN (which is working)
- added test cases from 2016-01-01 to 2018-12-31

- change non-breaking space to regular space
Pull Request resolved: https://github.com/facebook/duckling/pull/282

Reviewed By: chinmay87

Differential Revision: D13551882

Pulled By: patapizza

fbshipit-source-id: e254be1beaed21226741c55f243ac21eaa06d636
2019-01-02 14:01:53 -08:00
Julien Odent
546fa113a6 Time: Add "today" helper + reuse "tt" helper
Summary: Instead of `cycleNth TG.Day 0` and `Just . Token Time`.

Reviewed By: chinmay87

Differential Revision: D9344258

fbshipit-source-id: 1731c19f0d83640c5716757c70fcefea4655172f
2018-08-15 12:45:48 -07:00
Julien Odent
a3e87589a1 Time: Reuse "now" helper
Summary: Instead of `cycleNth TG.Second 0`.

Reviewed By: chinmay87

Differential Revision: D9341237

fbshipit-source-id: 153dba6edb0b341afad1ee6f7fa04361415be211
2018-08-15 12:45:48 -07:00
Edward Akerboom
ddbb6fdff8 Remove am/pm rule
Summary:
See https://github.com/facebook/duckling/issues/196
Closes https://github.com/facebook/duckling/pull/199

Reviewed By: patapizza

Differential Revision: D8098984

Pulled By: xhavokx

fbshipit-source-id: e6c7f94b8cda09c5f96c75052d333bced0c85ac2
2018-05-23 06:15:35 -07:00
Chinmay Deshmukh
e7f285cd1d Time: Return Holiday Name in response (Beta)
Summary:
Return the canonical holiday name if the input had a holiday in it and the date resolves to the date of the holiday.

Add `holiday` to `TimeData`.
Set it in the holiday rule.
Make sure it propogates appropriately in `predNth` and `intersect`.
Make sure it doesn't propogate in other rules.
Add `holiday` to `TimeValue` and set it during `resolve`

Reviewed By: patapizza

Differential Revision: D7441387

fbshipit-source-id: d57602fd294dc6149ab044c05065c1b9250cb331
2018-04-02 10:45:32 -07:00
Julien Odent
ad0ab1d98e Time/DE,EN,NL: fixes + refactoring
Summary:
* added `okForThisNext` flag for holidays/seasons/months/days of week rules
* fixed `mkRuleHolidays` argument ordering
* reused helpers in English

Reviewed By: JonCoens

Differential Revision: D7200945

fbshipit-source-id: 01da94f5ba929a37a379b5b9efd68961892a926c
2018-03-12 09:45:37 -07:00
Bora Tunca
002dec5614 Support lowercase time zones
Summary: Support lowercase time zones

Reviewed By: patapizza

Differential Revision: D7114137

fbshipit-source-id: 906c4fa5305aea8990e8a5d480ceeec4b584d7db
2018-03-01 14:30:29 -08:00
Julien Odent
bef7a44fa8 Remove redundant brackets and language pragmas
Summary: .

Reviewed By: JonCoens

Differential Revision: D6838082

fbshipit-source-id: 94757bdb80c6d3c29a7a6554429940a1b7403108
2018-01-29 16:45:28 -08:00
Julien Odent
fb10a6e6ba Time/EN: Parse spelled out times + AM/PM
Summary:
When using speech recognition, we might see things like "six thirty six a m" or
"ten thirty p m".
Also fixed the argument order of `timeOfDayAMPM` to be more idiomatic.

Reviewed By: blandinw

Differential Revision: D6316542

fbshipit-source-id: 0008c049040219b3a1dd80d9e4661ba8a246fa7f
2017-11-14 13:30:26 -08:00
Panagiotis Vekris
c6a7fedb7b Extract useful time-rule constructors to Time.Helpers
Summary: Some constructors for Time related rules are being reused among different language, so we can extract them in `Duckling/Time/Helpers.hs`.

Reviewed By: patapizza

Differential Revision: D6269106

fbshipit-source-id: 7d9969ce425ee27a2e1a32ea48932e16c7e6b1f1
2017-11-08 14:45:35 -08:00
Julien Odent
b3fb913a23 Time: don't parse subsequent numbers
Summary:
- Fixes #89. "<number> <number>" would parse as Time if in the right range.
- Applied same rule for all languages. Note that for Italian and Polish, I updated "<hour> <minute>" tests to be in the form "at <hour> <minute>".
- Replaced `liftM2` with more generic `and|or . sequence [f1, f2, ...]`.

Reviewed By: blandinw

Differential Revision: D5992879

fbshipit-source-id: 5409ffb
2017-10-06 12:19:29 -07:00
Julien Odent
83ea150d94 Convert back escaped characters in rules
Summary:
We noticed that using UTF-8 characters directly in regexes work.
Hence converting back the escaped characters for readability and maintenance.

Reviewed By: blandinw

Differential Revision: D5787146

fbshipit-source-id: e5a4b9a
2017-09-07 12:49:33 -07:00
Henry Swanson
b62be42077 Consolidate other times in DE ruleset
Summary:
Combined each of seasons, instants, and holidays into a data list and a
function to generate the list of Rules.

*Instants = today, tomorrow, now, end of year, etc.

Reviewed By: patapizza

Differential Revision: D5730896

fbshipit-source-id: 23170e7
2017-08-29 16:34:30 -07:00
Henry Swanson
96432e5b7d Consolidate days of the week and months for DE
Summary:
The German ruleset has 12 separate rules for months, and 7 for days. This
change replaces those with a list of months/days and a single function
to create a list of rules from those. This is the same approach as is currently in the English ruleset.

Reviewed By: patapizza

Differential Revision: D5728656

fbshipit-source-id: 8590f4a
2017-08-29 14:49:39 -07:00
Atyansh Jaiswal
4e96a15c15 Refactored weekend rules to use the weekend helper for all languages
Summary: This is a simple refactor that uses the weekend helper for all languages

Reviewed By: patapizza

Differential Revision: D5677330

fbshipit-source-id: 9984539
2017-08-22 10:34:24 -07:00
Julien Odent
9037126937 [Duckling] Time/DE: don't parse 'nächste 5'
Summary: Fixes https://github.com/wit-ai/wit/issues/694.

Reviewed By: niteria

Differential Revision: D5590023

fbshipit-source-id: 6356615
2017-08-09 06:49:26 -07:00
Julien Odent
a84eb62180 Time: Fix nthDOWOfMonth
Summary:
Fixes #65.
* fixes US holidays
* Black Friday is actually the first day after Thanksgiving day (not necessary the fourth Friday of November)

Reviewed By: JonCoens

Differential Revision: D5533906

fbshipit-source-id: 1824cba
2017-08-01 09:04:31 -07:00
Sebastian Mika
291bd28873 Various smaller DE time improvements
Summary:
This PR contains various smaller but - at least on my data - important performance improvements for matching of German time and time range expressions.

I evaluated this on approx 11.000 time and time range expressions taken from emails (rather formal business travel requests) that have been manually annotated with the "true" time. Comparing this branch to the current master (`d6f8dd`) I get e.g. approx. 80% of the duckling results within +/- 1h of the true value (hours are the smallest grain in my data), vs. only 70% in the master. Other indicators I checked (time/range confusion, other thresholds, failures to find anything in the first place, etc.) were all improved as well.

**Changes**:

* [significant performance plus] added a rule `ruleDateDateInterval` that handles variations of "13.-15.10." correctly. Here the common case is that "13." refers to "13.10." and not "13.CURRENTMONTH". I didn't see an obvious way to fix that in the `<datetime> - <datetime>` rule.
* [significant performance plus] In `ruleMmdd` (which matches expressions like "13.03." in German), I made the last dot optional. At least in less formal text this is quite common to be forgotten. Also here and in `ruleDateDateInterval` I changed the order of the terms in the regular expression matching the month to prefer matching e.g. "10" over matching "1"+"no dot".
* [minor] treat "14/15Uhr" the same as "14-15Uhr"
*  [minor] Extended "bis" to also match "bis zum" and "auf den" (e.g. in "von Montag bis zum Freitag" or "von Dienstag auf Mittwoch")
* [minor] Changed `hh:mm` matching to also get the rather esoteric expression "17h00" - should do no harm.
Closes https://github.com/facebookincubator/duckling/pull/54

Reviewed By: blandinw

Differential Revision: D5301815

Pulled By: patapizza

fbshipit-source-id: 8766caf
2017-06-23 07:04:27 -07:00
Julien Odent
4ed89d29de DE/Time: Convert unicode char to hexadecimal
Summary: I missed that one.

Reviewed By: niteria

Differential Revision: D5079134

fbshipit-source-id: 2eacbea
2017-05-18 08:04:45 -07:00
Sebastian Mika
39cb76024b Smaller improvements to DE about/before/after
Summary:
* In DE `frühestens` and `spätestens` act implicitly as `nach` and `vor` (after and before) on times and may also appear after the time

* The rule `ruleTimeofdayTimeofdayInterval` does match `9Uhr-10` but not the
way more common expression `9-10Uhr`; added the same rule with the
second time as non-latent; actually I am not sure whether the original
rule makes sense at all

* Simple extension of `intersect by ,` to THE formal way in DE to express
a date (i.e. `Freitag, der 13.03.2013`)

General remark: I used UTF-8 characters albeit I saw that the other rules and examples use escaped hex encoding for e.g. German umlaute. If there is any reason to do that (it is not very readable), I will of course change that.
Closes https://github.com/facebookincubator/duckling/pull/19

Reviewed By: niteria

Differential Revision: D5070052

Pulled By: patapizza

fbshipit-source-id: 990ad08
2017-05-17 10:19:44 -07:00
Bartosz Nitka
cdd2f1c9cb Don't produce empty tokens from interval
Summary:
This is analogous to
[Duckling] Don't produce trivially empty Tokens
but that change did that for intersect, this one
deals with interval.

Reviewed By: patapizza

Differential Revision: D5039215

fbshipit-source-id: 95bd821
2017-05-10 16:04:22 -07:00
Bartosz Nitka
878f85b9e1 Codemod intersectMB to intersect
Summary:
`intersectMB` was a name used for the purpose of migrating.
This is the last part of the migration.

Reviewed By: patapizza

Differential Revision: D4906098

fbshipit-source-id: a70af78
2017-04-18 10:19:20 -07:00
Bartosz Nitka
fe39a55a4c Use intervalMB instead of interval
Summary:
This continues the work from:
"[Duckling] Don't produce trivially empty Tokens"
All the Rules should use intervalMB from now on.

Reviewed By: patapizza

Differential Revision: D4906072

fbshipit-source-id: 277b961
2017-04-18 10:19:20 -07:00
Bartosz Nitka
3d18cf5ea9 Don't produce trivially empty Tokens
Summary:
We can detect certain kinds of contradictions sooner,
producing a token with an unresolvable Predicate is wasteful.
For a text like:
```
"Demain apres midi 14h 15 h 16h vendredi 14 a 15h"
```
it could produce 7000 tokens with empty predicates.
After this change it produces none and we get a 4x improvement in
time and 6x improvement in allocations.

Note I only covered `ruleIntersect*` here. I need to do this for
other instances as well.

Reviewed By: JonCoens

Differential Revision: D4871078

fbshipit-source-id: 9f0e7ad
2017-04-11 16:35:05 -07:00
Bartosz Nitka
1cf8496967 tt helper for returning Time Tokens
Summary:
This is a very common pattern (>1k occurrences).
Replacing it with something shorter makes the rules a bit less
boilerplate-y.
Feel free to bikeshed the name, I can easily redo the codemod.

Reviewed By: patapizza

Differential Revision: D4848864

fbshipit-source-id: 7baeee3
2017-04-10 12:34:43 -07:00
Bartosz Nitka
f46539ced2 Type for Closed/Open intervals
Summary:
This makes the code easier to read.
I'm not attached to naming, but this is
standard terminology from topology.

Reviewed By: JonCoens, patapizza

Differential Revision: D4848740

fbshipit-source-id: 79c2c20
2017-04-07 12:19:17 -07:00
Julien Odent
54c9448fba Rename Number to Numeral
Summary: For consistency with the dimension name.

Reviewed By: JonCoens

Differential Revision: D4722216

fbshipit-source-id: 82c56d3
2017-03-16 13:49:16 -07:00
FBShipIt
3f8e52e70a Initial commit
fbshipit-source-id: 301a10f448e9623aa1c953544f42de562909e192
2017-03-08 10:33:56 -08:00