Implementation of Markov Chain to generate, for instance, text.
Implementation of Markov Chain to generate, for instance, text.
(analyse corpus & {:keys [lookback max-length] :or {lookback 2}})
Analyse corpus
and return a state space. Option lookback
determines the
strength of the lookup key and defaults to 2. max-length
will be set to
largest row length in the corpus if no value is supplied.
Analyse `corpus` and return a state space. Option `lookback` determines the strength of the lookup key and defaults to 2. `max-length` will be set to largest row length in the corpus if no value is supplied.
(analyse-text text & opts)
Analyse text
as a corpus of lines and words.
Analyse `text` as a corpus of lines and words.
(generate {:keys [space lookback max-length] :as state-space})
Generate new chains from given state-space
. When the generated
chain exceeds max-length
it will contain ::et-cetera
it the last
position. This function uses weighted
to do its random picking.
Generate new chains from given `state-space`. When the generated chain exceeds `max-length` it will contain `::et-cetera` it the last position. This function uses `weighted` to do its random picking.
(generate-text state-space)
Generate a new sentence from are state-space
.
Generate a new sentence from are `state-space`.
(split-sentences text)
Split text
into sentences.
Split `text` into sentences.
(split-words sentence)
Split sentence
into words.
Split `sentence` into words.
(weighted m)
Pick a random value from a weighted set given a map for values and
weights. The CLJ implementation of this function uses
clojure.data.generators
, to get reproducible results use it's
*rnd*
binding .
Pick a random value from a weighted set given a map for values and weights. The CLJ implementation of this function uses `clojure.data.generators`, to get reproducible results use it's `*rnd*` binding .
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close