跳转到主要内容

生成Markov Memes的命令行工具。

项目描述

Markov Meme

PyPI version GitHub actions status

使用Markov模型生成主题化的Memes或随机生成的文本怎么样?我也这么认为。

用法

安装

您可以从PyPI安装

pip install markovmeme

或者直接从仓库安装

$ git clone https://github.com/vsoch/markovmeme
$ python setup.py install

用法

您可以通过以下基本用法查看。基本上,有一个“generate”命令

$ markov-meme 
usage: markov-meme [-h] {generate} ...

Markov Meme Generator

optional arguments:
  -h, --help  show this help message and exit

actions:
  actions for Markov Meme Generator

  {generate}  markovmeme actions
    generate  generate a meme

您可以通过查看generate帮助来查看可用的语料库

$ markov-meme generate --help
usage: markov-meme generate [-h] [--outfile OUTFILE] [--fontsize FONTSIZE]
                            [--font {OpenSans-Regular,Pacifico-Regular,Anton-Regular}]
                            [--corpus {hamlet,dr_seuss,trump_speech,the_office,office/stanley,office/toby,office/meredith,office/holly,office/creed,office/oscar,office/deangelo,office/david,office/dwight,office/kelly,office/phyllis,office/jim,office/nellie,office/gabe,office/clark,office/roy,office/karen,office/michael,office/andy,office/charles,office/kevin,office/pam,office/ryan,office/erin,office/robert,office/darryl,office/pete,office/jan,office/jo,office/angela}]
                            [--custom-corpus CUSTOM_CORPUS]
                            [--image CUSTOM_IMAGE] [--no-model]

optional arguments:
  -h, --help            show this help message and exit
  --outfile OUTFILE     the output file to save the image (defaults to
                        randomly generated png)
  --fontsize FONTSIZE   font size of text (if desired) defaults to 16
  --font {OpenSans-Regular,Pacifico-Regular,Anton-Regular}
                        choice of font (defaults to open sans)
  --corpus {hamlet,dr_seuss,trump_speech,the_office,office/stanley,office/toby,office/meredith,office/holly,office/creed,office/oscar,office/deangelo,office/david,office/dwight,office/kelly,office/phyllis,office/jim,office/nellie,office/gabe,office/clark,office/roy,office/karen,office/michael,office/andy,office/charles,office/kevin,office/pam,office/ryan,office/erin,office/robert,office/darryl,office/pete,office/jan,office/jo,office/angela}
                        the corpus to use to generate the meme, matches to
                        images.
  --custom-corpus CUSTOM_CORPUS
                        A custom corpus file, full path
  --image CUSTOM_IMAGE  A custom image file, full path
  --no-model            Don't generate a sentence from corpus, just randomly
                        select sentence.

随机生成

要从随机语料库生成Meme,您可以运行以下命令

$ markov-meme generate

如果随机选择的语料库没有匹配的图片,您将看到

No images exist for corpus office/clark. Please specify --image.

语料库和图片选择

您可以再次运行相同的命令或指定特定的语料库和图片。

$ markov-meme generate --corpus office/michael --image markovmeme/data/images/office/michael1.png

对于指定自定义语料库,它应该是一个包含从其中生成模型的行的文本文件。

$ markov-meme generate --custom-corpus markovmeme/data/corpus/office/michael.txt --image markovmeme/data/images/office/michael2.png

跳过模型

如果您不想使用模型(并想要某些语料库的真实行)请添加 --no-model

$ markov-meme generate --no-model

交互式Python

大部分情况下,文本大小和字符数量限制在1-3行内。如果您想自定义或进行其他操作,可以直接与类进行交互。

from markovmeme.main import MemeImage
from markovmeme.text import generate_text

# corpus is absolute path, or relative to module's data/corpus folder
corpus = "office/michael"

text = generate_text(corpus=corpus, use_model=True, size=10)

# Set image to full path, or None to select based on corpus
meme = MemeImage(image=None, corpus=corpus)

# Add text generated, centered on top
meme.write_text(text, fontsize=args.fontsize, font=font)

# Leave outfile as None to generate random name
meme.save_image(None)

支持

您有问题吗?或者想建议一个功能来改进它?请提交问题!

项目详情


下载文件

下载您平台对应的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码分发

markovmeme-0.0.1.tar.gz (51.8 MB 查看哈希值)

上传时间 源代码

构建分发

markovmeme-0.0.1-py3.7.egg (51.9 MB 查看哈希值)

上传时间 源代码

支持

AWSAWS云计算和安全赞助商DatadogDatadog监控FastlyFastlyCDNGoogleGoogle下载分析MicrosoftMicrosoftPSF赞助商PingdomPingdom监控SentrySentry错误日志StatusPageStatusPage状态页面