clj-duckling.util.engine
This component parses a phrase and extracts information based on rules.
The two main phases are matching and production.
1. rules are transformed into objets via rules macro
2. rules are (recursively) matched based on theirs pattern vectors.
3. tokens containing final info are produced using their production rules
build-rule
(build-rule name pattern production)
export-value
multimethod
Transforms a token value for API output. Returns the modified value.
maxlen-judge
(maxlen-judge stash)
Choose the winning token in the stash.
pass-all
(pass-all sentence rules logger)
Make as many passes as necessary until no new tokens are produced
(there is a limit to avoid infinite loops though)
pattern-fn
(pattern-fn pattern)
Makes a pattern function from the pattern slice (regex...)
resolve-token
multimethod
Resolve a token based on its dimension, predicate, and the context.
Returns a coll of tokens, since they can have multiple resolutions, or none.
Unresolved tokens are returned as is, without a :value key.
rules
(rules forms)
Parses a set of rules and 'add' them into 'the-rules'.
Can be called several times, since rules might spread into several files.