(filter-alts weights)
Remove paths for weights that are not alternations. Only alternations (gen/frequency) are currently affected by the weights so remove everything else.
Remove paths for weights that are not alternations. Only alternations (gen/frequency) are currently affected by the weights so remove everything else.
(filter-weight-nodes grammar weights pred?)
Return a weight map where the grammar nodes (for each weight path) fulfill pred? predicate. For example, to return weights that only refer to string or regex terminals use the predicate: #(#{:string :regex} (:tag %))
Return a weight map where the grammar nodes (for each weight path) fulfill pred? predicate. For example, to return weights that only refer to string or regex terminals use the predicate: #(#{:string :regex} (:tag %))
(flatten-text tree & [sep])
Take a tree (sequences hierarchy) and flattens it all the way to a single string (optionally separated by sep). Empty values are removed.
Take a tree (sequences hierarchy) and flattens it all the way to a single string (optionally separated by sep). Empty values are removed.
(flatten-text* tree)
Take a tree (sequences hierarchy) and flattens it all the way to a single sequence of numbers and strings. Empty values are removed.
Take a tree (sequences hierarchy) and flattens it all the way to a single sequence of numbers and strings. Empty values are removed.
(get-grammar-node grammar path)
Get the a grammar node for the given path in grammar. Nil is returned if the path does not exist in the grammar, the tag type along the path don't match, or the numeric parser index is out-of-bounds.
Get the a grammar node for the given path in grammar. Nil is returned if the path does not exist in the grammar, the tag type along the path don't match, or the numeric parser index is out-of-bounds.
(remove-key tree k)
Walk a tree removing every key/value where key match k
Walk a tree removing every key/value where key match k
(tree-deps trees)
Takes a structure like {:a tree-a :b tree-b :c tree-c} and returns a map like {:a #{:b :c} :b #{:c} :c #{}} which means that :a appears in tree-b and tree-c, :b appears in tree-c, but :c does not appear in tree-a or tree-b.
Takes a structure like {:a tree-a :b tree-b :c tree-c} and returns a map like {:a #{:b :c} :b #{:c} :c #{}} which means that :a appears in tree-b and tree-c, :b appears in tree-c, but :c does not appear in tree-a or tree-b.
(tree-matches pred? tree)
Return seq of pred? matches for any node in the tree.
Return seq of pred? matches for any node in the tree.
(weight-reducer-half weight)
Returns the amount to reduce a weight that will result in the final weight being the half of the original weight. A weight of 1 should return 1 and 0 should return 0.
Returns the amount to reduce a weight that will result in the final weight being the half of the original weight. A weight of 1 should return 1 and 0 should return 0.
(weight-reducer-sqrt weight)
Returns the amount to reduce a weight that will result in the final weight being the sqrt of the original weight. A weight of 1 should return 1 and 0 should return 0.
Returns the amount to reduce a weight that will result in the final weight being the sqrt of the original weight. A weight of 1 should return 1 and 0 should return 0.
(weights-reduce grammar weights change-weights reducer-fn)
Takes a grammar, an starting weight map, a map weights to change (change-weights), and a per weight reducer function. Returns a new weight map with weights that are reduced based on change-weights and reducer-fn. If there is a single weight in the change-weights map then that weight in the original will be reduced by (reducer-fn original-weight). If there is more than one weight in change-weights, then the reduce value will be proportional to the ratio of the change-weight value to the sum of all the change-weight values.
Takes a grammar, an starting weight map, a map weights to change (change-weights), and a per weight reducer function. Returns a new weight map with weights that are reduced based on change-weights and reducer-fn. If there is a single weight in the change-weights map then that weight in the original will be reduced by (reducer-fn original-weight). If there is more than one weight in change-weights, then the reduce value will be proportional to the ratio of the change-weight value to the sum of all the change-weight values.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close