Basic Usage
Importing and initializing WordSiv
Once you've installed WordSiv, try generating a sentence:
from wordsiv import WordSiv
# Make a WordSiv object, w/ default Vocab set to English
wsv = WordSiv(vocab="en")
# Generate a sentence w/out any word filtering
print(wsv.sent())
You should see a random sentence in the console in the lower-right of DrawBot!
Check out the Quick Reference if you want to quickly jump into WordSiv, or read on for more detailed information.
Listing Vocabs
WordSiv generates text using Vocabs:
objects that contain a word list (usually with occurrence counts) for a given
language. WordSiv includes some Vocabs, and you can make your own (instructions
coming soon!). You can see all available Vocabs with: list_vocabs()
:
Selecting a Vocab
You can set which Vocab you want to use on WordSiv
object initialization,
which will affect all text generation methods you call:
Alternatively, you can specify vocab
when you are calling word()
, sent()
,
etc.:
Note
The vocab
argument for word()
, sent()
, etc. has precedence:
Restricting the Glyph Set
The glyphs
argument specifies a whitelist of glyphs that WordSiv will use to
constrain text generation.
You can set glyphs
on WordSiv
object initialization, which will affect all
subsequent text generation methods you call:
from wordsiv import WordSiv
wsv = WordSiv(vocab="en", glyphs="HAMBUGERFONTShambugerfonts.,")
print(wsv.words())
Alternatively, you can specify glyphs
when you are calling word()
, sent()
,
etc.: