clj-duckling.util.analyze
analyze
(analyze s targets context model rules logger)
Analyze a sentence, returns the stash and a curated list of winners.
Args:
s (string):
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.
context (map):
model (Model):
rules (Engine):
logger (): current logger
Returns:
(map): a map with 2 keys :stash and :winners
compare-tokens
(compare-tokens a b classifiers wanted-dims)
Compares two candidate tokens a and b for runtime selection.
wanted-dim is a hash whose keys are the :dim wanted by the caller, the value
can be anything truthy.
Returns nil: not comparable 0: equal 1: greater -1: lesser
get-dims
(get-dims corpus classif rules logger)
Get all dimensions from a corpus.
Args:
corpus (Corpus): the corpus
classif (map): the classification model
rules (vector): the rules engine
logger (Logger): the current logger
Returns:
(set): the corpus dimensions as keywords
parse
(parse s dims context model rules logger)
Parse a sentence, returns a curated list of winners.
Args:
s (string):
context (map):
dims (coll): a coll of dims, only winners of these dims are kept.
If no targets specified, all winners are returned.
model (Model): the tool's model (classifier)
rules (Engine): the tool's rules (engine)
logger (): current logger
Returns:
(collection): a collection of winners tokens
select-winners
(select-winners compare-fn log-prob-fn resolve-fn candidates)
Winner= token that is not 'smaller' (in the sense of the provided partial
order) than another winner, and that resolves to a value
select-winners*
(select-winners* compare-fn resolve-fn already-selected candidates)