Commit Graph

754 Commits

Author SHA1 Message Date
leandro.guisandez@pgconocimiento.com
1322cd69ec Init
Summary: Initialises Distance for CA (Catalan) language

Reviewed By: stroxler

Differential Revision: D28297521

Pulled By: chessai

fbshipit-source-id: eb8641568f5981ea6e2d481c305e36cdb683dcfb
2021-05-12 12:50:13 -07:00
leandro.guisandez@pgconocimiento.com
213d1f12a5 Init
Summary: Initialise AmountOfMoney for CA (Catalan) language

Reviewed By: stroxler

Differential Revision: D28296090

Pulled By: chessai

fbshipit-source-id: f02305a762ee3cbf357bbb0a65eef614d3d828c9
2021-05-12 11:32:18 -07:00
Daniel Cartwright
3e28d42a29 Nth Time of Time rules: Make it less permissive
Summary: Currently, Duckling will accept "The first christmas of next month" in this rule, which is nonsensical. This reduces the scope of the times the rule recognises, thereby limiting us to a set of more sensible resolutions.

Reviewed By: stroxler

Differential Revision: D27861417

fbshipit-source-id: 3f19700af7298a6238c59f5de0598168d4b4a3c4
2021-05-11 11:32:14 -07:00
chessai
ccdf27ad1d FR: add nth <time> of <time> rules (#596)
Summary: Pull Request resolved: https://github.com/facebook/duckling/pull/596

Reviewed By: stroxler

Differential Revision: D27722743

Pulled By: chessai

fbshipit-source-id: a9136fef2a26e87269bca8212ae07d3d7fe04977
2021-05-11 11:32:13 -07:00
Daniel Cartwright
59cb9e0879 Support legalese numerals
Summary:
Support numerals like "forty-five (45)". Commonly seen in legal documents.

There are no classifiers to regenerate.

Resolves #216

Reviewed By: stroxler

Differential Revision: D28305725

fbshipit-source-id: b9b4e160f630ce3cf462fcf9f2e575738463c313
2021-05-10 10:33:35 -07:00
Steven Troxler
0efbfe5988 Give a usable error if we fail to parse reftime parameter
Summary:
My attention was brought to this issue by the linter complaining about `read`.

The linter is just as happy with `error`, but I do think it's better to fail
with a usable error message here than with whatever error `read` gives us.

Reviewed By: chessai

Differential Revision: D28213406

fbshipit-source-id: f101d0515ee64978480bdbb873ff72d80d124969
2021-05-07 06:20:03 -07:00
Steven Troxler
4b44e969c9 Fix all name collisions on the main Types.hs
Summary:
I think they all fell into one of two categories:
- names colliding with field names, but where there was already an existing
  pattern (e.g. d for dimension, v for value) and we just had to be consistent
- cases that were best fixed by turning NamedFieldPuns on, which I did

Reviewed By: chessai

Differential Revision: D28213245

fbshipit-source-id: 18fbd61771e12da11ce03b98b74af51d1e837787
2021-05-07 06:20:03 -07:00
Steven Troxler
ce3614fedd In Debug.hs, s/sentence/input/g
Summary:
When tracing the code from Debug downward, the unnecessary rename
of an argument from `sentence` to `input` creates a context switch. Let's
use the same name throughout.

Reviewed By: chessai

Differential Revision: D28213244

fbshipit-source-id: 22476d958312e5c60cd32ff1e3d0d460cf0c8c79
2021-05-06 08:54:57 -07:00
Steven Troxler
a88b70feb7 Filter with a self-describing function in where
Summary:
In both `Api.hs` and `Debug.hs` I noticed that I was staring at the code
longer than necessary to figure out what a lambda with a destructure and
pattern match were doing. Moving it to a function in `where` named
`isRelevantDimension` makes skimming easier.

Reviewed By: chessai

Differential Revision: D28213243

fbshipit-source-id: 344f464dcac7297009c35b19373eef67e0eb9540
2021-05-06 08:54:57 -07:00
Steven Troxler
eba5d0a825 Simple style fixes for outer layers around Engine.hs
Summary:
Easy style fixes for ExampleMain.hs, Debug.hs, Api.hs, Core.hs

Most of these are just lint fixes, but I also made a few not-just-lint changes
to conform to some elements of our style guide that I agree with:
- if the type signature doesn't fit on one line, then put one type per line
  with nothing on the first line, so that all types are vertically aligned - makes
  for a quick skim
- try to avoid mixing same-line function args with hanging function args: hang
  all arguments or none at all to get a more outline-like feel, again better for
  skimming

I was actually able to eliminate all errors for most of these modules - the name
collisions I usually give up on were manageable by hiding + easy variable renames

Reviewed By: chessai

Differential Revision: D28213246

fbshipit-source-id: 1f77d56f2ff8dccfd5f3b534f087c07047b92885
2021-05-06 08:54:56 -07:00
Steven Troxler
0e13d28b4d Time/EN: Get rid of unnecessary rules
Summary:
While I was working on fixing #604, I came across the rules
`ruleMilitarySpelledOutAMPM(2)`, which were actually capturing
some of my test phrases and confusing me.

This commit removes them because
- they aren't needed: the existing latent spelled-out hour + minute rules plus
  the "(in the )?(am/pm)" rules together give the same behavior
- they are confusingly named - these aren't military times at all, they are
  spelled-out civilian times

Reviewed By: haoxuany

Differential Revision: D27848485

fbshipit-source-id: ba1ed16ec22b5139b0b500b44dc91adb1b5e3d82
2021-04-26 06:17:44 -07:00
Steven Troxler
c44c73fe04 Numeral/ES: Add support for additive concatenations
Summary:
This commit extend Spanish-language support for concatenations
of the form "<higher-order-of-magnitude> <lower>", e.g.
"doscientos tres" (203) or "cuatro mil ventiuno" (4022) to work
not just for hundreds but also for thousands and millions.

Reviewed By: chessai

Differential Revision: D27858133

fbshipit-source-id: 5c6b227ae7dad9009cd636e7ea49c209480c931a
2021-04-23 09:48:07 -07:00
Steven Troxler
888da76215 Numeral/ES: Add support for 1M, and multiples of 1K/1M
Summary:
This commit adds two things to Spanish numeral support:
- support for millions
- support, via hooking into the `isMultipliable` logic used by EN, for
  composing counts of 2-999 with either "mil" or "millones", which is
  the standard way to say things like "tres mil" = 3000

Reviewed By: chessai

Differential Revision: D27858135

fbshipit-source-id: 980e95bd989f818c5ceaa2bb6c87fe81d3e08366
2021-04-23 09:48:06 -07:00
Steven Troxler
15bba9eba9 Numeral/ES: Refactor hundreds handling to fix bug
Summary:
This diff refactors our handling of "<hundreds> 0..99" numbers
to be more flexible by replacing `ruleNumeralthreePartHundreds`
with
- a rule for two-part hundreds like "dos cientos" (which is technically
  incorrect grammar - doscientos is correct - but probably worth keeping) based
  on a notion of multipliability like that used in EN rules
- a rule stating that we can compose hundreds with 0..99 additively

The resulting rules are more flexible, and they correctly parse not only
gramatically iffy phrases like "dos cientos tres", but also grammatically
correct phrases like "doscientos tres". This fixes #380.

Reviewed By: chessai

Differential Revision: D27858136

fbshipit-source-id: 4a918d84d93ac074f83f6947a8f80cfd11145115
2021-04-23 09:48:06 -07:00
Steven Troxler
6db071069b Numeral/ES: Style fixes - names, order, etc
Summary:
Whle looking into fixing https://github.com/facebook/duckling/issues/380
I was having a bit of trouble navigating the existing rules and guessing
what is / is not supported.

This diff refactors the Numeral/ES code to be easier to navigate:
- rename all the `ruleNumeral{1,2,3,4,5,6}` rules to be descriptive
- changes the order to be themed from small to large numbers, and
  make sure the order of defines matches the order of rules at the end
  of the module
- use [20 .. 90] instead of manually specifying the same list out-of-order

Reviewed By: chessai

Differential Revision: D27858134

fbshipit-source-id: b13983d75b36bb4e2b387ef06fe61066d81ae19a
2021-04-23 09:48:06 -07:00
Steven Troxler
bf696ba185 Time/EN: Allow dashes in spelled-out times
Summary:
It's common to use dashes when spelling out times longhand,
e.g. "five-thirty am", but Duckling wasn't handling this at all.

This commit adds rules for times spelled out with dashes. The
rules explicitly forbid the second of the two times from including
digits via a negative match. This is because
- it wouldn't be at all idomatic to write five-26 or five-oh-6
- allowing that pattern clashes with time range parsing, e.g.
  "9-10 am" should parse as a time range, not as "9:10 am"

Reviewed By: chessai

Differential Revision: D27848428

fbshipit-source-id: dfe8b98cb38119a16db2a19db47fd3128783e617
2021-04-22 11:47:28 -07:00
Steven Troxler
23ec021b07 Duration/RU: For non-int times, use the coarsest grain
Summary:
This commit fixes #111, which was an open issue that any non-integer
multiple of any unit of time was being converted to seconds.

My solution is to write a recursive function `Duration.Helpers.inCoarsestGrain`
which, given a grain `g` and double value `v` finds the coarses grain `g'` such that
`v * g` - rounded to the nearest seconds - has integral units.

We call this function only in the case of non-integer multiples, and we start our
search from the given grain because nothing coarser would make sense. The code could
actually be slightly more efficient if we started at the next-smallest grain, but
in the interest of clarity I think this is probably better.

Reviewed By: chessai

Differential Revision: D27891439

fbshipit-source-id: b048310963eb71337fd91ab4ef3c840134a76e73
2021-04-21 13:32:38 -07:00
Steven Troxler
f73277c2b0 Duration/EN: fix lint errors
Summary:
Minor changes to silence most linter errors
- remove redundant import
- delete some redundant brackets and tweak bracket locations
- switch . to $ to avoid excessive-point-free-style warnings

Also linted Duration/Types.hs

Reviewed By: chessai

Differential Revision: D27891440

fbshipit-source-id: d84287edafe328aeddd78b781618ec5c41944bd8
2021-04-21 13:32:37 -07:00
Steven Troxler
35532b0b7c Time/EN: Tighten up handling of split times like "five ten"
Summary:
While debugging an attempt to extend our handling of spelled-out
times, I realized that we are being too aggressive in our parsing of
times like "five ten", because we'll parse "five nine" as possibly
meaning "5:09", which isn't something an English speaker would say
(or rather if they did, it's more likely they mean "five (to) six"
or something similar.

Reviewed By: chessai

Differential Revision: D27848429

fbshipit-source-id: 34d783332fd60359ad9b6e7862367453bc93a1d1
2021-04-20 05:31:53 -07:00
Steven Troxler
a250e60cbb Silence many lint errors on Time/{Helpers,Types}.hs
Summary:
This commit gets rid of all the easy-to-fix lint warnings on time helper modules:
- replacing unnecessary `.` with `$`
- Flipping a lambda in a map to an infix operation
- Use `ts` for a list of times, not `series` which produces a pretty confusing naming collision

There are still quite a lot of lint errors related to name masking, which would be challenging to fix without us coming to an agreement about naming conventions.

But at least in my editor, name-masking errors are a lot less visually noisy than other errors (they only highlight the one name) so I don't mind them as much when skimming the code.

Reviewed By: chessai

Differential Revision: D27842198

fbshipit-source-id: 9091e5349657243b61d7ee169d0d06dd2122ac17
2021-04-19 18:16:55 -07:00
Splinter Suidman
933c287854 NL: Fix spelling of ‘achttien’ (18) (#602)
Summary:
The Dutch numeral and ordinal rules contained a spelling mistake: [‘achttien’](https://en.wiktionary.org/wiki/achttien) (18) was spelt as ‘achtien’ (note the single *t*).

This PR fixes this spelling mistake everywhere in the code base.

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

Reviewed By: patapizza

Differential Revision: D27859001

Pulled By: chessai

fbshipit-source-id: 8da0d8b099d49cf6207d4066cee1fc7da68a418e
2021-04-19 18:01:33 -07:00
Steven Troxler
586522b649 Numeral: Silence point-free lint errors in Numeral/Helpers.hs
Summary:
While looking at bugfixes for some ES and IT numeral parsing, I was
looking at the Helpers.hs module and figured I'd silence some lint
errors. There are still some name-masking lint issues, but all others
have been fixed.

Reviewed By: chessai

Differential Revision: D27854164

fbshipit-source-id: 5be8d924b033a55608c455074df1c80c8c0019be
2021-04-19 16:47:10 -07:00
jkachmar
e7f320e0c9 Bumps tasty upper bound (< 1.5) (#605)
Summary:
Closes https://github.com/facebook/duckling/issues/600

 ---

I saw the latest 0.2.0.0 release announcement and decided to try building the project locally.

This compiles successfully with `tasty-1.4.1` and `cabal-install` (cf. the  snippet below if you want to see the full set of packages I compiled/tested with).

<details>
  <summary> cabal.project.freeze </summary>

```
active-repositories: hackage.haskell.org:merge
constraints: any.HUnit ==1.6.2.0,
             any.aeson ==1.5.6.0,
             aeson -bytestring-builder -cffi -developer -fast,
             any.ansi-terminal ==0.11,
             ansi-terminal -example,
             any.ansi-wl-pprint ==0.6.9,
             ansi-wl-pprint -example,
             any.array ==0.5.4.0,
             any.assoc ==1.0.2,
             any.attoparsec ==0.13.2.5,
             attoparsec -developer,
             any.base ==4.14.1.0,
             any.base-compat ==0.11.2,
             any.base-compat-batteries ==0.11.2,
             any.base-orphans ==0.8.4,
             any.bifunctors ==5.5.10,
             bifunctors +semigroups +tagged,
             any.binary ==0.8.8.0,
             any.blaze-builder ==0.4.2.1,
             any.bytestring ==0.10.12.0,
             any.bytestring-builder ==0.10.8.2.0,
             bytestring-builder +bytestring_has_builder,
             any.call-stack ==0.3.0,
             any.case-insensitive ==1.2.1.0,
             any.clock ==0.8.2,
             clock -llvm,
             any.colour ==2.3.5,
             any.comonad ==5.0.8,
             comonad +containers +distributive +indexed-traversable,
             any.constraints ==0.12,
             any.constraints-extras ==0.3.1.0,
             constraints-extras +build-readme,
             any.containers ==0.6.2.1,
             any.data-fix ==0.3.1,
             any.deepseq ==1.4.4.0,
             any.dependent-sum ==0.7.1.0,
             any.directory ==1.3.6.0,
             any.distributive ==0.6.2.1,
             distributive +semigroups +tagged,
             any.dlist ==1.0,
             dlist -werror,
             any.extensible-exceptions ==0.1.1.4,
             any.extra ==1.7.9,
             any.filepath ==1.4.2.1,
             any.generic-deriving ==1.14,
             generic-deriving +base-4-9,
             any.ghc-boot-th ==8.10.4,
             any.ghc-prim ==0.6.1,
             any.happy ==1.20.0,
             any.hashable ==1.3.1.0,
             hashable +integer-gmp,
             any.haskell-src-exts ==1.23.1,
             any.hsc2hs ==0.68.7,
             hsc2hs -in-ghc-tree,
             any.indexed-traversable ==0.1.1,
             any.integer-gmp ==1.0.3.0,
             any.integer-logarithms ==1.0.3.1,
             integer-logarithms -check-bounds +integer-gmp,
             any.io-streams ==1.5.2.0,
             io-streams +network -nointeractivetests +zlib,
             any.io-streams-haproxy ==1.0.1.0,
             any.lifted-base ==0.2.3.12,
             any.monad-control ==1.0.2.3,
             any.mtl ==2.2.2,
             any.network ==3.1.2.1,
             network -devel,
             any.network-uri ==2.6.4.1,
             any.old-locale ==1.0.0.7,
             any.optparse-applicative ==0.16.1.0,
             optparse-applicative +process,
             any.parsec ==3.1.14.0,
             any.pretty ==1.1.3.6,
             any.primitive ==0.7.1.0,
             any.process ==1.6.9.0,
             any.random ==1.2.0,
             any.readable ==0.3.1,
             any.regex-base ==0.94.0.1,
             any.regex-pcre ==0.95.0.0,
             any.regex-posix ==0.96.0.0,
             regex-posix -_regex-posix-clib,
             any.rts ==1.0,
             any.scientific ==0.3.6.2,
             scientific -bytestring-builder -integer-simple,
             any.semigroups ==0.19.1,
             semigroups +binary +bytestring -bytestring-builder +containers +deepseq +hashable +tagged +template-haskell +text +transformers +unordered-containers,
             any.snap-core ==1.0.4.2,
             snap-core -debug +network-uri -portable,
             any.snap-server ==1.1.2.0,
             snap-server -build-pong -build-testserver -debug -openssl -portable,
             any.some ==1.0.2,
             some +newtype-unsafe,
             any.splitmix ==0.1.0.3,
             splitmix -optimised-mixer,
             any.stm ==2.5.0.0,
             any.strict ==0.4.0.1,
             strict +assoc,
             any.tagged ==0.8.6.1,
             tagged +deepseq +transformers,
             any.tasty ==1.4.1,
             tasty +clock +unix,
             any.tasty-hunit ==0.10.0.3,
             any.template-haskell ==2.16.0.0,
             any.text ==1.2.4.1,
             any.text-show ==3.9,
             text-show +base-4-9 +new-functor-classes +template-haskell-2-11,
             any.th-abstraction ==0.4.2.0,
             any.th-compat ==0.1.2,
             any.th-lift ==0.8.2,
             any.these ==1.1.1.1,
             these +assoc,
             any.time ==1.9.3,
             any.time-compat ==1.9.5,
             time-compat -old-locale,
             any.timezone-olson ==0.2.0,
             any.timezone-series ==0.1.9,
             any.transformers ==0.5.6.2,
             any.transformers-base ==0.4.5.2,
             transformers-base +orphaninstances,
             any.transformers-compat ==0.6.6,
             transformers-compat -five +five-three -four +generic-deriving +mtl -three -two,
             any.type-equality ==1,
             any.unbounded-delays ==0.1.1.1,
             any.unix ==2.7.2.2,
             any.unix-compat ==0.5.3,
             unix-compat -old-time,
             any.unordered-containers ==0.2.13.0,
             unordered-containers -debug,
             any.uuid-types ==1.0.4,
             any.vector ==0.12.3.0,
             vector +boundschecks -internalchecks -unsafechecks -wall,
             any.wcwidth ==0.0.2,
             wcwidth -cli +split-base,
             any.zlib ==0.6.2.3,
             any.zlib-bindings ==0.1.1.5
index-state: hackage.haskell.org 2021-04-18T19:08:29Z
```

</details>

The test suite fails with the following error:

```
    Numeral Tests
      AF Tests
        Corpus Tests:              FAIL
          tests/Duckling/Testing/Asserts.hs:90:
          empty result on "agt"
```

...but from what I can tell by the last few CI runs some corpus test errors are not unexpected so I figure this _probably_ isn't a regression.

 ---

I avoided messing with the Stackage snapshot since that seemed out-of-scope, but I could rework this PR (or open another) to update it to the latest LTS resolver and/or add a Stackage Nightly resolver as well.

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

Reviewed By: girifb

Differential Revision: D27858969

Pulled By: chessai

fbshipit-source-id: 3f60fd28fe8eeb903de40c696c59ae10eedf12e4
2021-04-19 16:02:32 -07:00
chessai
8ce33d81f5 Update CHANGELOG (#610)
Summary:
Recent changes were allowed in without changelog entries (my fault).
This adds entries for those changes.

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

Reviewed By: haoxuany

Differential Revision: D27867893

Pulled By: chessai

fbshipit-source-id: 6e3d9dce496f0f9344dcb65c5e2dd3f1f1c380eb
2021-04-19 16:02:32 -07:00
Steven Troxler
9bd4c9b7fb Time/EN: Allow latent match for <part-of-day> <latent-time-of-day>
Summary:
This fixes #592 in a very conservative way: the reason why `ruleIntersect` does
not detect "tonight 815" and "tonight eight fifteen" as it does "tonight 8:15"
is because it explicitly forbids the second part of the intersection from being
latent, unless it is a year.

I don't think it's a good idea to remove the restriction on latent inputs in
`ruleIntersect`, so instead I just made a new rule specifically for the
intersection of `<part-of-day> <time-of-day>`.

It also seems to me that there's a lot of room for this to be too aggressive,
for example if I say "tonight 500 people will laugh" the "tonight" and "500"
aren't really linked. So, I set the rule to be latent; this may be too conservative
to be useful though (do client libraries usually allow latent results?).

Reviewed By: chessai

Differential Revision: D27842596

fbshipit-source-id: 36ac59e31c632d4864241bce291147a46d52f780
2021-04-19 13:05:50 -07:00
evjava
f1cb3bc87c Russian(RU) duration improvements (#375)
Summary:
- dimunitives for minutes and hours
- quarters of an hour
- added 'сутки' (24-hour period)
Pull Request resolved: https://github.com/facebook/duckling/pull/375

Reviewed By: stroxler

Differential Revision: D20332233

Pulled By: chessai

fbshipit-source-id: 479858e6c5de856a6965b6193c481e654a6e04fb
2021-04-16 14:31:41 -07:00
chessai
d712bee78b initialise changelog (#597)
Summary:
resolves https://github.com/facebook/duckling/issues/455

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

Reviewed By: girifb

Differential Revision: D27806129

Pulled By: chessai

fbshipit-source-id: 4bca273fef5df0848c2b92d3ac753b66cedfcdcb
2021-04-16 10:02:28 -07:00
chessai
3e4fe974a3 update ci (#594)
Summary:
- Update GHC 8.10.2 to 8.10.3
- Add GHC 9.0.1
- Make stack CI as extensive as cabal CI
- update tested-with
- remove cabal CI, keep stack only

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

Reviewed By: girifb

Differential Revision: D27710921

Pulled By: chessai

fbshipit-source-id: 098bcbb33c7dc7dfac4e2e46ca9ea07083b47b59
2021-04-12 18:32:23 -07:00
chessai
e6e000fb62 v0.1.6.1 -> v0.2.0.0 (#593)
Summary:
Necessary major version bump as per PVP: https://pvp.haskell.org/

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

Reviewed By: girifb

Differential Revision: D27710929

Pulled By: chessai

fbshipit-source-id: 16fb24e108ab6696d31c94573e79644248bf00e2
2021-04-12 14:17:18 -07:00
leandro.guisandez@pgconocimiento.com
f3e128a07b Add Ordinal dimension to CA (Catalan) locale
Summary: Adds Ordinal rules to Catalan language

Reviewed By: patapizza

Differential Revision: D27681617

Pulled By: chessai

fbshipit-source-id: 145a1117eeff10839484f34a87e9bd685382d42e
2021-04-09 13:05:19 -07:00
leandro.guisandez@pgconocimiento.com
7907812184 Initialise Catalan language with Numeral
Summary: Adds Catalan language and Numeral rules for it

Reviewed By: haoxuany

Differential Revision: D26518604

Pulled By: chessai

fbshipit-source-id: e6b4b0ceb9b7931d086c732dd03fb5cbbe062d5b
2021-04-08 14:47:02 -07:00
chessai
9babaee20a add missing copyright headers (#591)
Summary: Pull Request resolved: https://github.com/facebook/duckling/pull/591

Reviewed By: patapizza

Differential Revision: D27623732

Pulled By: chessai

fbshipit-source-id: e38a64d04d004ea80fabeb5efbc635b00e2802df
2021-04-08 10:46:31 -07:00
Amr Keleg
8a8f557002 Add more variants of egp to EN and AR AmountOfMoney dimension (#590)
Summary:
These are popular variants/abbreviations of Egyptian pounds.
All these forms are documented on wikipedia (https://en.wikipedia.org/wiki/Egyptian_pound)

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

Reviewed By: haoxuany

Differential Revision: D27598249

Pulled By: chessai

fbshipit-source-id: 42ae9115b1def48c58e50a6deb624c3407c029f3
2021-04-07 12:31:41 -07:00
Mustafa ALP
3157d2e553 Time Dimension for TR locale (#584)
Summary:
Added time dimension for Turkish language

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

Differential Revision: D27235743

Pulled By: chessai

fbshipit-source-id: 7419ff7373d942530f0eb35939acb9970b918672
2021-04-06 10:32:18 -07:00
chessai
4c4d5ca725 bump dependencies (#588)
Summary: Pull Request resolved: https://github.com/facebook/duckling/pull/588

Reviewed By: girifb

Differential Revision: D27435008

Pulled By: chessai

fbshipit-source-id: f0b0a42752cfebcf290cbc6c6d194ba09724670f
2021-03-30 12:47:10 -07:00
Mustafa ALP
5385346e69 Update README.md (#585)
Summary:
Convert `This` to `Seal` in order to make this example working.

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

Reviewed By: girifb

Differential Revision: D27235685

Pulled By: chessai

fbshipit-source-id: 71a712a622b5d9d10f7842276a2b8f60f962477e
2021-03-26 14:33:53 -07:00
Steven Troxler
d47cb1b002 Ignore the no-"-1" linter error for duckling
Summary:
By default, Facebook Haskell code has a lint error banning
-1s, because at one point it was used as a default value in some
API handlers and it's better to use Option + Nothing for this use case.

But in Duckling - particularly in the Time module - it's quite
common that we actually want to work with -1 as a meaningful integer
value, involving some kind of offset.

Reviewed By: chessai

Differential Revision: D27118984

fbshipit-source-id: 5fe2200e8005a20855d7fdd3a8eb2ad33291edc8
2021-03-17 10:47:28 -07:00
Steven Troxler
4917d426cf Style tweaks
Summary:
The facebook internal linters prefer us to avoid
excessive point-free style and extra $ where we could
instead move existing brackets.

Making those style tweaks for Time/EN/Rules.hs because
I was looking at the file as part of

Reviewed By: chessai

Differential Revision: D27108042

fbshipit-source-id: 7c8e76578476ea14d655131943e693c5159b12d2
2021-03-17 10:47:28 -07:00
Steven Troxler
78904b6680 Time - #444 Handle 2-digit date in existing d/m/y rule
Summary:
The pattern laied out in the bug report
https://github.com/facebook/duckling/issues/444
is actually already handled by the pattern
`<day-of-month>(ordinal or number)/<named-month>/year`.

The problem is purely that the regular expression doesn't
match 2-digit years, so the pattern is getting skipped rather
than evaluated. This diff fixes the regexp and adds a new example
with a 2-digit pattern.

This fixes the bug report:
```
> debug (makeLocale EN Nothing) "10-Apr-15" [Seal Time]
<day-of-month>(ordinal or number)/<named-month>/year (10-Apr-15)
-- integer (numeric) (10)
-- -- regex (10)
-- regex (-)
-- April (Apr)
-- -- regex (Apr)
-- regex (-)
-- regex (15)
[Entity {dim = "time", body = "10-Apr-15", value = RVal Time (TimeValue (SimpleValue (InstantValue {vValue = 2015-04-10 00:00:00 -0200, vGrain = Day})) [SimpleValue (InstantValue {vValue = 2015-04-10 00:00:00 -0200, vGrain = Day})] Nothing), start = 0, end = 9, latent = False, enode = Node {nodeRange = Range 0 9, token = Token Time TimeData{latent=False, grain=Day, form=Nothing, direction=Nothing, holiday=Nothing, hasTimezone=False}, children = [Node {nodeRange = Range 0 2, token = Token Numeral (NumeralData {value = 10.0, grain = Nothing, multipliable = False, okForAnyTime = True}), children = [Node {nodeRange = Range 0 2, token = Token RegexMatch (GroupMatch ["10"]), children = [], rule = Nothing}], rule = Just "integer (numeric)"},Node {nodeRange = Range 2 3, token = Token RegexMatch (GroupMatch []), children = [], rule = Nothing},Node {nodeRange = Range 3 6, token = Token Time TimeData{latent=False, grain=Month, form=Just (Month {month = 4}), direction=Nothing, holiday=Nothing, hasTimezone=False}, children = [Node {nodeRange = Range 3 6, token = Token RegexMatch (GroupMatch []), children = [], rule = Nothing}], rule = Just "April"},Node {nodeRange = Range 6 7, token = Token RegexMatch (GroupMatch []), children = [], rule = Nothing},Node {nodeRange = Range 7 9, token = Token RegexMatch (GroupMatch ["15"]), children = [], rule = Nothing}], rule = Just "<day-of-month>(ordinal or number)/<named-month>/year"}}]
```

Reviewed By: chessai

Differential Revision: D27106007

fbshipit-source-id: 4751672aef807464febef87f6d22d7270bd335df
2021-03-17 10:35:00 -07:00
mustafaalp43@gmail.com
56fd7b0aaf Feature/Turkish money (#579)
Summary:
Added amount of money dimension for Turkish language
Pull Request resolved: https://github.com/facebook/duckling/pull/579

Test Plan: :test Endpoint.Duckling.Test

Reviewed By: haoxuany, bugra

Differential Revision: D27017300

Pulled By: chessai

fbshipit-source-id: e8cb257a2953675f54269ed358948e8cbe38af7b
2021-03-17 10:35:00 -07:00
chessai
8de488475a Load timezones more leniently. (#582)
Summary:
On some linux systems, such as on NixOS, /usr/share/zoneinfo does not
exist. What does exist in its place is /etc/zoneinfo. So, we should try to load
that if /usr/share/zoneinfo does not exist.

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

Reviewed By: girifb

Differential Revision: D27086925

Pulled By: chessai

fbshipit-source-id: f4a38822be9888d57034f67a6f7abd17d56d38b8
2021-03-16 13:04:09 -07:00
Steven Troxler
55168db92f Update classifiers
Summary:
I was testing an unrelated change (which doesn't change
classifier scores) and reran classifiers just to be safe, I noticed
that the scores changed.

This diff updates them.

Reviewed By: chessai

Differential Revision: D26892970

fbshipit-source-id: c7da3e3b7d01955f98b287a3ff4e7c1ff2837c7f
2021-03-08 14:02:45 -08:00
Steven Troxler
fc5278855d Combine duplicated examples
Summary:
I was looking at adding support for "next week" constructions in Spanish to
close https://github.com/facebook/duckling/issues/553 (which it appears has
already been handled), when I noticed that the equivalent logic for English
has been split into two separate examples: "coming week" isn't in the same
example as other equivalent constructs like "upcoming week" and "next week".

This diff combines them, which I think is clearer and fewer lines of code

Reviewed By: chessai

Differential Revision: D26892322

fbshipit-source-id: 68ca4644759198fc79d963ae080495c3f2d4a923
2021-03-08 13:47:06 -08:00
Mustafa ALP
b671d75d02 Typo correction (#574)
Summary:
This commit includes typo correction for `half` and `three` equivelant in Turkish

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

Reviewed By: girifb

Differential Revision: D26726718

Pulled By: chessai

fbshipit-source-id: 840c2d8e491057b6ccec81562ff64356789f587d
2021-03-03 12:31:33 -08:00
Aaron Yue
f68ebf808a forward factor parse tree for exploit in T85548324
Summary: due to exploit in T85548324, factoring the input to get a smaller parse tree (the existing one parses tail recursively, whereas this one uses ruleIntersect which is still bad, but slightly better).

Differential Revision: D26657170

fbshipit-source-id: fe3a738073b4d30ae401521bb692f4a4bba48d96
2021-02-24 22:20:20 -08:00
Amit Manchanda
37b671389c add: support for specific times in HI duration (#424)
Summary: Pull Request resolved: https://github.com/facebook/duckling/pull/424

Reviewed By: girifb

Differential Revision: D26411920

Pulled By: chessai

fbshipit-source-id: 3f0063e4786688579f2f53f46b31bda5d222d402
2021-02-17 14:48:07 -08:00
Aleksey Landyrev
590651150b Add Time dimension for RU language
Summary: Used b40e2147a9 as reference

Reviewed By: kappa

Differential Revision: D24773196

Pulled By: chessai

fbshipit-source-id: 7cc008c0ee80f930efd76e39bb16ca91ec94b641
2021-02-12 12:02:44 -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
evjava@yandex.ru
ff4a1a5bae Be more permissive with numerals [20, 90]
Summary: There are a handful of more spelling for russian numbers [20, 30 .. 90] that we aren't handling. Additionally, we optimise for recall over precision by allowing some invalid spellings that could be understandable typos.

Reviewed By: patapizza

Differential Revision: D26285711

Pulled By: chessai

fbshipit-source-id: fd8a8f373d228a526e79b22326eff48bb966310d
2021-02-05 15:31:18 -08:00