Skip to content

toastdriven/attain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

attain

A little Markov Chain library, for funsies.

Usage

>>> import attain
>>> mc = attain.MarkovChain()

# In the Real World™, you'd probably want to create the corpus
# sequence-of-tokens a better way. But for example purposes...
>>> sentences = """
...     Hello, world!
...     Hello Kitty is my favorite.
...     My life for Aiur!
... """
>>> corpus = [
...     word.lower().rstrip(",!.").strip()
...     for word
...     in sentences.split()
... ]

# At current, training can only be done once.
>>> mc.train(corpus)

>>> mc.generate()
['is', 'my', 'life', 'for', 'aiur']

>>> mc.generate_sentence()
"For aiur kitty is my favorite!"

Tests

$ git clone https://github.com/toastdriven/attain.git
$ cd attain

$ pipenv install --dev

$ pipenv shell

$ pytest tests

License

New BSD

About

A little Markov Chain library, for funsies.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages