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
Summary:
Suggest to use wit.ai's built-in entities if running Duckling is not
an option.
Reviewed By: JonCoens
Differential Revision: D6312789
fbshipit-source-id: 08f1c5759cdd7761b456914cd5c42e1c111c6408
Summary:
* Locales support for the library, following `<Lang>_<Region>` with ISO 639-1 code for `<Lang>` and ISO 3166-1 alpha-2 code for `<Region>` (#33)
* `Locale` opaque type (composite of `Lang` and `Region`) with `makeLocale` smart constructor to only allow valid `(Lang, Region)` combinations
* API: `Context`'s `lang` parameter has been replaced by `locale`, with optional `Region` and backward compatibility.
* `Rules/<Lang>.hs` exposes
- `langRules`: cross-locale rules for `<Lang>`, from `<Dimension>/<Lang>/Rules.hs`
- `localeRules`: locale-specific rules, from `<Dimension>/<Lang>/<Region>/Rules.hs`
- `defaultRules`: `langRules` + specific rules from select locales to ensure backward-compatibility
* Corpus, tests & classifiers
- 1 classifier per locale, with default classifier (`<Lang>_XX`) when no locale provided (backward-compatible)
- Default classifiers are built on existing corpus
- Locale classifiers are built on
- `<Dimension>/<Lang>/Corpus.hs` exposes a common `corpus` to all locales of `<Lang>`
- `<Dimension>/<Lang>/<Region>/Corpus.hs` exposes `allExamples`: a list of examples specific to the locale (following `<Dimension>/<Lang>/<Region>/Rules.hs`).
- Locale classifiers use the language corpus extended with the locale examples as training set.
- Locale examples need to use the same `Context` (i.e. reference time) as the language corpus.
- For backward compatibility, `<Dimension>/<Lang>/Corpus.hs` can expose also `defaultCorpus`, which is `corpus` augmented with specific examples. This is controlled by `getDefaultCorpusForLang` in `Duckling.Ranking.Generate`.
- Tests run against each classifier to make sure runtime works as expected.
* MM/DD (en_US) vs DD/MM (en_GB) example to illustrate
Reviewed By: JonCoens, blandinw
Differential Revision: D6038096
fbshipit-source-id: f29c28d
Summary: Updated `README.md` with instructions on how to add a new language in Duckling.
Reviewed By: JonCoens
Differential Revision: D5712523
fbshipit-source-id: 6f5eda0
Summary:
It's not quite clear how to use `Duckling.Debug` now,
see #17
Reviewed By: patapizza
Differential Revision: D5044254
fbshipit-source-id: 09f83cd
Summary:
Turns out that `brew` can succeed installing `pcre`, but still
not install development headers in `/usr/local/include/`
if that path is not writable. `brew doctor` should find that
and related problems.
Relevant ticket: #8
Reviewed By: patapizza, JonCoens
Differential Revision: D5031503
fbshipit-source-id: ba0b8e8
Summary:
This adds a travis script, so that we get feedback when
we push or on pull requests.
It builds and runs tests.
We currently only test with GHC 8.0.2, other versions
are broken for reasons given in the script.
I relaxed the version of `time` in preparation for GHC 8.2.
It also adds an icon in the README.md
Reviewed By: JonCoens
Differential Revision: D5002255
fbshipit-source-id: 47ff3af
Summary:
* moved `AmountOfMoney` up for alphabetical order
* added example request for HTTP server example
Reviewed By: JonCoens
Differential Revision: D4978108
fbshipit-source-id: e98de49
Summary:
`stack exe/RegenMain.hs` uses runghc which is a tool
we don't test with often. Making sure the executable
is rebuilt and using it should be enough.
Reviewed By: patapizza
Differential Revision: D4783844
fbshipit-source-id: 459dbc4
Summary:
This works around https://github.com/haskell/cabal/issues/4350
If we don't do this files get compiled multiple times
and cabal is unhappy.
Reviewed By: patapizza
Differential Revision: D4782749
fbshipit-source-id: 5bbe425
Summary: `DNumber` is a terrible name and was only there because legacy. `Numeral` makes more sense for this dimension, so let's use that instead.
Reviewed By: patapizza
Differential Revision: D4707167
fbshipit-source-id: cd78aa3