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

c

(c n)

classifiers-map

corpus-map

default-context

(default-context opt)
Build a default context for testing. opt can be either :corpus or :now

details

extract

(extract sentence context leven-stash targets)
API used by Wit.ai (will be moved to Wit)
targets is a coll of maps {:module :dim :label} for instance:
{:module fr$core, :dim duration, :label wit$duration} to get duration results
Returns a single coll of tokens with :body :value :start :end :label (=wisp) :latent

gen-config-for-langs-test

get-classifier-test

get-dims

(get-dims module {:keys [context tests]})
Retrieves all available dimensions for module by running its corpus.

get-rules-test

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.

load!-test

make-corpus-test

make-rules-test

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.

rules-map

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]

token