duckling.core
The main module with public API.
analyze
(analyze s context module targets base-stash)
Parse a sentence, returns the stash and a curated list of winners.
Args:
s (string):
context (map):
module (keyword): language module
targets (coll): a coll of {:dim dim :label label} : only winners of these dims are
kept, and they receive a :label key = the label provided.
If no targets specified, all winners are returned.
base-stash ():
Returns:
(map): a map with 2 keys :stash and :winners
default-context
(default-context opt)
Build a default context for testing. opt can be either :corpus or :now
gen-config-for-langs-test
get-dims
(get-dims module {:keys [context tests]})
Retrieves all available dimensions for module by running its corpus.
load!
(load!)
(load! {:keys [languages config logger]})
(Re)loads rules and classifiers for languages or/and config.
Args:
langsconfig (map): (optional) languages map with 2 keywords (:languages :config).
If no language list nor config provided, loads all languages.
Returns:
(map): loaded modules with available dimensions.
parse
(parse module text)
(parse module text dims)
(parse module text dims context)
Public API. Parses text using given module.
Args:
module (string): the language module (ex en$core)
text (string): the text to parse
dims (list): (optional) list of keywords referencing token dimensions to be extracted (default [] all dimensions)
context (map): (optional) a map with a :reference-time key. If not provided, the system current date and time is used.
Returns:
(map): the tokens
play
(play module-id s)
(play module-id s targets)
(play module-id s targets context)
Show processing details for one sentence. Defines a 'details' function.
run
(run)
(run module-id)
Runs the corpus and prints the results to the terminal.
run-corpus
(run-corpus {context :context, tests :tests} module)
Run the corpus given in parameter for the given module.
Returns a list of vectors [0|1 text error-msg]