rasa/duckling!Duckling Logo
Duckling is a Haskell library that parses text into structured data.
bash"the first Tuesday of October" => {"value":"2017-10-03T00:00:00.000-07:00","grain":"day"}
A Haskell environment is required. We recommend using stack.
On Linux and MacOS you'll need to install PCRE development headers. On Linux, use your package manager to install them. On MacOS, the easiest way to install them is with Homebrew:
bashbrew install pcre
If that doesn't help, try running brew doctor and fix
the issues it finds.
To compile and run the binary:
bashstack build stack exec duckling-example-exe
The first time you run it, it will download all required packages.
This runs a basic HTTP server. Example request:
bashcurl -XPOST [***] --data 'locale=en_GB&text=tomorrow at eight'
In the example application, all dimensions are enabled by default. Provide the parameter dims to specify which ones you want. Examples:
bashIdentify credit card numbers only: $ curl -XPOST [***] --data 'locale=en_US&text="4111-1111-1111-1111"&dims="["credit-card-number"]"' If you want multiple dimensions, comma-separate them in the array: $ curl -XPOST [***] --data 'locale=en_US&text="3 cups of sugar"&dims="["quantity","numeral"]"'
See exe/ExampleMain.hs for an example on how to integrate Duckling in your
project.
If your backend doesn't run Haskell or if you don't want to spin your own Duckling server, you can directly use wit.ai's built-in entities.
Duckling supports many languages, but most don't support all dimensions yet (we need your help!). Please look into this directory for language-specific support.
| Dimension | Example input | Example value output |
|---|---|---|
AmountOfMoney | "42€" | {"value":42,"type":"value","unit":"EUR"} |
CreditCardNumber | "4111-1111-1111-1111" | {"value":"4111111111111111","issuer":"visa"} |
Distance | "6 miles" | {"value":6,"type":"value","unit":"mile"} |
Duration | "3 mins" | {"value":3,"minute":3,"unit":"minute","normalized":{"value":180,"unit":"second"}} |
Email | "***" | {"value":"***"} |
Numeral | "eighty eight" | {"value":88,"type":"value"} |
Ordinal | "33rd" | {"value":33,"type":"value"} |
PhoneNumber | "+1 (650) 123-4567" | {"value":"(+1) 6501234567"} |
Quantity | "3 cups of sugar" | {"value":3,"type":"value","product":"sugar","unit":"cup"} |
Temperature | "80F" | {"value":80,"type":"value","unit":"fahrenheit"} |
Time | "today at 9am" | {"values":[{"value":"2016-12-14T09:00:00.000-08:00","grain":"hour","type":"value"}],"value":"2016-12-14T09:00:00.000-08:00","grain":"hour","type":"value"} |
Url | "[***]" | {"value":"[***]","domain":"api.wit.ai"} |
Volume | "4 gallons" | {"value":4,"type":"value","unit":"gallon"} |
Custom dimensions are also supported.
To regenerate the classifiers and run the test suite:
bashstack build :duckling-regen-exe && stack exec duckling-regen-exe && stack test
It's important to regenerate the classifiers after updating the code and before running the test suite.
To extend Duckling's support for a dimension in a given language, typically 4 files need to be updated:
Duckling/<Dimension>/<Lang>/Rules.hs
Duckling/<Dimension>/<Lang>/Corpus.hs
Duckling/Dimensions/<Lang>.hs (if not already present in Duckling/Dimensions/Common.hs)
Duckling/Rules/<Lang>.hs
To add a new language:
Numeral.To add a new locale:
Rules have a name, a pattern and a production. Patterns are used to perform character-level matching (regexes on input) and concept-level matching (predicates on tokens). Productions are arbitrary functions that take a list of tokens and return a new token.
The corpus (resp. negative corpus) is a list of examples that should (resp. shouldn't) parse. The reference time for the corpus is Tuesday Feb 12, 2013 at 4:30am.
Duckling.Debug provides a few debugging tools:
bash$ stack repl --no-load > :l Duckling.Debug > debug (makeLocale EN $ Just US) "in two minutes" [Seal Time] in|within|after <duration> (in two minutes) -- regex (in) -- <integer> <unit-of-duration> (two minutes) -- -- integer (0..19) (two) -- -- -- regex (two) -- -- minute (grain) (minutes) -- -- -- regex (minutes) [Entity {dim = "time", body = "in two minutes", value = RVal Time (TimeValue (SimpleValue (InstantValue {vValue = 2013-02-12 04:32:00 -0200, vGrain = Second})) [SimpleValue (InstantValue {vValue = 2013-02-12 04:32:00 -0200, vGrain = Second})] Nothing), start = 0, end = 14}]
Duckling is BSD-licensed.
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
在 Linux 系统配置镜像服务
在 Docker Desktop 配置镜像
Docker Compose 项目配置
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
MacOS OrbStack 容器配置
在宝塔面板一键配置镜像
Synology 群晖 NAS 配置
飞牛 fnOS 系统配置镜像
极空间 NAS 系统配置服务
爱快 iKuai 路由系统配置
绿联 NAS 系统配置镜像
QNAP 威联通 NAS 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
无需登录使用专属域名
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
免费版仅支持 Docker Hub 访问,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等;免费版仅支持 docker.io。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
来自真实用户的反馈,见证轩辕镜像的优质服务